Skip to content

Commit

Permalink
Remove peer service fallback to server.socket.* (#9369)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Sep 5, 2023
1 parent db7eb14 commit 9e12723
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.Map;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -60,7 +61,7 @@ public void onEnd(

String serverAddress = attributesGetter.getServerAddress(request);
String peerService = mapToPeerService(serverAddress);
if (peerService == null) {
if (peerService == null && SemconvStability.emitOldHttpSemconv()) {
String serverSocketDomain = attributesGetter.getServerSocketDomain(request, response);
peerService = mapToPeerService(serverSocketDomain);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.context.Context;
import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -101,6 +103,9 @@ void shouldSetPeerNameIfItMatches() {

@Test
void shouldSetSockPeerNameIfItMatchesAndNoPeerNameProvided() {

Assumptions.assumeTrue(SemconvStability.emitOldHttpSemconv());

// given
Map<String, String> peerServiceMapping = new HashMap<>();
peerServiceMapping.put("example.com", "myService");
Expand Down

0 comments on commit 9e12723

Please sign in to comment.