Reuse NoOpenTelemetryAgentCondition - #460
Conversation
There was a problem hiding this comment.
Pull request overview
This PR centralizes the “no OpenTelemetry Java agent present” Spring Condition so it can be reused across multiple GCP Spring Boot auto-configurations, replacing duplicate/local implementations.
Changes:
- Moved
NoOpenTelemetryAgentConditionintono.entur.logging.cloud.gcp.springand reused it from multiple auto-configs. - Removed the nested condition from
GcpMicrometerTraceAutoConfigurationand updated GCP web/grpc trace auto-configurations to reference the shared condition. - Adjusted module dependencies to enable cross-module reuse.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| gcp/spring-boot-autoconfigure-gcp/src/main/java/no/entur/logging/cloud/gcp/spring/NoOpenTelemetryAgentCondition.java | Relocates the shared condition into the GCP autoconfigure module/package. |
| gcp/spring-boot-autoconfigure-gcp/src/main/java/no/entur/logging/cloud/gcp/spring/GcpMicrometerTraceAutoConfiguration.java | Switches from an inner condition class to the shared NoOpenTelemetryAgentCondition. |
| gcp/spring-boot-autoconfigure-gcp/build.gradle | Removes an unused dependency from the autoconfigure module. |
| gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/NoOpenTelemetryAgentCondition.java | Removes the previously-local condition implementation (now shared elsewhere). |
| gcp/correlation-id-trace-spring-boot-gcp-web/src/main/java/no/entur/logging/cloud/gcp/trace/spring/web/GcpTraceAutoConfiguration.java | Updates to import and use the shared condition class. |
| gcp/correlation-id-trace-spring-boot-gcp-web/build.gradle | Adds a dependency to access the shared condition. |
| gcp/correlation-id-trace-spring-boot-gcp-grpc/src/main/java/no/entur/logging/cloud/gcp/trace/spring/grpc/GcpGrpcTraceAutoConfiguration.java | Updates to import and use the shared condition class. |
| gcp/correlation-id-trace-spring-boot-gcp-grpc/build.gradle | Adds a dependency to access the shared condition. |
Suppressed comments (1)
gcp/spring-boot-autoconfigure-gcp/src/main/java/no/entur/logging/cloud/gcp/spring/NoOpenTelemetryAgentCondition.java:5
- This class appears to have been moved/renamed at the package level (from a previously published package) and is public. That is a binary-breaking change for any external consumers that referenced the old FQCN.
If backward compatibility is required, consider keeping a deprecated type at the old FQCN that delegates to this condition for one major version (or document the breaking change explicitly).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| api project(':trace:server:correlation-id-trace-spring-boot-web') | ||
| api project(':gcp:logback-logstash-encoder-gcp') | ||
| api project(':gcp:spring-boot-autoconfigure-gcp') | ||
|
|
| api project(':trace:server:correlation-id-trace-spring-boot-grpc') | ||
| api project(':gcp:logback-logstash-encoder-gcp') | ||
| api project(':gcp:spring-boot-autoconfigure-gcp') | ||
|
|
||
| api("org.springframework.boot:spring-boot-autoconfigure") |
| import jakarta.servlet.DispatcherType; | ||
| import no.entur.logging.cloud.gcp.spring.NoOpenTelemetryAgentCondition; | ||
| import no.entur.logging.cloud.trace.spring.web.CorrelationIdAutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; |
Allow apps to use this as well