-
Couldn't load subscription status.
- Fork 1k
Peer service testing #14963
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
Merged
Merged
Peer service testing #14963
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4c7c9e2
Test peer.service in all HTTP client instrumentations
trask ebac09b
centralize
trask 289a151
jedis
trask a4d0c2e
lettuce
trask bb0eca4
vertx-sql-client
trask e8fb30e
r2dbc
trask 98b546e
dubbo
trask 5068473
jdbc
trask 00bc62e
./gradlew spotlessApply
otelbot[bot] 7a32b2b
more
trask a135dc5
Remove peer.service assertions from library-autoconfigure Dubbo tests
trask 14ca030
Add PEER_SERVICE to Apache Dubbo library-autoconfigure test expectations
trask 64f5500
Apply review suggestions
trask 6ff80b8
Address PR review comments
trask 5928bfc
Revert play-ws-2.1 test configuration to use test{} instead of withTy…
trask bd99620
Add peer.service to test expectations for hibernate-reactive and spri…
trask 85c7a9e
Merge branch 'main' into peer-service-testing
laurit 65fcfcb
update
trask fa61ec6
review
trask 5fd9fb4
spotless
trask edba3b4
Merge remote-tracking branch 'upstream/main' into peer-service-testing
trask ac8ec92
revert windows fix since working on that elsewhere
trask 7f76372
import
trask 7371826
./gradlew spotlessApply
otelbot[bot] 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
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
36 changes: 0 additions & 36 deletions
36
...n/java/io/opentelemetry/instrumentation/api/semconv/http/HostAddressAndPortExtractor.java
This file was deleted.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
.../opentelemetry/instrumentation/api/semconv/http/internal/HostAddressAndPortExtractor.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,59 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.api.semconv.http.internal; | ||
|
|
||
| import io.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesGetter; | ||
| import io.opentelemetry.instrumentation.api.semconv.network.internal.AddressAndPortExtractor; | ||
| import java.util.List; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Extracts server address and port from the HTTP Host header. | ||
| * | ||
| * <p>This class is internal and is hence not for public use. Its APIs are unstable and can change | ||
| * at any time. | ||
| */ | ||
| public final class HostAddressAndPortExtractor<REQUEST> | ||
| implements AddressAndPortExtractor<REQUEST> { | ||
|
|
||
| private final HttpCommonAttributesGetter<REQUEST, ?> getter; | ||
|
|
||
| public HostAddressAndPortExtractor(HttpCommonAttributesGetter<REQUEST, ?> getter) { | ||
| this.getter = getter; | ||
| } | ||
|
|
||
| @Override | ||
| public void extract(AddressPortSink sink, REQUEST request) { | ||
| String host = firstHeaderValue(getter.getHttpRequestHeader(request, "host")); | ||
| if (host == null) { | ||
| return; | ||
| } | ||
|
|
||
| int hostHeaderSeparator = host.indexOf(':'); | ||
| if (hostHeaderSeparator == -1) { | ||
| sink.setAddress(host); | ||
| } else { | ||
| sink.setAddress(host.substring(0, hostHeaderSeparator)); | ||
| setPort(sink, host, hostHeaderSeparator + 1, host.length()); | ||
| } | ||
| } | ||
|
|
||
| @Nullable | ||
| private static String firstHeaderValue(List<String> values) { | ||
| return values.isEmpty() ? null : values.get(0); | ||
| } | ||
|
|
||
| private static void setPort(AddressPortSink sink, String header, int start, int end) { | ||
| if (start == end) { | ||
| return; | ||
| } | ||
| try { | ||
| sink.setPort(Integer.parseInt(header.substring(start, end))); | ||
| } catch (NumberFormatException ignored) { | ||
| // malformed port, ignoring | ||
| } | ||
| } | ||
| } | ||
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
48 changes: 48 additions & 0 deletions
48
...java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TestOpenTelemetryClientFilter.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,48 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.apachedubbo.v2_7; | ||
|
|
||
| import io.opentelemetry.api.GlobalOpenTelemetry; | ||
| import io.opentelemetry.instrumentation.apachedubbo.v2_7.internal.DubboClientNetworkAttributesGetter; | ||
| import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor; | ||
| import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.apache.dubbo.common.extension.Activate; | ||
| import org.apache.dubbo.rpc.Filter; | ||
| import org.apache.dubbo.rpc.Invocation; | ||
| import org.apache.dubbo.rpc.Invoker; | ||
| import org.apache.dubbo.rpc.Result; | ||
|
|
||
| @Activate( | ||
| group = {"consumer"}, | ||
| order = -1) | ||
| public final class TestOpenTelemetryClientFilter implements Filter { | ||
|
|
||
| private final Filter delegate; | ||
|
|
||
| public TestOpenTelemetryClientFilter() { | ||
| // Create peer service mapping for testing | ||
| Map<String, String> peerServiceMapping = new HashMap<>(); | ||
| peerServiceMapping.put("127.0.0.1", "test-peer-service"); | ||
| peerServiceMapping.put("localhost", "test-peer-service"); | ||
| peerServiceMapping.put("192.0.2.1", "test-peer-service"); | ||
|
|
||
| delegate = | ||
| DubboTelemetry.builder(GlobalOpenTelemetry.get()) | ||
| .addAttributesExtractor( | ||
| PeerServiceAttributesExtractor.create( | ||
| new DubboClientNetworkAttributesGetter(), | ||
| PeerServiceResolver.create(peerServiceMapping))) | ||
| .build() | ||
| .newClientFilter(); | ||
| } | ||
|
|
||
| @Override | ||
| public Result invoke(Invoker<?> invoker, Invocation invocation) { | ||
| return delegate.invoke(invoker, invocation); | ||
| } | ||
| } |
31 changes: 31 additions & 0 deletions
31
...java/io/opentelemetry/instrumentation/apachedubbo/v2_7/TestOpenTelemetryServerFilter.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,31 @@ | ||
| /* | ||
| * Copyright The OpenTelemetry Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package io.opentelemetry.instrumentation.apachedubbo.v2_7; | ||
|
|
||
| import io.opentelemetry.api.GlobalOpenTelemetry; | ||
| import org.apache.dubbo.common.extension.Activate; | ||
| import org.apache.dubbo.rpc.Filter; | ||
| import org.apache.dubbo.rpc.Invocation; | ||
| import org.apache.dubbo.rpc.Invoker; | ||
| import org.apache.dubbo.rpc.Result; | ||
|
|
||
| @Activate( | ||
| group = {"provider"}, | ||
| order = -1) | ||
| public final class TestOpenTelemetryServerFilter implements Filter { | ||
|
|
||
| private final Filter delegate; | ||
|
|
||
| public TestOpenTelemetryServerFilter() { | ||
| // Server filter doesn't need peer service configuration | ||
| delegate = DubboTelemetry.create(GlobalOpenTelemetry.get()).newServerFilter(); | ||
| } | ||
|
|
||
| @Override | ||
| public Result invoke(Invoker<?> invoker, Invocation invocation) { | ||
| return delegate.invoke(invoker, invocation); | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
....7/library-autoconfigure/src/test/resources/META-INF/services/org.apache.dubbo.rpc.Filter
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,2 @@ | ||
| io.opentelemetry.instrumentation.apachedubbo.v2_7.TestOpenTelemetryClientFilter | ||
| io.opentelemetry.instrumentation.apachedubbo.v2_7.TestOpenTelemetryServerFilter |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could the host header contain an ipv6 address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is existing code just moved to
.internalpackage, mind if I open an issue for this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#15158