Skip to content

Commit d4435c9

Browse files
traskheyams
andauthored
Use direct peer address in client.address when X-Forwarded-For is not present (#10370)
Co-authored-by: heyams <[email protected]>
1 parent 5b1ef39 commit d4435c9

File tree

13 files changed

+49
-6
lines changed

13 files changed

+49
-6
lines changed
+9-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import io.opentelemetry.instrumentation.api.semconv.network.internal.AddressAndPortExtractor;
1111
import java.util.Locale;
1212

13-
final class ForwardedForAddressAndPortExtractor<REQUEST>
14-
implements AddressAndPortExtractor<REQUEST> {
13+
final class HttpServerAddressAndPortExtractor<REQUEST> implements AddressAndPortExtractor<REQUEST> {
1514

1615
private final HttpServerAttributesGetter<REQUEST, ?> getter;
1716

18-
ForwardedForAddressAndPortExtractor(HttpServerAttributesGetter<REQUEST, ?> getter) {
17+
HttpServerAddressAndPortExtractor(HttpServerAttributesGetter<REQUEST, ?> getter) {
1918
this.getter = getter;
2019
}
2120

@@ -34,6 +33,13 @@ public void extract(AddressPortSink sink, REQUEST request) {
3433
return;
3534
}
3635
}
36+
37+
// use network.peer.address and network.peer.port
38+
sink.setAddress(getter.getNetworkPeerAddress(request, null));
39+
Integer port = getter.getNetworkPeerPort(request, null);
40+
if (port != null && port > 0) {
41+
sink.setPort(port);
42+
}
3743
}
3844

3945
private static boolean extractFromForwardedHeader(AddressPortSink sink, String forwarded) {

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public final class HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> {
4646

4747
clientAddressPortExtractor =
4848
new ClientAddressAndPortExtractor<>(
49-
httpAttributesGetter, new ForwardedForAddressAndPortExtractor<>(httpAttributesGetter));
49+
httpAttributesGetter, new HttpServerAddressAndPortExtractor<>(httpAttributesGetter));
5050
serverAddressPortExtractor = new ForwardedHostAddressAndPortExtractor<>(httpAttributesGetter);
5151
}
5252

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
import org.mockito.junit.jupiter.MockitoExtension;
2828

2929
@ExtendWith(MockitoExtension.class)
30-
class ForwardedForAddressAndPortExtractorTest {
30+
class HttpServerAddressAndPortExtractorTest {
3131

3232
@Mock HttpServerAttributesGetter<String, String> getter;
3333

34-
@InjectMocks ForwardedForAddressAndPortExtractor<String> underTest;
34+
@InjectMocks HttpServerAddressAndPortExtractor<String> underTest;
3535

3636
@ParameterizedTest
3737
@ArgumentsSource(ForwardedArgs.class)

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void restComponentServerAndClientCallWithJettyBackend() {
106106
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
107107
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
108108
equalTo(SemanticAttributes.SERVER_PORT, Long.valueOf(port)),
109+
equalTo(SemanticAttributes.CLIENT_ADDRESS, "127.0.0.1"),
109110
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"),
110111
satisfies(
111112
SemanticAttributes.USER_AGENT_ORIGINAL,

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ void twoCamelServiceSpans() throws Exception {
157157
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
158158
equalTo(SemanticAttributes.SERVER_ADDRESS, "127.0.0.1"),
159159
equalTo(SemanticAttributes.SERVER_PORT, portTwo),
160+
equalTo(SemanticAttributes.CLIENT_ADDRESS, "127.0.0.1"),
160161
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"),
161162
satisfies(
162163
NetworkAttributes.NETWORK_PEER_PORT,

instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationBasicTests.groovy

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
9999
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
100100
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
101101
"$SemanticAttributes.SERVER_PORT" port
102+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
102103
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
103104
"$NetworkAttributes.NETWORK_PEER_PORT" Long
104105
}
@@ -156,6 +157,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
156157
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
157158
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
158159
"$SemanticAttributes.SERVER_PORT" port
160+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
159161
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
160162
"$NetworkAttributes.NETWORK_PEER_PORT" Long
161163
}
@@ -208,7 +210,9 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
208210
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
209211
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
210212
"$SemanticAttributes.SERVER_PORT" port
213+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
211214
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
215+
212216
"$NetworkAttributes.NETWORK_PEER_PORT" Long
213217
}
214218
}
@@ -269,6 +273,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
269273
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
270274
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
271275
"$SemanticAttributes.SERVER_PORT" port
276+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
272277
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
273278
"$NetworkAttributes.NETWORK_PEER_PORT" Long
274279
"$SemanticAttributes.ERROR_TYPE" "500"
@@ -336,6 +341,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
336341
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
337342
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
338343
"$SemanticAttributes.SERVER_PORT" port
344+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
339345
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
340346
"$NetworkAttributes.NETWORK_PEER_PORT" Long
341347
}
@@ -383,6 +389,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
383389
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
384390
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
385391
"$SemanticAttributes.SERVER_PORT" port
392+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
386393
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
387394
"$NetworkAttributes.NETWORK_PEER_PORT" Long
388395
}
@@ -462,6 +469,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
462469
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
463470
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
464471
"$SemanticAttributes.SERVER_PORT" port
472+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
465473
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
466474
"$NetworkAttributes.NETWORK_PEER_PORT" Long
467475
"$SemanticAttributes.ERROR_TYPE" "500"
@@ -511,6 +519,7 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification {
511519
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
512520
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
513521
"$SemanticAttributes.SERVER_PORT" port
522+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
514523
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
515524
"$NetworkAttributes.NETWORK_PEER_PORT" Long
516525
}

instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationForwardTests.groovy

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
9797
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
9898
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
9999
"$SemanticAttributes.SERVER_PORT" port
100+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
100101
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
101102
"$NetworkAttributes.NETWORK_PEER_PORT" Long
102103
}
@@ -165,6 +166,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
165166
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
166167
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
167168
"$SemanticAttributes.SERVER_PORT" port
169+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
168170
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
169171
"$NetworkAttributes.NETWORK_PEER_PORT" Long
170172
}
@@ -212,6 +214,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
212214
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
213215
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
214216
"$SemanticAttributes.SERVER_PORT" port
217+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
215218
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
216219
"$NetworkAttributes.NETWORK_PEER_PORT" Long
217220
}
@@ -307,6 +310,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
307310
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
308311
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
309312
"$SemanticAttributes.SERVER_PORT" port
313+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
310314
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
311315
"$NetworkAttributes.NETWORK_PEER_PORT" Long
312316
}
@@ -388,6 +392,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
388392
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
389393
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
390394
"$SemanticAttributes.SERVER_PORT" port
395+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
391396
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
392397
"$NetworkAttributes.NETWORK_PEER_PORT" Long
393398
"$SemanticAttributes.ERROR_TYPE" "500"
@@ -449,6 +454,7 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification {
449454
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
450455
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
451456
"$SemanticAttributes.SERVER_PORT" port
457+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
452458
"$NetworkAttributes.NETWORK_PEER_ADDRESS" "127.0.0.1"
453459
"$NetworkAttributes.NETWORK_PEER_PORT" Long
454460
}

instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification {
9898
"$SemanticAttributes.NETWORK_PROTOCOL_VERSION" "1.1"
9999
"$SemanticAttributes.SERVER_ADDRESS" { it == "localhost" || it == null }
100100
"$SemanticAttributes.SERVER_PORT" { it == app.bindPort || it == null }
101+
"$SemanticAttributes.CLIENT_ADDRESS" { it == "127.0.0.1" || it == null }
101102
"$NetworkAttributes.NETWORK_PEER_ADDRESS" { it == "127.0.0.1" || it == null }
102103
"$NetworkAttributes.NETWORK_PEER_PORT" { it instanceof Long || it == null }
103104
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"

instrumentation/spark-2.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/sparkjava/SparkJavaBasedTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void generatesSpans() {
7171
equalTo(SemanticAttributes.NETWORK_PROTOCOL_VERSION, "1.1"),
7272
equalTo(SemanticAttributes.SERVER_ADDRESS, "localhost"),
7373
equalTo(SemanticAttributes.SERVER_PORT, port),
74+
equalTo(SemanticAttributes.CLIENT_ADDRESS, "127.0.0.1"),
7475
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"),
7576
satisfies(
7677
NetworkAttributes.NETWORK_PEER_PORT,

instrumentation/spring/spring-webflux/spring-webflux-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/v5_0/server/SpringWebfluxTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
1010
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
1111
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
12+
import static io.opentelemetry.semconv.SemanticAttributes.CLIENT_ADDRESS;
1213
import static io.opentelemetry.semconv.SemanticAttributes.ERROR_TYPE;
1314
import static io.opentelemetry.semconv.SemanticAttributes.EXCEPTION_EVENT_NAME;
1415
import static io.opentelemetry.semconv.SemanticAttributes.EXCEPTION_MESSAGE;
@@ -119,6 +120,7 @@ void basicGetTest(Parameter parameter) {
119120
val -> val.isInstanceOf(Long.class)),
120121
equalTo(SERVER_ADDRESS, "localhost"),
121122
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
123+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
122124
equalTo(URL_PATH, parameter.urlPath),
123125
equalTo(HTTP_REQUEST_METHOD, "GET"),
124126
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
@@ -239,6 +241,7 @@ void getAsyncResponseTest(Parameter parameter) {
239241
val -> val.isInstanceOf(Long.class)),
240242
equalTo(SERVER_ADDRESS, "localhost"),
241243
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
244+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
242245
equalTo(URL_PATH, parameter.urlPath),
243246
equalTo(HTTP_REQUEST_METHOD, "GET"),
244247
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
@@ -346,6 +349,7 @@ void createSpanDuringHandlerFunctionTest(Parameter parameter) {
346349
val -> val.isInstanceOf(Long.class)),
347350
equalTo(SERVER_ADDRESS, "localhost"),
348351
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
352+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
349353
equalTo(URL_PATH, parameter.urlPath),
350354
equalTo(HTTP_REQUEST_METHOD, "GET"),
351355
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
@@ -418,6 +422,7 @@ void get404Test() {
418422
val -> val.isInstanceOf(Long.class)),
419423
equalTo(SERVER_ADDRESS, "localhost"),
420424
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
425+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
421426
equalTo(URL_PATH, "/notfoundgreet"),
422427
equalTo(HTTP_REQUEST_METHOD, "GET"),
423428
equalTo(HTTP_RESPONSE_STATUS_CODE, 404),
@@ -478,6 +483,7 @@ void basicPostTest() {
478483
val -> val.isInstanceOf(Long.class)),
479484
equalTo(SERVER_ADDRESS, "localhost"),
480485
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
486+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
481487
equalTo(URL_PATH, "/echo"),
482488
equalTo(HTTP_REQUEST_METHOD, "POST"),
483489
equalTo(HTTP_RESPONSE_STATUS_CODE, 202),
@@ -518,6 +524,7 @@ void getToBadEndpointTest(Parameter parameter) {
518524
val -> val.isInstanceOf(Long.class)),
519525
equalTo(SERVER_ADDRESS, "localhost"),
520526
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
527+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
521528
equalTo(URL_PATH, parameter.urlPath),
522529
equalTo(HTTP_REQUEST_METHOD, "GET"),
523530
equalTo(HTTP_RESPONSE_STATUS_CODE, 500),
@@ -598,6 +605,7 @@ void redirectTest() {
598605
val -> val.isInstanceOf(Long.class)),
599606
equalTo(SERVER_ADDRESS, "localhost"),
600607
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
608+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
601609
equalTo(URL_PATH, "/double-greet-redirect"),
602610
equalTo(HTTP_REQUEST_METHOD, "GET"),
603611
equalTo(HTTP_RESPONSE_STATUS_CODE, 307),
@@ -626,6 +634,7 @@ void redirectTest() {
626634
val -> val.isInstanceOf(Long.class)),
627635
equalTo(SERVER_ADDRESS, "localhost"),
628636
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
637+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
629638
equalTo(URL_PATH, "/double-greet"),
630639
equalTo(HTTP_REQUEST_METHOD, "GET"),
631640
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
@@ -677,6 +686,7 @@ void multipleGetsToDelayingRoute(Parameter parameter) {
677686
val -> val.isInstanceOf(Long.class)),
678687
equalTo(SERVER_ADDRESS, "localhost"),
679688
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
689+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
680690
equalTo(URL_PATH, parameter.urlPath),
681691
equalTo(HTTP_REQUEST_METHOD, "GET"),
682692
equalTo(HTTP_RESPONSE_STATUS_CODE, 200),
@@ -758,6 +768,7 @@ void cancelRequestTest() throws Exception {
758768
val -> val.isInstanceOf(Long.class)),
759769
equalTo(SERVER_ADDRESS, "localhost"),
760770
satisfies(SERVER_PORT, val -> val.isInstanceOf(Long.class)),
771+
equalTo(CLIENT_ADDRESS, "127.0.0.1"),
761772
equalTo(URL_PATH, "/slow"),
762773
equalTo(HTTP_REQUEST_METHOD, "GET"),
763774
equalTo(URL_SCHEME, "http"),

instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
6868
"$NetworkAttributes.NETWORK_PEER_PORT" Long
6969
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
7070
"$SemanticAttributes.SERVER_PORT" Long
71+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
7172
"$SemanticAttributes.URL_PATH" "/listProducts"
7273
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
7374
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
@@ -158,6 +159,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
158159
"$NetworkAttributes.NETWORK_PEER_PORT" Long
159160
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
160161
"$SemanticAttributes.SERVER_PORT" Long
162+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
161163
"$SemanticAttributes.URL_PATH" baseUrl
162164
"$SemanticAttributes.URL_QUERY" "$TEST_REQUEST_ID_PARAMETER=$requestId"
163165
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"

instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
6868
"$NetworkAttributes.NETWORK_PEER_PORT" Long
6969
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
7070
"$SemanticAttributes.SERVER_PORT" Long
71+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
7172
"$SemanticAttributes.URL_PATH" "/listProducts"
7273
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"
7374
"$SemanticAttributes.HTTP_RESPONSE_STATUS_CODE" 200
@@ -158,6 +159,7 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification {
158159
"$NetworkAttributes.NETWORK_PEER_PORT" Long
159160
"$SemanticAttributes.SERVER_ADDRESS" "localhost"
160161
"$SemanticAttributes.SERVER_PORT" Long
162+
"$SemanticAttributes.CLIENT_ADDRESS" "127.0.0.1"
161163
"$SemanticAttributes.URL_PATH" baseUrl
162164
"$SemanticAttributes.URL_QUERY" "$TEST_REQUEST_ID_PARAMETER=$requestId"
163165
"$SemanticAttributes.HTTP_REQUEST_METHOD" "GET"

smoke-tests/src/test/groovy/io/opentelemetry/smoketest/AppServerTest.groovy

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ abstract class AppServerTest extends SmokeTest {
123123
and: "Server span for the remote call"
124124
traces.countFilteredAttributes(SemanticAttributes.URL_PATH.key, "/app/headers") == 1
125125

126+
and: "Number of spans with client address"
127+
traces.countFilteredAttributes(SemanticAttributes.CLIENT_ADDRESS.key, "127.0.0.1") == 1
128+
126129
and: "Number of spans with http protocol version"
127130
traces.countFilteredAttributes(SemanticAttributes.NETWORK_PROTOCOL_VERSION.key, "1.1") == 3
128131

0 commit comments

Comments
 (0)