Skip to content

Fix: remove gcp project and get host-project ID - #467

Closed
helleengebakken wants to merge 4 commits into
mainfrom
fix/remove-gcp_project_id
Closed

Fix: remove gcp project and get host-project ID#467
helleengebakken wants to merge 4 commits into
mainfrom
fix/remove-gcp_project_id

Conversation

@helleengebakken

@helleengebakken helleengebakken commented Aug 31, 2026

Copy link
Copy Markdown

Resolve project ID from OTel resource attribute instead of GCP_PROJECT_ID

resolveProjectId() built the projects/{projectId}/traces/{traceId} value written to logs by falling back through GOOGLE_CLOUD_PROJECT → GCP_PROJECT_ID. GCP_PROJECT_ID isn't a GCP standard env var and was unused as a fallback source, so it's dropped.

In its place: Kubernetes workloads are moving trace export to the cluster's host project (ent-kub-) instead of their own project, so the code now reads the gcp.project_id OpenTelemetry resource attribute from OTEL_RESOURCE_ATTRIBUTES first - that's where the destination project will actually live post-migration. GOOGLE_CLOUD_PROJECT remains the fallback for runtimes it doesn't affect (Cloud Run, Firebase), which still export traces to their own project.

No behavior change for services that don't set gcp.project_id.

Helle Engebakken added 2 commits August 31, 2026 13:41
…ect_id

Kubernetes workloads will export traces to the cluster host project
(ent-kub-<env>) instead of their own project (CLOUD-4435), so the
projects/{projectId}/traces/{traceId} value written to logs must use
that destination project. It is carried in the gcp.project_id OTel
resource attribute; GOOGLE_CLOUD_PROJECT remains the fallback for
runtimes (Cloud Run, Firebase) that still export to their own project.
Copilot AI lite review requested due to automatic review settings August 31, 2026 12:28
@helleengebakken
helleengebakken requested review from a team as code owners August 31, 2026 12:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates the GCP Logback Logstash encoder to resolve the trace project ID from OpenTelemetry resource attributes (supporting Kubernetes “host project” trace export), and removes the non-standard GCP_PROJECT_ID environment variable fallback.

Changes:

  • Prefer gcp.project_id from OTEL_RESOURCE_ATTRIBUTES when resolving the project ID used in projects/{projectId}/traces/{traceId}.
  • Keep GOOGLE_CLOUD_PROJECT as the fallback source for runtimes where traces remain in the workload project.
  • Add a small parsing helper for OTEL_RESOURCE_ATTRIBUTES.
File summaries
File Description
gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverLogstashEncoder.java Switches project-id resolution to prefer OTel resource attribute gcp.project_id and removes GCP_PROJECT_ID fallback.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Helle Engebakken and others added 2 commits August 31, 2026 14:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@AlexanderBrevig

Copy link
Copy Markdown
Contributor

Did todays findings with ditto hacking change the validity of this PR? My spidey sense is that we should not need to do so much manual work and that the java agent augments logs correctly when using the default behavior (logs and traces to same default project aka the host project)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants