Skip to content

Opentelemetry support - #450

Merged
skjolber merged 39 commits into
mainfrom
opentelemetry
Aug 24, 2026
Merged

Opentelemetry support#450
skjolber merged 39 commits into
mainfrom
opentelemetry

Conversation

@skjolber

@skjolber skjolber commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Support both Opentelemetry agent and Opentelemetry spring boot starter (native Spring). Borrows from #439 and #442.

  • map MDC fields to the appropriate Azure / GCP structured JSON output.
    • if no opentelemetry agent, assume spring boot starter (micrometer) in low-level encoder
  • disable use of correlaction->trace header mappings if opentelemetry present
    • deprecate doing the mappings for correlation id
  • add OpenTelemetry examples for both agent and spring boot starter
    • test that the resulting JSON output is as expected

Not included / future improvements:

  • gRPC MDC Context handling is kept as-is, not suitable for Opentelemetry local baggage / micrometer context propagating according to AI
  • duplicate JSON field check (not present in various other contexts either)

viliket and others added 12 commits August 7, 2026 15:28
GKE ingests structured JSON logs written to stdout. The logging agent promotes only its reserved logging.googleapis.com/trace and logging.googleapis.com/spanId keys to the corresponding LogEntry fields; ordinary traceId and spanId keys remain in jsonPayload.

Map the real OpenTelemetry trace and span IDs to those reserved keys. Prefer OpenTelemetry values over legacy MDC values and avoid duplicate JSON fields.

See: https://docs.cloud.google.com/logging/docs/agent/logging/configuration#special-fields

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@skjolber
skjolber requested review from a team as code owners August 14, 2026 14:37
Copilot AI lite review requested due to automatic review settings August 14, 2026 14:37
@skjolber
skjolber marked this pull request as draft August 14, 2026 14:37

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.

Pull request overview

This PR extends cloud-logging’s GCP/Azure structured logging to work with both the OpenTelemetry Java agent and Spring Boot’s native OpenTelemetry starter (Micrometer bridge), primarily by translating MDC trace/span fields into the platform-specific JSON keys and disabling legacy correlation-id → trace mappings when OTel is present.

Changes:

  • Add GCP MDC providers that map OTel agent (trace_id/span_id/trace_flags) and Micrometer (traceId/spanId/traceSampled) MDC fields into GCP “special fields”.
  • Add Azure encoder support for OTel agent MDC (trace_id/span_id) → Azure (traceId/spanId) field mapping.
  • Add multiple new OTel-focused example apps (web + gRPC; agent + starter) and tests asserting produced JSON output.

Reviewed changes

Copilot reviewed 103 out of 104 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
test/test-logback-junit/src/main/java/no/entur/logging/cloud/logback/logstash/test/junit/LogStatement.java Adds JSON parsing helpers for tests to assert specific fields in captured log lines.
settings.gradle Registers new OTEL example subprojects.
build.gradle Aligns versions plugin application with the plugin id declared in plugins {}.
gcp/spring-boot-autoconfigure-gcp/build.gradle Adds Micrometer tracing dependency to support sampling propagation.
gcp/spring-boot-autoconfigure-gcp/src/main/java/no/entur/logging/cloud/gcp/spring/GlobalSamplingLoggingHandler.java Adds an ObservationHandler that stamps sampling info into MDC.
gcp/spring-boot-autoconfigure-gcp-test/src/main/resources/logback/spring-defaults-test.xml Adjusts test console pattern (removes correlation pattern placeholder).
gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverOpenTelemetryTraceMdcJsonProvider.java Maps OTel agent MDC keys to GCP reserved structured logging fields; adds agent detection helper.
gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverMicrometerTraceMdcJsonProvider.java Maps Micrometer tracing MDC keys to GCP reserved structured logging fields.
gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverLogstashEncoder.java Switches MDC mapping provider based on whether the OTel Java agent is detected.
gcp/logback-logstash-encoder-gcp/src/test/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverOpenTelemetryTraceMdcJsonProviderTest.java Adds tests validating GCP trace/span field mapping behavior.
gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/NoOpenTelemetryAgentCondition.java New condition to disable legacy correlation-id trace filter when OTel agent is present.
gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/GcpTraceMdcSupportBuilder.java Marks legacy builder deprecated (legacy correlation-based tracing path).
gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/GcpTraceMdcSupport.java Marks legacy helper deprecated (legacy correlation-based tracing path).
gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/GcpTraceFilter.java Marks legacy servlet filter deprecated (legacy correlation-based tracing path).
gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/GcpTraceAutoConfiguration.java Disables legacy trace filter when OTel starter is on classpath or agent is detected.
gcp/correlation-id-trace-spring-boot-gcp-web/README.md Updates README to reflect MDC fields produced and OTel-based auto-disable behavior.
gcp/correlation-id-trace-spring-boot-gcp-web/build.gradle Adds dependency on GCP logstash encoder for agent detection.
gcp/correlation-id-trace-spring-boot-gcp-grpc/src/main/java/no/entur/logging/cloud/gcp/trace/spring/grpc/NoOpenTelemetryAgentCondition.java New condition to disable legacy correlation-id gRPC interceptor when OTel agent is present.
gcp/correlation-id-trace-spring-boot-gcp-grpc/src/main/java/no/entur/logging/cloud/gcp/trace/spring/grpc/interceptor/OrderedTraceIdGrpcMdcContextServerInterceptor.java Marks legacy trace interceptor deprecated.
gcp/correlation-id-trace-spring-boot-gcp-grpc/src/main/java/no/entur/logging/cloud/gcp/trace/spring/grpc/GcpGrpcTraceAutoConfiguration.java Disables legacy trace interceptor when OTel starter is on classpath or agent is detected.
gcp/correlation-id-trace-spring-boot-gcp-grpc/README.md Updates README to reflect OTel-based auto-disable behavior.
gcp/correlation-id-trace-spring-boot-gcp-grpc/build.gradle Adds dependency on GCP logstash encoder for agent detection.
azure/spring-boot-autoconfigure-azure-test/src/main/resources/logback/spring-defaults-test.xml Adjusts test console pattern (removes correlation pattern placeholder).
azure/logback-logstash-encoder-azure/src/main/java/no/entur/logging/cloud/azure/logback/logstash/AzureOpenTelemetryTraceMdcJsonProvider.java Adds OTel agent MDC → Azure field mapping provider + agent detection helper.
azure/logback-logstash-encoder-azure/src/main/java/no/entur/logging/cloud/azure/logback/logstash/AzureLogstashEncoder.java Replaces default MDC provider with Azure OTel mapping provider when agent is detected.
examples/gcp-web-without-test-artifacts-example/build.gradle Adds OTel starter/testing deps to existing “without test artifacts” web example.
examples/gcp-grpc-spring-without-test-artifacts-example/src/main/java/no/entur/grpc/example/GreetingController.java Removes legacy trace-id interceptor from example interceptor chain.
examples/gcp-grpc-spring-without-test-artifacts-example/src/main/java/no/entur/grpc/example/GreetingControllerWithOnDemandLogging.java Removes legacy trace-id interceptor from example on-demand interceptor chain.
examples/gcp-grpc-spring-without-test-artifacts-example/build.gradle Adds OTel starter/testing deps to existing “without test artifacts” gRPC example.
examples/gcp-grpc-spring-example/src/main/java/no/entur/grpc/example/GreetingController.java Removes legacy trace-id interceptor from example interceptor chain.
examples/gcp-grpc-spring-example/src/main/java/no/entur/grpc/example/GreetingControllerWithOnDemandLogging.java Removes legacy trace-id interceptor from example on-demand interceptor chain.
examples/gcp-web-without-test-artifacts-otel-starter-example/build.gradle New web example using Spring Boot OTel starter (machine-readable JSON) + tests.
examples/gcp-web-without-test-artifacts-otel-starter-example/README.md Documents the new OTel starter “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/resources/application.properties Config for new OTel starter “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/java/org/entur/example/web/DemoApplication.java Spring Boot main for new OTel starter “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/java/org/entur/example/web/config/LogConfiguration.java Logbook body filter example (masking secret field).
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/java/org/entur/example/web/config/WebSecurityConfig.java Example security configuration for the app.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Example REST endpoints producing logs and large payloads.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/main/java/org/entur/example/web/rest/MyEntity.java Example DTO used by endpoints/tests.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/test/java/org/entur/example/web/otel/agent/WebLoggingFormatTest.java Tests log output contains GCP trace/span fields.
examples/gcp-web-without-test-artifacts-otel-starter-example/src/test/java/org/entur/example/web/otel/agent/OndemandWebLoggingHttpOkHighLogLevelTest.java Tests on-demand logging behavior with OTel starter example.
examples/gcp-web-without-test-artifacts-otel-agent-example/build.gradle New web example running tests with OTel Java agent attached.
examples/gcp-web-without-test-artifacts-otel-agent-example/README.md Documents the new OTel agent “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/resources/application.properties Config for new OTel agent “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/java/org/entur/example/web/DemoApplication.java Spring Boot main for new OTel agent “without test artifacts” web example.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/java/org/entur/example/web/config/LogConfiguration.java Logbook body filter example (masking secret field).
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/java/org/entur/example/web/config/WebSecurityConfig.java Example security configuration for the app.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Example REST endpoints producing logs and large payloads.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/main/java/org/entur/example/web/rest/MyEntity.java Example DTO used by endpoints/tests.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/test/java/org/entur/example/web/otel/agent/WebLoggingFormatTest.java Tests log output contains GCP trace/span fields.
examples/gcp-web-without-test-artifacts-otel-agent-example/src/test/java/org/entur/example/web/otel/agent/OndemandWebLoggingHttpOkHighLogLevelTest.java Tests on-demand logging behavior with OTel agent example.
examples/gcp-web-otel-starter-example/build.gradle New web example using OTel starter plus local dev bootRun configuration.
examples/gcp-web-otel-starter-example/README.md Documents the new OTel starter web example.
examples/gcp-web-otel-starter-example/src/main/resources/application.properties Config for new OTel starter web example.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/DemoApplication.java Spring Boot main for new OTel starter web example.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/config/LogConfiguration.java Logbook body filter example (masking secret field).
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/config/WebSecurityConfig.java Security config + example filters for MDC enrichment and auth behavior.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/config/UserIdEnricherFilter.java Example filter enriching MDC (subject) for testing.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/config/ReturnHttp401AuthenticationHeaderFilter.java Example filter returning 401 under certain Authorization header.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Richer REST example with multiple endpoints and error cases.
examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/rest/MyEntity.java Example DTO used by endpoints/tests.
examples/gcp-web-otel-starter-example/src/test/java/org/entur/example/web/otel/starter/WebLoggingFormatTest.java Tests log output contains GCP trace/span fields across encoder modes.
examples/gcp-web-otel-starter-example/src/test/java/org/entur/example/web/otel/starter/OndemandWebLoggingHttpOkHighLogLevelTest.java Tests on-demand logging behavior for OTel starter web example.
examples/gcp-web-otel-agent-example/build.gradle New web example running tests with OTel Java agent attached + bootRun dev config.
examples/gcp-web-otel-agent-example/README.md Documents the new OTel agent web example.
examples/gcp-web-otel-agent-example/src/main/resources/application.properties Config for new OTel agent web example.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/DemoApplication.java Spring Boot main for new OTel agent web example.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/config/LogConfiguration.java Logbook body filter example (masking secret field).
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/config/WebSecurityConfig.java Security config + example filters for MDC enrichment and auth behavior.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/config/UserIdEnricherFilter.java Example filter enriching MDC (subject) for testing.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/config/ReturnHttp401AuthenticationHeaderFilter.java Example filter returning 401 under certain Authorization header.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java Richer REST example with multiple endpoints and error cases.
examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/rest/MyEntity.java Example DTO used by endpoints/tests.
examples/gcp-web-otel-agent-example/src/test/java/org/entur/example/web/WebLoggingFormatTest.java Tests log output contains GCP trace/span fields across encoder modes.
examples/gcp-web-otel-agent-example/src/test/java/org/entur/example/web/OndemandWebLoggingHttpOkHighLogLevelTest.java Tests on-demand logging behavior for OTel agent web example.
examples/gcp-web-otel-agent-example/src/test/java/org/entur/example/web/ActuatorTest.java Exercises actuator readiness endpoint under different encoder modes.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/build.gradle New gRPC example (Spring) using OTel starter + protobuf generation.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/README.md Documents the new OTel starter gRPC “without test artifacts” example.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/resources/application.properties Config for new OTel starter gRPC example.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/proto/greeting_service.proto New proto definitions for example service.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/proto/greeting_message.proto New proto message types for example service.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/DemoApplication.java Spring Boot main for new gRPC example.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/MyGrpcConfig.java Example gRPC configuration incl. logging filters and interceptors.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/MyValidationServerInterceptor.java Example interceptor emitting structured error status.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/AbstractGreetingController.java Example gRPC service implementation producing logs and errors.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/GreetingController.java Registers example gRPC service with interceptor chain (non-ondemand).
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/main/java/no/entur/grpc/example/GreetingControllerWithOnDemandLogging.java Registers example gRPC service with interceptor chain (ondemand).
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/starter/SpringAbstractGrpcTest.java Test base for asserting GCP trace/span fields in captured logs.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/starter/SpringGrpcLoggingFormatTest.java Basic gRPC logging format test under OTel starter.
examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/starter/SpringOndemandGrpcLoggingHighLogLevelTest.java On-demand gRPC logging behavior test under OTel starter.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/build.gradle New gRPC example (Spring) running tests with OTel Java agent attached.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/README.md Documents the new OTel agent gRPC “without test artifacts” example.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/resources/application.properties Config for new OTel agent gRPC example.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/proto/greeting_service.proto New proto definitions for agent-backed example service.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/proto/greeting_message.proto New proto message types for agent-backed example service.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/DemoApplication.java Spring Boot main for new gRPC agent example.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/MyGrpcConfig.java Example gRPC configuration incl. logging filters and interceptors.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/MyValidationServerInterceptor.java Example interceptor emitting structured error status.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/AbstractGreetingController.java Example gRPC service implementation producing logs and errors.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/GreetingController.java Registers example gRPC service with interceptor chain (non-ondemand).
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/main/java/no/entur/grpc/example/GreetingControllerWithOnDemandLogging.java Registers example gRPC service with interceptor chain (ondemand).
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/agent/SpringAbstractGrpcTest.java Test base for asserting GCP trace/span fields in captured logs.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/agent/SpringGrpcLoggingFormatTest.java Basic gRPC logging format test under OTel agent.
examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/src/test/java/no/entur/grpc/example/without/test/artifacts/otel/agent/SpringOndemandGrpcLoggingHighLogLevelTest.java On-demand gRPC logging behavior test under OTel agent.
Suppressed comments (1)

gcp/logback-logstash-encoder-gcp/src/test/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverOpenTelemetryTraceMdcJsonProviderTest.java:46

  • This test case uses Micrometer-style MDC keys (traceId/spanId) even though this provider only remaps OTel agent keys (trace_id/span_id).

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

skjolber and others added 7 commits August 14, 2026 16:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
fix: PR 451 - autodetect micrometer+otel starter, add trace_sampled test, fix TraceSampledMdcHandler

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
…-gcp (#453)

feat: move TraceSampledMdcHandler to spring-boot-autoconfigure-gcp with @AutoConfigureAfter and class-level conditions

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
@skjolber
skjolber requested a balanced review from Copilot August 15, 2026 15:51
* Opentelemetry: Restore project id in trace

* Use fixed prefix

* Update gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverLogstashEncoder.java

Co-authored-by: Alexander Brevig <alexander.brevig@hey.com>

---------

Co-authored-by: Alexander Brevig <alexander.brevig@hey.com>
@helleengebakken
helleengebakken marked this pull request as ready for review August 21, 2026 12:28
@helleengebakken
helleengebakken requested review from AlexanderBrevig, helleengebakken and tommybo-entur and a balanced review from Copilot August 21, 2026 12:29

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.

Pull request overview

Copilot reviewed 104 out of 105 changed files in this pull request and generated 11 comments.

Comment thread gcp/correlation-id-trace-spring-boot-gcp-web/README.md
Comment thread gcp/correlation-id-trace-spring-boot-gcp-grpc/README.md
Comment thread examples/gcp-web-otel-agent-example/README.md Outdated
Comment thread .github/workflows/deploy-manual-snapshot.yml
skjolber and others added 2 commits August 24, 2026 12:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI and others added 2 commits August 24, 2026 10:08
…MdcJsonProvider

Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>

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.

Pull request overview

Copilot reviewed 104 out of 105 changed files in this pull request and generated 2 comments.

Suppressed comments (7)

gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverOpenTelemetryTraceMdcJsonProvider.java:59

  • When MDC contains both trace_id/span_id and an existing GCP reserved key, this loop emits the reserved property twice: once for the mapped OTel key and again in default. Duplicate jsonPayload fields can make Fluentbit drop several seconds of logs. Resolve precedence before writing (prefer the OTel value) and emit each reserved key at most once.
    gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverMicrometerTraceMdcJsonProvider.java:59
  • When MDC also contains logging.googleapis.com/trace, logging.googleapis.com/spanId, or logging.googleapis.com/trace_sampled, these mappings produce duplicate JSON properties when the target entry is later written by default. This is operationally unsafe for GCP ingestion. Resolve the mapped values first and skip all source/target entries so each reserved field is emitted once.
    gcp/logback-logstash-encoder-gcp/src/main/java/no/entur/logging/cloud/gcp/logback/logstash/StackdriverOpenTelemetryTraceMdcJsonProvider.java:105
  • Agent detection depends on the agent JAR path containing opentelemetry, but -javaagent permits any filename (for example /opt/agent.jar). In that valid deployment the encoder selects the Micrometer provider, leaves the agent's snake_case MDC keys unmapped, and enables legacy fake-trace filters. Avoid filename-based detection; select mappings from the MDC keys present on each event and use an actual agent signal for auto-configuration.
    azure/logback-logstash-encoder-azure/src/main/java/no/entur/logging/cloud/azure/logback/logstash/AzureOpenTelemetryTraceMdcJsonProvider.java:66
  • This assumes the -javaagent path contains opentelemetry, although Java allows the agent JAR to be renamed. With -javaagent:/opt/agent.jar, the Azure MDC provider is not replaced and trace_id/span_id remain unmapped. Install a provider that can handle both naming schemes, or detect the running agent without relying on its filename.
    private static boolean isOtelArgument(String argument) {
        String lowerArg = argument.toLowerCase();
        return lowerArg.contains("-javaagent:") && lowerArg.contains("opentelemetry");

gcp/spring-boot-autoconfigure-gcp/src/main/java/no/entur/logging/cloud/gcp/spring/TraceSampledMdcHandler.java:41

  • Closing any nested observation unconditionally removes the sampled flag belonging to its parent scope. For example, after an observed downstream call closes, subsequent logs in the sampled server observation no longer contain trace_sampled. Preserve and restore the prior MDC value per observation scope instead of always removing it.
    gcp/correlation-id-trace-spring-boot-gcp-web/README.md:4
  • Correct the OpenTelemetry product name.
    gcp/correlation-id-trace-spring-boot-gcp-grpc/README.md:4
  • Correct the OpenTelemetry product name.

Comment thread examples/gcp-web-otel-agent-example/build.gradle Outdated
skjolber and others added 2 commits August 24, 2026 12:35
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
@skjolber
skjolber merged commit c20033e into main Aug 24, 2026
10 checks passed
@skjolber
skjolber deleted the opentelemetry branch August 24, 2026 11:08
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.

6 participants