Skip to content

refactor: reuse main java/proto sources from base modules in *-otel-* examples - #458

Merged
skjolber merged 6 commits into
opentelemetryfrom
copilot/reuse-java-proto-sources
Aug 16, 2026
Merged

refactor: reuse main java/proto sources from base modules in *-otel-* examples#458
skjolber merged 6 commits into
opentelemetryfrom
copilot/reuse-java-proto-sources

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

The 6 new *-otel-* example modules introduced in PR #450 duplicated their src/main sources verbatim from gcp-grpc-spring-without-test-artifacts-example and gcp-web-without-test-artifacts-example. This replaces those copies with cross-project sourceSets imports.

gRPC otel modules (×4) — full import

All four modules had sources 100% identical to gcp-grpc-spring-without-test-artifacts-example. src/main/{java,proto,resources} deleted; imported via sourceSets:

// e.g. gcp-grpc-spring-otel-agent-example/build.gradle
sourceSets {
    main {
        java     { srcDirs '../gcp-grpc-spring-without-test-artifacts-example/src/main/java' }
        proto    { srcDirs '../gcp-grpc-spring-without-test-artifacts-example/src/main/proto' }
        resources { srcDirs '../gcp-grpc-spring-without-test-artifacts-example/src/main/resources' }
    }
    test.java.srcDirs += "${protobuf.generatedFilesBaseDir}/test/java"
    test.java.srcDirs += "${protobuf.generatedFilesBaseDir}/test/grpc"
}

Applies to: gcp-grpc-spring-otel-{agent,starter}-example and gcp-grpc-spring-without-test-artifacts-otel-{agent,starter}-example.

Web without-test-artifacts otel modules (×2) — java import

  • gcp-web-without-test-artifacts-otel-agent-example: imports main java + resources from base (identical after the fix below)
  • gcp-web-without-test-artifacts-otel-starter-example: imports main java; keeps its own application.properties (adds management.tracing.* properties required by the OTel Spring Boot starter)

Base web module alignment

gcp-web-without-test-artifacts-example/DocumentEndpoint.java updated to log the MDC context map — a line already present in all otel variants, useful regardless of OTel. Uses SLF4J parameterised logging ({}); same fix applied to the two remaining web otel DocumentEndpoint copies that are not yet deduplicated.

Not included

gcp-web-otel-{agent,starter}-example have extra classes (RestClientConfig, UserIdEnricherFilter, DummyEndpoint, etc.) and diverged versions of WebSecurityConfig/DocumentEndpoint vs the base — a clean import would require restructuring those source trees and is deferred.

Copilot AI and others added 3 commits August 15, 2026 23:42
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
…modules

All 4 gRPC otel modules (gcp-grpc-spring-otel-agent-example,
gcp-grpc-spring-otel-starter-example,
gcp-grpc-spring-without-test-artifacts-otel-agent-example,
gcp-grpc-spring-without-test-artifacts-otel-starter-example) now import
their main java/proto/resources from gcp-grpc-spring-without-test-artifacts-example
via sourceSets, removing duplicate sources.

Both web without-test-artifacts otel modules now import their main java
from gcp-web-without-test-artifacts-example. The otel-agent module also
imports resources (they are identical to base). The otel-starter module
keeps its own resources/application.properties (contains otel-specific
management.tracing properties).

gcp-web-without-test-artifacts-example DocumentEndpoint.java updated to
include MDC logging (logger.info with MDC.getCopyOfContextMap()) which
is present in all otel variants and is useful generally.

Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
@skjolber
skjolber changed the base branch from main to opentelemetry August 16, 2026 08:14
Copilot AI and others added 2 commits August 16, 2026 08:58
…e-java-proto-sources

# Conflicts:
#	examples/gcp-grpc-spring-otel-agent-example/build.gradle
#	examples/gcp-grpc-spring-otel-starter-example/build.gradle
#	examples/gcp-grpc-spring-without-test-artifacts-otel-agent-example/build.gradle
#	examples/gcp-grpc-spring-without-test-artifacts-otel-starter-example/build.gradle
#	examples/gcp-web-otel-agent-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java
#	examples/gcp-web-otel-starter-example/src/main/java/org/entur/example/web/rest/DocumentEndpoint.java
#	examples/gcp-web-without-test-artifacts-example/build.gradle
#	examples/gcp-web-without-test-artifacts-otel-agent-example/build.gradle
#	examples/gcp-web-without-test-artifacts-otel-starter-example/build.gradle

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

Co-authored-by: skjolber <1031478+skjolber@users.noreply.github.com>
@skjolber
skjolber marked this pull request as ready for review August 16, 2026 09:21
@skjolber
skjolber requested review from a team as code owners August 16, 2026 09:21
@skjolber
skjolber merged commit f1aaf2a into opentelemetry Aug 16, 2026
1 check passed
@skjolber
skjolber deleted the copilot/reuse-java-proto-sources branch August 16, 2026 09:21
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.

2 participants