PeerService Resolver (#9061)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com> Co-authored-by: jason plumb <75337021+breedx-splk@users.noreply.github.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com> Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
This commit is contained in:
parent
0511f5f7c3
commit
9a1c178d58
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.http;
|
||||
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.url.UrlParser;
|
||||
import io.opentelemetry.semconv.SemanticAttributes;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Extractor of the {@code peer.service} span attribute, described in <a
|
||||
* href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/span-general.md#general-remote-service-attributes">the
|
||||
* specification</a>.
|
||||
*/
|
||||
public final class HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
||||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||
|
||||
private final HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter;
|
||||
private final PeerServiceResolver peerServiceResolver;
|
||||
|
||||
// visible for tests
|
||||
HttpClientPeerServiceAttributesExtractor(
|
||||
HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
||||
PeerServiceResolver peerServiceResolver) {
|
||||
this.attributesGetter = attributesGetter;
|
||||
this.peerServiceResolver = peerServiceResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link HttpClientPeerServiceAttributesExtractor} that will use the passed {@code
|
||||
* attributesGetter} instance to determine the value of the {@code peer.service} attribute.
|
||||
*/
|
||||
public static <REQUEST, RESPONSE>
|
||||
HttpClientPeerServiceAttributesExtractor<REQUEST, RESPONSE> create(
|
||||
HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
||||
PeerServiceResolver peerServiceResolver) {
|
||||
return new HttpClientPeerServiceAttributesExtractor<>(attributesGetter, peerServiceResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {}
|
||||
|
||||
@Override
|
||||
public void onEnd(
|
||||
AttributesBuilder attributes,
|
||||
Context context,
|
||||
REQUEST request,
|
||||
@Nullable RESPONSE response,
|
||||
@Nullable Throwable error) {
|
||||
|
||||
if (peerServiceResolver.isEmpty()) {
|
||||
// optimization for common case
|
||||
return;
|
||||
}
|
||||
|
||||
String serverAddress = attributesGetter.getServerAddress(request);
|
||||
Integer serverPort = attributesGetter.getServerPort(request);
|
||||
Supplier<String> pathSupplier = () -> getUrlPath(attributesGetter, request);
|
||||
String peerService = mapToPeerService(serverAddress, serverPort, pathSupplier);
|
||||
if (peerService == null) {
|
||||
String serverSocketDomain = attributesGetter.getServerSocketDomain(request, response);
|
||||
Integer serverSocketPort = attributesGetter.getServerSocketPort(request, response);
|
||||
peerService = mapToPeerService(serverSocketDomain, serverSocketPort, null);
|
||||
}
|
||||
if (peerService != null) {
|
||||
attributes.put(SemanticAttributes.PEER_SERVICE, peerService);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String mapToPeerService(
|
||||
@Nullable String host, @Nullable Integer port, @Nullable Supplier<String> pathSupplier) {
|
||||
if (host == null) {
|
||||
return null;
|
||||
}
|
||||
return peerServiceResolver.resolveService(host, port, pathSupplier);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getUrlPath(
|
||||
HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter, REQUEST request) {
|
||||
String urlFull = attributesGetter.getUrlFull(request);
|
||||
if (urlFull == null) {
|
||||
return null;
|
||||
}
|
||||
return UrlParser.getPath(urlFull);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ 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.SemanticAttributes;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -23,24 +22,24 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
|||
implements AttributesExtractor<REQUEST, RESPONSE> {
|
||||
|
||||
private final ServerAttributesGetter<REQUEST, RESPONSE> attributesGetter;
|
||||
private final Map<String, String> peerServiceMapping;
|
||||
private final PeerServiceResolver peerServiceResolver;
|
||||
|
||||
// visible for tests
|
||||
PeerServiceAttributesExtractor(
|
||||
ServerAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
||||
Map<String, String> peerServiceMapping) {
|
||||
PeerServiceResolver peerServiceResolver) {
|
||||
this.attributesGetter = attributesGetter;
|
||||
this.peerServiceMapping = peerServiceMapping;
|
||||
this.peerServiceResolver = peerServiceResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link PeerServiceAttributesExtractor} that will use the passed {@code
|
||||
* netAttributesExtractor} instance to determine the value of the {@code peer.service} attribute.
|
||||
* attributesGetter} instance to determine the value of the {@code peer.service} attribute.
|
||||
*/
|
||||
public static <REQUEST, RESPONSE> AttributesExtractor<REQUEST, RESPONSE> create(
|
||||
ServerAttributesGetter<REQUEST, RESPONSE> attributesGetter,
|
||||
Map<String, String> peerServiceMapping) {
|
||||
return new PeerServiceAttributesExtractor<>(attributesGetter, peerServiceMapping);
|
||||
PeerServiceResolver peerServiceResolver) {
|
||||
return new PeerServiceAttributesExtractor<>(attributesGetter, peerServiceResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,16 +53,18 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
|||
@Nullable RESPONSE response,
|
||||
@Nullable Throwable error) {
|
||||
|
||||
if (peerServiceMapping.isEmpty()) {
|
||||
if (peerServiceResolver.isEmpty()) {
|
||||
// optimization for common case
|
||||
return;
|
||||
}
|
||||
|
||||
String serverAddress = attributesGetter.getServerAddress(request);
|
||||
String peerService = mapToPeerService(serverAddress);
|
||||
Integer serverPort = attributesGetter.getServerPort(request);
|
||||
String peerService = mapToPeerService(serverAddress, serverPort);
|
||||
if (peerService == null && SemconvStability.emitOldHttpSemconv()) {
|
||||
String serverSocketDomain = attributesGetter.getServerSocketDomain(request, response);
|
||||
peerService = mapToPeerService(serverSocketDomain);
|
||||
Integer serverSocketPort = attributesGetter.getServerSocketPort(request, response);
|
||||
peerService = mapToPeerService(serverSocketDomain, serverSocketPort);
|
||||
}
|
||||
if (peerService != null) {
|
||||
attributes.put(SemanticAttributes.PEER_SERVICE, peerService);
|
||||
|
@ -71,10 +72,10 @@ public final class PeerServiceAttributesExtractor<REQUEST, RESPONSE>
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private String mapToPeerService(@Nullable String endpoint) {
|
||||
if (endpoint == null) {
|
||||
private String mapToPeerService(@Nullable String host, @Nullable Integer port) {
|
||||
if (host == null) {
|
||||
return null;
|
||||
}
|
||||
return peerServiceMapping.get(endpoint);
|
||||
return peerServiceResolver.resolveService(host, port, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.net;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public interface PeerServiceResolver {
|
||||
|
||||
public boolean isEmpty();
|
||||
|
||||
@Nullable
|
||||
public String resolveService(
|
||||
String host, @Nullable Integer port, @Nullable Supplier<String> pathSupplier);
|
||||
|
||||
static PeerServiceResolver create(Map<String, String> mapping) {
|
||||
return new PeerServiceResolverImpl(mapping);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.net;
|
||||
|
||||
import static java.util.Comparator.comparing;
|
||||
import static java.util.Comparator.naturalOrder;
|
||||
import static java.util.Comparator.nullsFirst;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.url.UrlParser;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
class PeerServiceResolverImpl implements PeerServiceResolver {
|
||||
|
||||
private static final Comparator<ServiceMatcher> matcherComparator =
|
||||
nullsFirst(
|
||||
comparing(ServiceMatcher::getPort, nullsFirst(naturalOrder()))
|
||||
.thenComparing(comparing(ServiceMatcher::getPath, nullsFirst(naturalOrder()))));
|
||||
|
||||
private final Map<String, Map<ServiceMatcher, String>> mapping = new HashMap<>();
|
||||
|
||||
PeerServiceResolverImpl(Map<String, String> peerServiceMapping) {
|
||||
peerServiceMapping.forEach(
|
||||
(key, serviceName) -> {
|
||||
String url = "https://" + key;
|
||||
String host = UrlParser.getHost(url);
|
||||
Integer port = UrlParser.getPort(url);
|
||||
String path = UrlParser.getPath(url);
|
||||
Map<ServiceMatcher, String> matchers =
|
||||
mapping.computeIfAbsent(host, x -> new HashMap<>());
|
||||
matchers.putIfAbsent(ServiceMatcher.create(port, path), serviceName);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return mapping.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String resolveService(
|
||||
String host, @Nullable Integer port, @Nullable Supplier<String> pathSupplier) {
|
||||
Map<ServiceMatcher, String> matchers = mapping.get(host);
|
||||
if (matchers == null) {
|
||||
return null;
|
||||
}
|
||||
return matchers.entrySet().stream()
|
||||
.filter(entry -> entry.getKey().matches(port, pathSupplier))
|
||||
.max((o1, o2) -> matcherComparator.compare(o1.getKey(), o2.getKey()))
|
||||
.map(Map.Entry::getValue)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@AutoValue
|
||||
abstract static class ServiceMatcher {
|
||||
|
||||
static ServiceMatcher create(Integer port, String path) {
|
||||
return new AutoValue_PeerServiceResolverImpl_ServiceMatcher(port, path);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
abstract Integer getPort();
|
||||
|
||||
@Nullable
|
||||
abstract String getPath();
|
||||
|
||||
public boolean matches(Integer port, Supplier<String> pathSupplier) {
|
||||
if (this.getPort() != null) {
|
||||
if (!this.getPort().equals(port)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.getPath() != null && this.getPath().length() > 0) {
|
||||
if (pathSupplier == null) {
|
||||
return false;
|
||||
}
|
||||
String path = pathSupplier.get();
|
||||
if (path == null) {
|
||||
return false;
|
||||
}
|
||||
if (!path.startsWith(this.getPath())) {
|
||||
return false;
|
||||
}
|
||||
if (port != null) {
|
||||
return port.equals(this.getPort());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.url;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class UrlParser {
|
||||
|
||||
@Nullable
|
||||
public static String getHost(String url) {
|
||||
|
||||
int startIndex = getHostStartIndex(url);
|
||||
if (startIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int endIndexExclusive = getHostEndIndexExclusive(url, startIndex);
|
||||
if (endIndexExclusive == startIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return url.substring(startIndex, endIndexExclusive);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Integer getPort(String url) {
|
||||
|
||||
int hostStartIndex = getHostStartIndex(url);
|
||||
if (hostStartIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int hostEndIndexExclusive = getHostEndIndexExclusive(url, hostStartIndex);
|
||||
if (hostEndIndexExclusive == hostStartIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (hostEndIndexExclusive < url.length() && url.charAt(hostEndIndexExclusive) != ':') {
|
||||
return null;
|
||||
}
|
||||
|
||||
int portStartIndex = hostEndIndexExclusive + 1;
|
||||
|
||||
int portEndIndexExclusive = getPortEndIndexExclusive(url, portStartIndex);
|
||||
if (portEndIndexExclusive == portStartIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return safeParse(url.substring(portStartIndex, portEndIndexExclusive));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getPath(String url) {
|
||||
|
||||
int hostStartIndex = getHostStartIndex(url);
|
||||
if (hostStartIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int hostEndIndexExclusive = getHostEndIndexExclusive(url, hostStartIndex);
|
||||
if (hostEndIndexExclusive == hostStartIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int pathStartIndex = url.indexOf('/', hostEndIndexExclusive);
|
||||
if (pathStartIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int pathEndIndexExclusive = getPathEndIndexExclusive(url, pathStartIndex);
|
||||
if (pathEndIndexExclusive == pathStartIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return url.substring(pathStartIndex, pathEndIndexExclusive);
|
||||
}
|
||||
|
||||
private static int getHostStartIndex(String url) {
|
||||
|
||||
int schemeEndIndex = url.indexOf(':');
|
||||
if (schemeEndIndex == -1) {
|
||||
// not a valid url
|
||||
return -1;
|
||||
}
|
||||
|
||||
int len = url.length();
|
||||
if (len <= schemeEndIndex + 2
|
||||
|| url.charAt(schemeEndIndex + 1) != '/'
|
||||
|| url.charAt(schemeEndIndex + 2) != '/') {
|
||||
// has no authority component
|
||||
return -1;
|
||||
}
|
||||
|
||||
return schemeEndIndex + 3;
|
||||
}
|
||||
|
||||
private static int getHostEndIndexExclusive(String url, int startIndex) {
|
||||
// look for the end of the host:
|
||||
// ':' ==> start of port, or
|
||||
// '/', '?', '#' ==> start of path
|
||||
return getEndIndexExclusive(
|
||||
url, startIndex, c -> (c == ':' || c == '/' || c == '?' || c == '#'));
|
||||
}
|
||||
|
||||
private static int getPortEndIndexExclusive(String url, int startIndex) {
|
||||
// look for the end of the port:
|
||||
// '/', '?', '#' ==> start of path
|
||||
return getEndIndexExclusive(url, startIndex, c -> (c == '/' || c == '?' || c == '#'));
|
||||
}
|
||||
|
||||
private static int getPathEndIndexExclusive(String url, int startIndex) {
|
||||
// look for the end of the path:
|
||||
// '?', '#' ==> end of path
|
||||
return getEndIndexExclusive(url, startIndex, c -> (c == '?' || c == '#'));
|
||||
}
|
||||
|
||||
private static int getEndIndexExclusive(
|
||||
String url, int startIndex, Predicate<Character> predicate) {
|
||||
int index;
|
||||
int len = url.length();
|
||||
for (index = startIndex; index < len; index++) {
|
||||
char c = url.charAt(index);
|
||||
if (predicate.test(c)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Integer safeParse(String port) {
|
||||
try {
|
||||
return Integer.valueOf(port);
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private UrlParser() {}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.http;
|
||||
|
||||
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import io.opentelemetry.api.common.Attributes;
|
||||
import io.opentelemetry.api.common.AttributesBuilder;
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
|
||||
import io.opentelemetry.semconv.SemanticAttributes;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class HttpClientPeerServiceAttributesExtractorTest {
|
||||
@Mock HttpClientAttributesGetter<String, String> httpAttributesExtractor;
|
||||
|
||||
@Test
|
||||
void shouldNotSetAnyValueIfNetExtractorReturnsNulls() {
|
||||
// given
|
||||
PeerServiceResolver peerServiceResolver =
|
||||
PeerServiceResolver.create(singletonMap("1.2.3.4", "myService"));
|
||||
|
||||
HttpClientPeerServiceAttributesExtractor<String, String> underTest =
|
||||
new HttpClientPeerServiceAttributesExtractor<>(
|
||||
httpAttributesExtractor, peerServiceResolver);
|
||||
|
||||
Context context = Context.root();
|
||||
|
||||
// when
|
||||
AttributesBuilder attributes = Attributes.builder();
|
||||
underTest.onStart(attributes, context, "request");
|
||||
underTest.onEnd(attributes, context, "request", "response", null);
|
||||
|
||||
// then
|
||||
assertTrue(attributes.build().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldNotSetAnyValueIfPeerNameDoesNotMatch() {
|
||||
// given
|
||||
PeerServiceResolver peerServiceResolver =
|
||||
PeerServiceResolver.create(singletonMap("example.com", "myService"));
|
||||
|
||||
HttpClientPeerServiceAttributesExtractor<String, String> underTest =
|
||||
new HttpClientPeerServiceAttributesExtractor<>(
|
||||
httpAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(httpAttributesExtractor.getServerAddress(any())).thenReturn("example2.com");
|
||||
|
||||
Context context = Context.root();
|
||||
|
||||
// when
|
||||
AttributesBuilder startAttributes = Attributes.builder();
|
||||
underTest.onStart(startAttributes, context, "request");
|
||||
AttributesBuilder endAttributes = Attributes.builder();
|
||||
underTest.onEnd(endAttributes, context, "request", "response", null);
|
||||
|
||||
// then
|
||||
assertTrue(startAttributes.build().isEmpty());
|
||||
assertTrue(endAttributes.build().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldSetPeerNameIfItMatches() {
|
||||
// given
|
||||
Map<String, String> peerServiceMapping = new HashMap<>();
|
||||
peerServiceMapping.put("example.com", "myService");
|
||||
peerServiceMapping.put("1.2.3.4", "someOtherService");
|
||||
|
||||
PeerServiceResolver peerServiceResolver = PeerServiceResolver.create(peerServiceMapping);
|
||||
|
||||
HttpClientPeerServiceAttributesExtractor<String, String> underTest =
|
||||
new HttpClientPeerServiceAttributesExtractor<>(
|
||||
httpAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(httpAttributesExtractor.getServerAddress(any())).thenReturn("example.com");
|
||||
|
||||
Context context = Context.root();
|
||||
|
||||
// when
|
||||
AttributesBuilder startAttributes = Attributes.builder();
|
||||
underTest.onStart(startAttributes, context, "request");
|
||||
AttributesBuilder endAttributes = Attributes.builder();
|
||||
underTest.onEnd(endAttributes, context, "request", "response", null);
|
||||
|
||||
// then
|
||||
assertThat(startAttributes.build()).isEmpty();
|
||||
assertThat(endAttributes.build())
|
||||
.containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService"));
|
||||
verify(httpAttributesExtractor, never()).getServerSocketDomain(any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldSetSockPeerNameIfItMatchesAndNoPeerNameProvided() {
|
||||
// given
|
||||
Map<String, String> peerServiceMapping = new HashMap<>();
|
||||
peerServiceMapping.put("example.com", "myService");
|
||||
peerServiceMapping.put("1.2.3.4", "someOtherService");
|
||||
|
||||
PeerServiceResolver peerServiceResolver = PeerServiceResolver.create(peerServiceMapping);
|
||||
|
||||
HttpClientPeerServiceAttributesExtractor<String, String> underTest =
|
||||
new HttpClientPeerServiceAttributesExtractor<>(
|
||||
httpAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(httpAttributesExtractor.getServerSocketDomain(any(), any())).thenReturn("example.com");
|
||||
|
||||
Context context = Context.root();
|
||||
|
||||
// when
|
||||
AttributesBuilder startAttributes = Attributes.builder();
|
||||
underTest.onStart(startAttributes, context, "request");
|
||||
AttributesBuilder endAttributes = Attributes.builder();
|
||||
underTest.onEnd(endAttributes, context, "request", "response", null);
|
||||
|
||||
// then
|
||||
assertThat(startAttributes.build()).isEmpty();
|
||||
assertThat(endAttributes.build())
|
||||
.containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService"));
|
||||
}
|
||||
}
|
|
@ -35,10 +35,11 @@ class PeerServiceAttributesExtractorTest {
|
|||
@Test
|
||||
void shouldNotSetAnyValueIfNetExtractorReturnsNulls() {
|
||||
// given
|
||||
Map<String, String> peerServiceMapping = singletonMap("1.2.3.4", "myService");
|
||||
PeerServiceResolver peerServiceResolver =
|
||||
PeerServiceResolver.create(singletonMap("1.2.3.4", "myService"));
|
||||
|
||||
PeerServiceAttributesExtractor<String, String> underTest =
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping);
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceResolver);
|
||||
|
||||
Context context = Context.root();
|
||||
|
||||
|
@ -54,10 +55,11 @@ class PeerServiceAttributesExtractorTest {
|
|||
@Test
|
||||
void shouldNotSetAnyValueIfPeerNameDoesNotMatch() {
|
||||
// given
|
||||
Map<String, String> peerServiceMapping = singletonMap("example.com", "myService");
|
||||
PeerServiceResolver peerServiceResolver =
|
||||
PeerServiceResolver.create(singletonMap("example.com", "myService"));
|
||||
|
||||
PeerServiceAttributesExtractor<String, String> underTest =
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping);
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(netAttributesExtractor.getServerAddress(any())).thenReturn("example2.com");
|
||||
|
||||
|
@ -81,8 +83,10 @@ class PeerServiceAttributesExtractorTest {
|
|||
peerServiceMapping.put("example.com", "myService");
|
||||
peerServiceMapping.put("1.2.3.4", "someOtherService");
|
||||
|
||||
PeerServiceResolver peerServiceResolver = PeerServiceResolver.create(peerServiceMapping);
|
||||
|
||||
PeerServiceAttributesExtractor<String, String> underTest =
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping);
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(netAttributesExtractor.getServerAddress(any())).thenReturn("example.com");
|
||||
|
||||
|
@ -111,8 +115,10 @@ class PeerServiceAttributesExtractorTest {
|
|||
peerServiceMapping.put("example.com", "myService");
|
||||
peerServiceMapping.put("1.2.3.4", "someOtherService");
|
||||
|
||||
PeerServiceResolver peerServiceResolver = PeerServiceResolver.create(peerServiceMapping);
|
||||
|
||||
PeerServiceAttributesExtractor<String, String> underTest =
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping);
|
||||
new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceResolver);
|
||||
|
||||
when(netAttributesExtractor.getServerSocketDomain(any(), any())).thenReturn("example.com");
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.net;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class PeerServiceResolverTest {
|
||||
|
||||
@Test
|
||||
void test() {
|
||||
Map<String, String> peerServiceMapping = new HashMap<>();
|
||||
peerServiceMapping.put("example.com:8080", "myService");
|
||||
peerServiceMapping.put("example.com", "myServiceBase");
|
||||
peerServiceMapping.put("1.2.3.4", "someOtherService");
|
||||
peerServiceMapping.put("1.2.3.4:8080/api", "someOtherService8080");
|
||||
peerServiceMapping.put("1.2.3.4/api", "someOtherServiceAPI");
|
||||
|
||||
PeerServiceResolver peerServiceResolver = PeerServiceResolver.create(peerServiceMapping);
|
||||
|
||||
assertEquals("myServiceBase", peerServiceResolver.resolveService("example.com", null, null));
|
||||
assertEquals("myService", peerServiceResolver.resolveService("example.com", 8080, () -> "/"));
|
||||
assertEquals(
|
||||
"someOtherService8080", peerServiceResolver.resolveService("1.2.3.4", 8080, () -> "/api"));
|
||||
assertEquals(
|
||||
"someOtherService", peerServiceResolver.resolveService("1.2.3.4", 9000, () -> "/api"));
|
||||
assertEquals(
|
||||
"someOtherService", peerServiceResolver.resolveService("1.2.3.4", 8080, () -> null));
|
||||
assertEquals(
|
||||
"someOtherServiceAPI", peerServiceResolver.resolveService("1.2.3.4", null, () -> "/api"));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,249 @@
|
|||
/*
|
||||
* Copyright The OpenTelemetry Authors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
package io.opentelemetry.instrumentation.api.instrumenter.url;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class UrlParserTest {
|
||||
|
||||
@Test
|
||||
void testGetHost() {
|
||||
assertThat(UrlParser.getHost("https://localhost")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost/")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost?")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost/?")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost?query")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost/?query")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost#")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost/#")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost#fragment")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost/#fragment")).isEqualTo("localhost");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetHostWithPort() {
|
||||
assertThat(UrlParser.getHost("https://localhost:8080")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost:8080/")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost:8080?")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost:8080/?")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost:8080?query")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost:8080/?query")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost:8080#")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost:8080/#")).isEqualTo("localhost");
|
||||
|
||||
assertThat(UrlParser.getHost("https://localhost:8080#fragment")).isEqualTo("localhost");
|
||||
assertThat(UrlParser.getHost("https://localhost:8080/#fragment")).isEqualTo("localhost");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetHostWithNoAuthority() {
|
||||
assertThat(UrlParser.getHost("https:")).isNull();
|
||||
assertThat(UrlParser.getHost("https:/")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("https:?")).isNull();
|
||||
assertThat(UrlParser.getHost("https:/?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("https:?query")).isNull();
|
||||
assertThat(UrlParser.getHost("https:/?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("https:#")).isNull();
|
||||
assertThat(UrlParser.getHost("https:/#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("https:#fragment")).isNull();
|
||||
assertThat(UrlParser.getHost("https:/#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetHostWithNoScheme() {
|
||||
assertThat(UrlParser.getHost("")).isNull();
|
||||
assertThat(UrlParser.getHost("/")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("?")).isNull();
|
||||
assertThat(UrlParser.getHost("/?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("?query")).isNull();
|
||||
assertThat(UrlParser.getHost("/?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("#")).isNull();
|
||||
assertThat(UrlParser.getHost("/#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getHost("#fragment")).isNull();
|
||||
assertThat(UrlParser.getHost("/#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPort() {
|
||||
assertThat(UrlParser.getPort("https://localhost")).isNull();
|
||||
assertThat(UrlParser.getPort("https://localhost/")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost?")).isNull();
|
||||
assertThat(UrlParser.getPort("https://localhost/?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost?query")).isNull();
|
||||
assertThat(UrlParser.getPort("https://localhost/?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost#")).isNull();
|
||||
assertThat(UrlParser.getPort("https://localhost/#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost#fragment")).isNull();
|
||||
assertThat(UrlParser.getPort("https://localhost/#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPortWithPort() {
|
||||
assertThat(UrlParser.getPort("https://localhost:8080")).isEqualTo(8080);
|
||||
assertThat(UrlParser.getPort("https://localhost:8080/")).isEqualTo(8080);
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost:8080?")).isEqualTo(8080);
|
||||
assertThat(UrlParser.getPort("https://localhost:8080/?")).isEqualTo(8080);
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost:8080?query")).isEqualTo(8080);
|
||||
assertThat(UrlParser.getPort("https://localhost:8080/?query")).isEqualTo(8080);
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost:8080#")).isEqualTo(8080);
|
||||
assertThat(UrlParser.getPort("https://localhost:8080/#")).isEqualTo(8080);
|
||||
|
||||
assertThat(UrlParser.getPort("https://localhost:8080#fragment")).isEqualTo(8080);
|
||||
assertThat(UrlParser.getPort("https://localhost:8080/#fragment")).isEqualTo(8080);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPortWithNoAuthority() {
|
||||
assertThat(UrlParser.getPort("https:")).isNull();
|
||||
assertThat(UrlParser.getPort("https:/")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https:?")).isNull();
|
||||
assertThat(UrlParser.getPort("https:/?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https:?query")).isNull();
|
||||
assertThat(UrlParser.getPort("https:/?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https:#")).isNull();
|
||||
assertThat(UrlParser.getPort("https:/#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("https:#fragment")).isNull();
|
||||
assertThat(UrlParser.getPort("https:/#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPortWithNoScheme() {
|
||||
assertThat(UrlParser.getPort("")).isNull();
|
||||
assertThat(UrlParser.getPort("/")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("?")).isNull();
|
||||
assertThat(UrlParser.getPort("/?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("?query")).isNull();
|
||||
assertThat(UrlParser.getPort("/?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("#")).isNull();
|
||||
assertThat(UrlParser.getPort("/#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPort("#fragment")).isNull();
|
||||
assertThat(UrlParser.getPort("/#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPath() {
|
||||
assertThat(UrlParser.getPath("https://localhost")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost/")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost/api/v1")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost?")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost/?")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost/api/v1?")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost?query")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost/?query")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost/api/v1?query")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost#")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost/#")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost/api/v1#")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost/#fragment")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost/api/v1#fragment")).isEqualTo("/api/v1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPathWithPort() {
|
||||
assertThat(UrlParser.getPath("https://localhost:8080")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/api/v1")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost:8080?")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/?")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/api/v1?")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost:8080?query")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/?query")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/api/v1?query")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost:8080#")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/#")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/api/v1#")).isEqualTo("/api/v1");
|
||||
|
||||
assertThat(UrlParser.getPath("https://localhost:8080#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/#fragment")).isEqualTo("/");
|
||||
assertThat(UrlParser.getPath("https://localhost:8080/api/v1#fragment")).isEqualTo("/api/v1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPathWithNoAuthority() {
|
||||
assertThat(UrlParser.getPath("https:")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/api/v1")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("https:?")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/?")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/api/v1?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("https:?query")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/?query")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/api/v1?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("https:#")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/#")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/api/v1#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("https:#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("https:/api/v1#fragment")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetPathtWithNoScheme() {
|
||||
assertThat(UrlParser.getPath("")).isNull();
|
||||
assertThat(UrlParser.getPath("/")).isNull();
|
||||
assertThat(UrlParser.getPath("/api/v1")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("?")).isNull();
|
||||
assertThat(UrlParser.getPath("/?")).isNull();
|
||||
assertThat(UrlParser.getPath("/api/v1?")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("?query")).isNull();
|
||||
assertThat(UrlParser.getPath("/?query")).isNull();
|
||||
assertThat(UrlParser.getPath("/api/v1?query")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("#")).isNull();
|
||||
assertThat(UrlParser.getPath("/#")).isNull();
|
||||
assertThat(UrlParser.getPath("/api/v1#")).isNull();
|
||||
|
||||
assertThat(UrlParser.getPath("#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("/#fragment")).isNull();
|
||||
assertThat(UrlParser.getPath("/api/v1#fragment")).isNull();
|
||||
}
|
||||
}
|
|
@ -14,9 +14,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import io.opentelemetry.javaagent.instrumentation.akkahttp.AkkaHttpUtil;
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class AkkaHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -27,7 +27,7 @@ public class OpenTelemetryFilter implements Filter {
|
|||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
new DubboClientNetworkAttributesGetter(),
|
||||
CommonConfig.get().getPeerServiceMapping()))
|
||||
CommonConfig.get().getPeerServiceResolver()))
|
||||
.build()
|
||||
.newFilter();
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
||||
|
@ -41,8 +41,8 @@ public final class ApacheHttpAsyncClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
|
||||
|
@ -41,8 +41,8 @@ public final class ApacheHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import org.apache.http.HttpResponse;
|
||||
|
||||
|
@ -41,8 +41,8 @@ public final class ApacheHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import org.apache.hc.core5.http.HttpRequest;
|
||||
import org.apache.hc.core5.http.HttpResponse;
|
||||
|
@ -42,8 +42,8 @@ public final class ApacheHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -8,7 +8,7 @@ package io.opentelemetry.javaagent.instrumentation.armeria.v1_3;
|
|||
import com.linecorp.armeria.client.HttpClient;
|
||||
import com.linecorp.armeria.server.HttpService;
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.armeria.v1_3.ArmeriaTelemetry;
|
||||
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaHttpClientAttributesGetter;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
@ -28,9 +28,9 @@ public final class ArmeriaSingletons {
|
|||
.setCapturedClientResponseHeaders(CommonConfig.get().getClientResponseHeaders())
|
||||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.addClientAttributeExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
ArmeriaHttpClientAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping()))
|
||||
CommonConfig.get().getPeerServiceResolver()))
|
||||
.setEmitExperimentalHttpClientMetrics(
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics())
|
||||
.setEmitExperimentalHttpServerMetrics(
|
||||
|
|
|
@ -13,9 +13,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
||||
public final class AsyncHttpClientSingletons {
|
||||
|
@ -42,8 +42,8 @@ public final class AsyncHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import org.asynchttpclient.Response;
|
||||
|
||||
|
@ -41,8 +41,8 @@ public final class AsyncHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addAttributesExtractor(new AsyncHttpClientAdditionalAttributesExtractor())
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
|
|
|
@ -36,7 +36,7 @@ public final class CouchbaseSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addContextCustomizer(
|
||||
(context, couchbaseRequest, startAttributes) ->
|
||||
CouchbaseRequestInfo.init(context, couchbaseRequest));
|
||||
|
|
|
@ -13,9 +13,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
||||
public class GoogleHttpClientSingletons {
|
||||
|
@ -42,8 +42,8 @@ public class GoogleHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import java.net.HttpURLConnection;
|
||||
|
||||
|
@ -39,8 +39,8 @@ public final class HttpUrlConnectionSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addAttributesExtractor(
|
||||
HttpMethodAttributeExtractor.create(
|
||||
CommonConfig.get().getKnownHttpRequestMethods()))
|
||||
|
|
|
@ -9,7 +9,7 @@ import static java.util.Collections.singletonList;
|
|||
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.httpclient.internal.HttpHeadersSetter;
|
||||
import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientAttributesGetter;
|
||||
import io.opentelemetry.instrumentation.httpclient.internal.JavaHttpClientInstrumenterFactory;
|
||||
|
@ -35,9 +35,9 @@ public class JavaHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
builder -> builder.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
singletonList(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
JavaHttpClientAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping())),
|
||||
CommonConfig.get().getPeerServiceResolver())),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public final class JdbcSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class JedisSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class JedisSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class JedisSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import static java.util.Collections.singletonList;
|
|||
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyClientHttpAttributesGetter;
|
||||
import io.opentelemetry.instrumentation.jetty.httpclient.v9_2.internal.JettyClientInstrumenterFactory;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
@ -28,9 +28,9 @@ public class JettyHttpClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
builder -> builder.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
singletonList(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
JettyClientHttpAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping())),
|
||||
CommonConfig.get().getPeerServiceResolver())),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
|
||||
public static Instrumenter<Request, Response> instrumenter() {
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import jodd.http.HttpRequest;
|
||||
import jodd.http.HttpResponse;
|
||||
|
@ -41,8 +41,8 @@ public final class JoddHttpSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class LettuceSingletons {
|
|||
.addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addAttributesExtractor(new LettuceConnectAttributesExtractor())
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class LettuceSingletons {
|
|||
ServerAttributesExtractor.create(connectNetworkAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
connectNetworkAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
connectNetworkAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addAttributesExtractor(new LettuceConnectAttributesExtractor())
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.netty.common.internal.NettyConnectionRequest;
|
||||
import io.opentelemetry.instrumentation.netty.common.internal.NettyErrorHolder;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
@ -47,8 +47,8 @@ public final class NettyClientSingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get())
|
||||
.addContextCustomizer(
|
||||
(context, requestAndChannel, startAttributes) -> NettyErrorHolder.init(context));
|
||||
|
@ -63,9 +63,9 @@ public final class NettyClientSingletons {
|
|||
.addAttributesExtractor(
|
||||
HttpClientAttributesExtractor.create(NettyConnectHttpAttributesGetter.INSTANCE))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
NettyConnectHttpAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping()))
|
||||
CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,15 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttribut
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractorBuilder;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractorBuilder;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
|
||||
import io.opentelemetry.instrumentation.netty.common.internal.NettyConnectionRequest;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ public final class NettyClientInstrumenterFactory {
|
|||
private final String instrumentationName;
|
||||
private final NettyConnectionInstrumentationFlag connectionTelemetryState;
|
||||
private final NettyConnectionInstrumentationFlag sslTelemetryState;
|
||||
private final Map<String, String> peerServiceMapping;
|
||||
private final PeerServiceResolver peerServiceResolver;
|
||||
private final boolean emitExperimentalHttpClientMetrics;
|
||||
|
||||
public NettyClientInstrumenterFactory(
|
||||
|
@ -44,13 +45,13 @@ public final class NettyClientInstrumenterFactory {
|
|||
String instrumentationName,
|
||||
NettyConnectionInstrumentationFlag connectionTelemetryState,
|
||||
NettyConnectionInstrumentationFlag sslTelemetryState,
|
||||
Map<String, String> peerServiceMapping,
|
||||
PeerServiceResolver peerServiceResolver,
|
||||
boolean emitExperimentalHttpClientMetrics) {
|
||||
this.openTelemetry = openTelemetry;
|
||||
this.instrumentationName = instrumentationName;
|
||||
this.connectionTelemetryState = connectionTelemetryState;
|
||||
this.sslTelemetryState = sslTelemetryState;
|
||||
this.peerServiceMapping = peerServiceMapping;
|
||||
this.peerServiceResolver = peerServiceResolver;
|
||||
this.emitExperimentalHttpClientMetrics = emitExperimentalHttpClientMetrics;
|
||||
}
|
||||
|
||||
|
@ -76,7 +77,8 @@ public final class NettyClientInstrumenterFactory {
|
|||
.setSpanStatusExtractor(HttpSpanStatusExtractor.create(httpAttributesGetter))
|
||||
.addAttributesExtractor(extractorBuilder.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(httpAttributesGetter, peerServiceMapping))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, peerServiceResolver))
|
||||
.addAttributesExtractors(additionalHttpAttributeExtractors)
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (emitExperimentalHttpClientMetrics) {
|
||||
|
@ -99,7 +101,7 @@ public final class NettyClientInstrumenterFactory {
|
|||
Instrumenter.<NettyConnectionRequest, Channel>builder(
|
||||
openTelemetry, instrumentationName, NettyConnectionRequest::spanName)
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(getter, peerServiceMapping));
|
||||
HttpClientPeerServiceAttributesExtractor.create(getter, peerServiceResolver));
|
||||
|
||||
if (connectionTelemetryFullyEnabled) {
|
||||
// when the connection telemetry is fully enabled, CONNECT spans are created for every
|
||||
|
@ -141,7 +143,7 @@ public final class NettyClientInstrumenterFactory {
|
|||
io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesExtractor
|
||||
.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(netAttributesGetter, peerServiceMapping))
|
||||
PeerServiceAttributesExtractor.create(netAttributesGetter, peerServiceResolver))
|
||||
.buildInstrumenter(
|
||||
sslTelemetryFullyEnabled
|
||||
? SpanKindExtractor.alwaysInternal()
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class NettyClientSingletons {
|
|||
"io.opentelemetry.netty-4.0",
|
||||
enabledOrErrorOnly(connectionTelemetryEnabled),
|
||||
enabledOrErrorOnly(sslTelemetryEnabled),
|
||||
CommonConfig.get().getPeerServiceMapping(),
|
||||
CommonConfig.get().getPeerServiceResolver(),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
INSTRUMENTER =
|
||||
factory.createHttpInstrumenter(
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class NettyClientSingletons {
|
|||
"io.opentelemetry.netty-4.1",
|
||||
enabledOrErrorOnly(connectionTelemetryEnabled),
|
||||
enabledOrErrorOnly(sslTelemetryEnabled),
|
||||
CommonConfig.get().getPeerServiceMapping(),
|
||||
CommonConfig.get().getPeerServiceResolver(),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
INSTRUMENTER =
|
||||
factory.createHttpInstrumenter(
|
||||
|
|
|
@ -11,6 +11,7 @@ import io.opentelemetry.api.OpenTelemetry;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractorBuilder;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractorBuilder;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.HttpRequestAndChannel;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumentationFlag;
|
||||
|
@ -119,7 +120,7 @@ public final class NettyClientTelemetryBuilder {
|
|||
"io.opentelemetry.netty-4.1",
|
||||
NettyConnectionInstrumentationFlag.DISABLED,
|
||||
NettyConnectionInstrumentationFlag.DISABLED,
|
||||
Collections.emptyMap(),
|
||||
PeerServiceResolver.create(Collections.emptyMap()),
|
||||
emitExperimentalHttpClientMetrics)
|
||||
.createHttpInstrumenter(
|
||||
extractorConfigurer, spanNameExtractorConfigurer, additionalAttributesExtractors));
|
||||
|
|
|
@ -17,9 +17,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
|
||||
public final class OkHttp2Singletons {
|
||||
|
@ -48,8 +48,8 @@ public final class OkHttp2Singletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,8 +11,8 @@ import io.opentelemetry.api.GlobalOpenTelemetry;
|
|||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientResendCount;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.okhttp.v3_0.internal.ConnectionErrorSpanInterceptor;
|
||||
import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpAttributesGetter;
|
||||
import io.opentelemetry.instrumentation.okhttp.v3_0.internal.OkHttpInstrumenterFactory;
|
||||
|
@ -35,8 +35,8 @@ public final class OkHttp3Singletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
builder -> builder.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
singletonList(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
OkHttpAttributesGetter.INSTANCE, CommonConfig.get().getPeerServiceMapping())),
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
OkHttpAttributesGetter.INSTANCE, CommonConfig.get().getPeerServiceResolver())),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
|
||||
public static final Interceptor CONTEXT_INTERCEPTOR =
|
||||
|
|
|
@ -32,7 +32,7 @@ public final class OpenSearchRestInstrumenterFactory {
|
|||
.create(netAttributesGetter))
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
netAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class PekkoHttpClientSingletons {
|
|||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import play.shaded.ahc.org.asynchttpclient.Request;
|
||||
import play.shaded.ahc.org.asynchttpclient.Response;
|
||||
|
@ -38,8 +38,8 @@ public final class PlayWsClientInstrumenterFactory {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -18,7 +18,7 @@ public final class R2dbcSingletons {
|
|||
.setStatementSanitizationEnabled(CommonConfig.get().isStatementSanitizationEnabled())
|
||||
.addAttributeExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
R2dbcNetAttributesGetter.INSTANCE, CommonConfig.get().getPeerServiceMapping()))
|
||||
R2dbcNetAttributesGetter.INSTANCE, CommonConfig.get().getPeerServiceResolver()))
|
||||
.build();
|
||||
|
||||
public static R2dbcTelemetry telemetry() {
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyClientInstrumenterFactory;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumentationFlag;
|
||||
import io.opentelemetry.instrumentation.netty.v4.common.internal.client.NettyConnectionInstrumenter;
|
||||
|
@ -61,8 +61,8 @@ public final class ReactorNettySingletons {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
@ -77,7 +77,7 @@ public final class ReactorNettySingletons {
|
|||
? NettyConnectionInstrumentationFlag.ENABLED
|
||||
: NettyConnectionInstrumentationFlag.DISABLED,
|
||||
NettyConnectionInstrumentationFlag.DISABLED,
|
||||
CommonConfig.get().getPeerServiceMapping(),
|
||||
CommonConfig.get().getPeerServiceResolver(),
|
||||
CommonConfig.get().shouldEmitExperimentalHttpClientMetrics());
|
||||
CONNECTION_INSTRUMENTER = instrumenterFactory.createConnectionInstrumenter();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import static java.util.Collections.singletonList;
|
|||
|
||||
import io.opentelemetry.api.GlobalOpenTelemetry;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.ClientInstrumenterFactory;
|
||||
import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.WebClientHttpAttributesGetter;
|
||||
import io.opentelemetry.instrumentation.spring.webflux.v5_3.internal.WebClientTracingFilter;
|
||||
|
@ -32,9 +32,9 @@ public final class WebClientHelper {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
builder -> builder.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods()),
|
||||
singletonList(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
WebClientHttpAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping())),
|
||||
CommonConfig.get().getPeerServiceResolver())),
|
||||
InstrumentationConfig.get()
|
||||
.getBoolean(
|
||||
"otel.instrumentation.spring-webflux.experimental-span-attributes", false),
|
||||
|
|
|
@ -11,9 +11,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
|
|||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientExperimentalMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientMetrics;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientPeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor;
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor;
|
||||
import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig;
|
||||
import io.vertx.core.http.HttpClientRequest;
|
||||
import io.vertx.core.http.HttpClientResponse;
|
||||
|
@ -38,8 +38,8 @@ public final class VertxClientInstrumenterFactory {
|
|||
.setKnownMethods(CommonConfig.get().getKnownHttpRequestMethods())
|
||||
.build())
|
||||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceMapping()))
|
||||
HttpClientPeerServiceAttributesExtractor.create(
|
||||
httpAttributesGetter, CommonConfig.get().getPeerServiceResolver()))
|
||||
.addOperationMetrics(HttpClientMetrics.get());
|
||||
if (CommonConfig.get().shouldEmitExperimentalHttpClientMetrics()) {
|
||||
builder.addOperationMetrics(HttpClientExperimentalMetrics.get());
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class VertxSqlClientSingletons {
|
|||
.addAttributesExtractor(
|
||||
PeerServiceAttributesExtractor.create(
|
||||
VertxSqlClientNetAttributesGetter.INSTANCE,
|
||||
CommonConfig.get().getPeerServiceMapping()));
|
||||
CommonConfig.get().getPeerServiceResolver()));
|
||||
|
||||
INSTRUMENTER = builder.buildInstrumenter(SpanKindExtractor.alwaysClient());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ dependencies {
|
|||
api("net.bytebuddy:byte-buddy-dep")
|
||||
|
||||
implementation(project(":instrumentation-api"))
|
||||
implementation(project(":instrumentation-api-semconv"))
|
||||
|
||||
// autoconfigure is unstable, do not expose as api
|
||||
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
|
||||
|
|
|
@ -7,11 +7,11 @@ package io.opentelemetry.javaagent.bootstrap.internal;
|
|||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceResolver;
|
||||
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ public final class CommonConfig {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private final Map<String, String> peerServiceMapping;
|
||||
private final PeerServiceResolver peerServiceResolver;
|
||||
private final List<String> clientRequestHeaders;
|
||||
private final List<String> clientResponseHeaders;
|
||||
private final List<String> serverRequestHeaders;
|
||||
|
@ -37,8 +37,9 @@ public final class CommonConfig {
|
|||
private final boolean emitExperimentalHttpServerMetrics;
|
||||
|
||||
CommonConfig(InstrumentationConfig config) {
|
||||
peerServiceMapping =
|
||||
config.getMap("otel.instrumentation.common.peer-service-mapping", emptyMap());
|
||||
peerServiceResolver =
|
||||
PeerServiceResolver.create(
|
||||
config.getMap("otel.instrumentation.common.peer-service-mapping", emptyMap()));
|
||||
|
||||
// TODO (mateusz): remove the old config names in 2.0
|
||||
clientRequestHeaders =
|
||||
|
@ -74,8 +75,8 @@ public final class CommonConfig {
|
|||
config.getBoolean("otel.instrumentation.http.server.emit-experimental-metrics", false);
|
||||
}
|
||||
|
||||
public Map<String, String> getPeerServiceMapping() {
|
||||
return peerServiceMapping;
|
||||
public PeerServiceResolver getPeerServiceResolver() {
|
||||
return peerServiceResolver;
|
||||
}
|
||||
|
||||
public List<String> getClientRequestHeaders() {
|
||||
|
|
Loading…
Reference in New Issue