|
5 | 5 |
|
6 | 6 | package io.opentelemetry.instrumentation.r2dbc.v1_0; |
7 | 7 |
|
| 8 | +import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor; |
| 9 | +import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceResolver; |
| 10 | +import io.opentelemetry.instrumentation.r2dbc.v1_0.internal.R2dbcNetAttributesGetter; |
8 | 11 | import io.opentelemetry.instrumentation.reactor.v3_1.ContextPropagationOperator; |
9 | 12 | import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; |
10 | 13 | import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; |
@@ -39,7 +42,18 @@ void stop() { |
39 | 42 | @Override |
40 | 43 | protected ConnectionFactory createProxyConnectionFactory( |
41 | 44 | ConnectionFactoryOptions connectionFactoryOptions) { |
42 | | - return R2dbcTelemetry.create(testing.getOpenTelemetry()) |
| 45 | + // Create peer service mapping for testing |
| 46 | + java.util.Map<String, String> peerServiceMapping = new java.util.HashMap<>(); |
| 47 | + peerServiceMapping.put("127.0.0.1", "test-peer-service"); |
| 48 | + peerServiceMapping.put("localhost", "test-peer-service"); |
| 49 | + peerServiceMapping.put("192.0.2.1", "test-peer-service"); |
| 50 | + |
| 51 | + return R2dbcTelemetry.builder(testing.getOpenTelemetry()) |
| 52 | + .addAttributesExtractor( |
| 53 | + PeerServiceAttributesExtractor.create( |
| 54 | + R2dbcNetAttributesGetter.INSTANCE, |
| 55 | + PeerServiceResolver.create(peerServiceMapping))) |
| 56 | + .build() |
43 | 57 | .wrapConnectionFactory( |
44 | 58 | super.createProxyConnectionFactory(connectionFactoryOptions), connectionFactoryOptions); |
45 | 59 | } |
|
0 commit comments