Skip to content

Conversation

@trask
Copy link
Member

@trask trask commented Oct 12, 2025

Resolves #10361

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

1 similar comment
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the peer-service-testing branch from 4d2a8de to 1d59409 Compare October 12, 2025 21:37
tasks {
test {
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
systemProperty("otel.instrumentation.common.peer-service-mapping", "127.0.0.1=test-peer-service,localhost=test-peer-service,192.0.2.1=test-peer-service")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be simplified by #13434

@trask trask force-pushed the peer-service-testing branch 5 times, most recently from 387f86e to 3378a01 Compare October 17, 2025 18:31
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

1 similar comment
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

.hasParent(trace.getSpan(0))
.hasStatus(StatusData.error())
.hasAttributesSatisfyingExactly(
.hasAttributesSatisfying(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relaxing here was needed because this is shared by both Java agent tests and library tests

and I decided to only test peer.service in Java agent tests (though we could revisit that decision)

Copy link
Contributor

@laurit laurit Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add hasPeerService to the super class or expose it through options. That method could return true only when running with the agent. To detect the presence of the agent we could Class.forName something or even check for otel.javaagent.debug that we know is only set for the agent. Instead of hasPeerService might also consider getExpectedPeerServiceName that would return null when running without the agent, that could allow simpler asserts as null is the same as missing attribute.

.hasKind(CLIENT)
.hasParent(trace.getSpan(0))
.hasAttributesSatisfyingExactly(
.hasAttributesSatisfying(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same reason here

Comment on lines +1156 to +1170
})
.satisfies(
spanData -> {
// Check for peer.service when running with javaagent instrumentation
String distroName =
spanData
.getResource()
.getAttribute(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME);
if ("opentelemetry-java-instrumentation".equals(distroName)) {
String expectedPeerService = options.getExpectedPeerServiceName().apply(uri);
if (expectedPeerService != null) {
assertThat(spanData.getAttributes())
.containsEntry(PeerIncubatingAttributes.PEER_SERVICE, expectedPeerService);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to deal with configuring all of the library http client telemetry builders, but now that the javaagent ones are working, I don't mind revisiting

(in general I don't think peer.service infra is as important for library instrumentation because it's generally easy to add a peer.service constant identifier when you add instrumentation around a particular service call in that case)

Comment on lines +205 to +208
Builder setTestPeerService(boolean value);

Builder setExpectedPeerServiceName(Function<URI, String> value);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really used with current hacky implementation, but maybe they should be

@trask trask marked this pull request as ready for review October 18, 2025 04:23
@trask trask requested a review from a team as a code owner October 18, 2025 04:23
tasks {
test {
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
systemProperty("otel.instrumentation.common.peer-service-mapping", "127.0.0.1=test-peer-service,localhost=test-peer-service,192.0.2.1=test-peer-service")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or in

"-Dotel.java.experimental.span-attributes.copy-from-baggage.include=test-baggage-key-1,test-baggage-key-2"

@trask trask force-pushed the peer-service-testing branch from c37ef46 to 5068473 Compare October 22, 2025 22:49
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask force-pushed the peer-service-testing branch 3 times, most recently from 7a23016 to 8c33824 Compare October 23, 2025 03:12
@trask trask marked this pull request as draft October 23, 2025 03:20
@trask trask force-pushed the peer-service-testing branch from 8c33824 to 7a717eb Compare October 23, 2025 04:02
@trask trask force-pushed the peer-service-testing branch from 7a717eb to 7a32b2b Compare October 23, 2025 17:02
Library instrumentation doesn't support peer-service-mapping configuration
(javaagent-only feature). Removed peer.service expectations from shared test
base class AbstractDubboTraceChainTest.java to fix failures with Dubbo 3.3.5.
trask added 2 commits October 23, 2025 11:40
CLIENT spans now include peer.service attribute when peer-service-mapping is configured.
- Remove empty test configuration blocks from build.gradle.kts files
- Don't reorder attributes in test assertions - add PEER_SERVICE at end instead
- Allow both error message formats in Lettuce tests (with and without 'getsockopt:')
@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Oct 23, 2025
Comment on lines +134 to +147
val ->
val.isIn(
"Connection refused: "
+ host
+ "/"
+ ip
+ ":"
+ incorrectPort,
"Connection refused: getsockopt: "
+ host
+ "/"
+ ip
+ ":"
+ incorrectPort)),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is just due to me running on Windows and getting a different message

trask and others added 5 commits October 23, 2025 14:57
- Remove empty test configuration blocks from build.gradle.kts files
- Delete temporary 'peer' file
- Fix attribute ordering in tests: keep original order and add peer.service at end
  - Lettuce 4.0 LettuceAsyncClientTest
  - Netty 4.1 ConnectionSpanTest and ClientSslTest
  - ReactorNetty 0.9 and 1.0 ConnectionSpanTest
…ng-data

- Update AbstractHibernateReactiveTest to expect peer.service attribute
- Update ReactiveSpringDataTest to expect peer.service attribute
- Add stringKey import to both test files
@trask trask marked this pull request as ready for review October 24, 2025 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test native This label can be applied to PRs to trigger them to run native tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing peer.service in nettyhttpclient service

2 participants