-
Notifications
You must be signed in to change notification settings - Fork 4k
interop: enable OpenTelemetry tracing support in Java interop client … #12910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AgraVator
wants to merge
21
commits into
grpc:master
Choose a base branch
from
AgraVator:otel-interop-test-suite
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cf6b688
interop: enable OpenTelemetry tracing support in Java interop client …
AgraVator 299e536
interop: add signal handling and try-with-resources cleanups
AgraVator b0f1369
interop: guarantee OpenTelemetrySdk teardown and fix span double ending
AgraVator 85eb6a9
interop: add @IgnoreJRERequirement for OpenTelemetry Java 8+ APIs to …
AgraVator 3659181
interop: add explanatory comment to @IgnoreJRERequirement for OpenTel…
AgraVator 7dbd4c3
interop: fix maybeCloseSpan in OpenTelemetryContextPropagationTest to…
AgraVator 625ce39
Upgrade to protobuf 3.25.9 / 25.6
AgraVator 696df7d
Revert "Upgrade to protobuf 3.25.9 / 25.6"
AgraVator f3a16f3
opentelemetry: stabilize tracing and remove GRPC_EXPERIMENTAL_ENABLE_…
AgraVator a07d5c3
test(interop): configure W3C tracecontext propagator in java interop …
AgraVator dae54f9
test(interop): support CLI flag aliases for otel collector address an…
AgraVator 643f323
test(interop): cleanup flags and remove unused imports
AgraVator 361daa2
revert(opentelemetry): revert production GrpcOpenTelemetry changes to…
AgraVator 90fadba
clean(interop): remove unrelated whitespace and try-with-resources di…
AgraVator 2dc3143
fix(checkstyle): fix import order in TestServiceClient and TestServic…
AgraVator ae2ee20
docs(interop): add comment explaining otel.bsp.schedule.delay configu…
AgraVator 61b8f4b
revert(test): revert OpenTelemetryContextPropagationTest to match ups…
AgraVator 89a93dd
fix(interop): add enable_opentelemetry and otel_collector_address par…
AgraVator 81643cd
Merge branch 'upstream/master' into otel-interop-test-suite
AgraVator 50d953a
refactor(interop): consolidate OpenTelemetry SDK setup in Util.setupO…
AgraVator 4e5c17b
fix(interop): move setupOpenTelemetry to OpenTelemetryUtil to avoid A…
AgraVator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
interop-testing/src/main/java/io/grpc/testing/integration/OpenTelemetryUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Copyright 2026 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.testing.integration; | ||
|
|
||
| import io.grpc.opentelemetry.GrpcOpenTelemetry; | ||
| import io.grpc.opentelemetry.InternalGrpcOpenTelemetry; | ||
| import io.opentelemetry.sdk.OpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk; | ||
| import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdkBuilder; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement; | ||
|
|
||
| /** | ||
| * Utility methods for OpenTelemetry configuration in integration testing. | ||
| */ | ||
| public final class OpenTelemetryUtil { | ||
|
|
||
| private OpenTelemetryUtil() {} | ||
|
|
||
| /** | ||
| * Initializes and registers OpenTelemetry tracing for interop client and server. | ||
| * | ||
| * @param otelCollectorAddress optional collector address (e.g. "localhost:4317") | ||
| * @return the configured {@link OpenTelemetrySdk} | ||
| */ | ||
| @IgnoreJRERequirement // OpenTelemetry uses Java 8+ APIs | ||
| public static OpenTelemetrySdk setupOpenTelemetry(String otelCollectorAddress) { | ||
| AutoConfiguredOpenTelemetrySdkBuilder sdkBuilder = | ||
| AutoConfiguredOpenTelemetrySdk.builder(); | ||
| Map<String, String> properties = new HashMap<>(); | ||
| properties.put("otel.traces.exporter", "otlp"); | ||
| // Reduce BatchSpanProcessor export delay from default 5000ms to 100ms for fast test runs. | ||
| properties.put("otel.bsp.schedule.delay", "100"); | ||
| if (otelCollectorAddress != null && !otelCollectorAddress.isEmpty()) { | ||
| String endpoint = otelCollectorAddress; | ||
| if (!endpoint.startsWith("http://") && !endpoint.startsWith("https://")) { | ||
| endpoint = "http://" + endpoint; | ||
| } | ||
| properties.put("otel.exporter.otlp.endpoint", endpoint); | ||
| } | ||
| sdkBuilder.addPropertiesSupplier(() -> properties); | ||
| AutoConfiguredOpenTelemetrySdk autoSdk = sdkBuilder.build(); | ||
| OpenTelemetrySdk openTelemetrySdk = autoSdk.getOpenTelemetrySdk(); | ||
| GrpcOpenTelemetry.Builder grpcOpentelemetryBuilder = GrpcOpenTelemetry.newBuilder() | ||
| .sdk(openTelemetrySdk); | ||
| InternalGrpcOpenTelemetry.enableTracing(grpcOpentelemetryBuilder, true); | ||
| GrpcOpenTelemetry grpcOpenTelemetry = grpcOpentelemetryBuilder.build(); | ||
| grpcOpenTelemetry.registerGlobal(); | ||
| return openTelemetrySdk; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.