Update OpenTelemetry API/SDK (#257)
* Update dependency version * Change getTracerFactory to getTracerProvider * Update some imports * Change put to set * Fix up bridge * Update package names * Update test SpanProcessor * Remove null conditionals around setAttribute * Update shading * Update span context extraction
This commit is contained in:
parent
8700b2eb33
commit
396baa69d6
|
|
@ -34,10 +34,7 @@ public abstract class BaseDecorator {
|
|||
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
final String component = getComponentName();
|
||||
if (component != null) {
|
||||
span.setAttribute(Tags.COMPONENT, component);
|
||||
}
|
||||
span.setAttribute(Tags.COMPONENT, getComponentName());
|
||||
return span;
|
||||
}
|
||||
|
||||
|
|
@ -77,10 +74,7 @@ public abstract class BaseDecorator {
|
|||
}
|
||||
|
||||
public static void addThrowable(final Span span, final Throwable throwable) {
|
||||
final String message = throwable.getMessage();
|
||||
if (message != null) {
|
||||
span.setAttribute(MoreTags.ERROR_MSG, message);
|
||||
}
|
||||
span.setAttribute(MoreTags.ERROR_MSG, throwable.getMessage());
|
||||
span.setAttribute(MoreTags.ERROR_TYPE, throwable.getClass().getName());
|
||||
|
||||
final StringWriter errorString = new StringWriter();
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ public abstract class ClientDecorator extends BaseDecorator {
|
|||
@Override
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
if (service() != null) {
|
||||
span.setAttribute(MoreTags.SERVICE_NAME, service());
|
||||
}
|
||||
return super.afterStart(span);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorato
|
|||
@Override
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
final String type = dbType();
|
||||
if (type != null) {
|
||||
span.setAttribute(Tags.DB_TYPE, type);
|
||||
}
|
||||
span.setAttribute(Tags.DB_TYPE, dbType());
|
||||
return super.afterStart(span);
|
||||
}
|
||||
|
||||
|
|
@ -48,17 +45,11 @@ public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorato
|
|||
public Span onConnection(final Span span, final CONNECTION connection) {
|
||||
assert span != null;
|
||||
if (connection != null) {
|
||||
final String user = dbUser(connection);
|
||||
if (user != null) {
|
||||
span.setAttribute(Tags.DB_USER, user);
|
||||
}
|
||||
final String instanceName = dbInstance(connection);
|
||||
if (instanceName != null) {
|
||||
span.setAttribute(Tags.DB_INSTANCE, instanceName);
|
||||
}
|
||||
span.setAttribute(Tags.DB_USER, dbUser(connection));
|
||||
span.setAttribute(Tags.DB_INSTANCE, dbInstance(connection));
|
||||
|
||||
if (instanceName != null && Config.get().isDbClientSplitByInstance()) {
|
||||
span.setAttribute(MoreTags.SERVICE_NAME, instanceName);
|
||||
if (Config.get().isDbClientSplitByInstance()) {
|
||||
span.setAttribute(MoreTags.SERVICE_NAME, dbInstance(connection));
|
||||
}
|
||||
}
|
||||
return span;
|
||||
|
|
|
|||
|
|
@ -55,10 +55,7 @@ public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends ClientDecor
|
|||
public Span onRequest(final Span span, final REQUEST request) {
|
||||
assert span != null;
|
||||
if (request != null) {
|
||||
final String method = method(request);
|
||||
if (method != null) {
|
||||
span.setAttribute(Tags.HTTP_METHOD, method);
|
||||
}
|
||||
span.setAttribute(Tags.HTTP_METHOD, method(request));
|
||||
|
||||
// Copy of HttpServerDecorator url handling
|
||||
try {
|
||||
|
|
@ -94,26 +91,20 @@ public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends ClientDecor
|
|||
span.setAttribute(Tags.HTTP_URL, urlBuilder.toString());
|
||||
|
||||
if (Config.get().isHttpClientTagQueryString()) {
|
||||
if (query != null) {
|
||||
span.setAttribute(MoreTags.HTTP_QUERY, query);
|
||||
}
|
||||
if (fragment != null) {
|
||||
span.setAttribute(MoreTags.HTTP_FRAGMENT, fragment);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug("Error tagging url", e);
|
||||
}
|
||||
|
||||
final String hostname = hostname(request);
|
||||
if (hostname != null) {
|
||||
span.setAttribute(MoreTags.NET_PEER_NAME, hostname);
|
||||
|
||||
if (Config.get().isHttpClientSplitByDomain()) {
|
||||
span.setAttribute(MoreTags.SERVICE_NAME, hostname);
|
||||
}
|
||||
}
|
||||
final Integer port = port(request);
|
||||
// Negative or Zero ports might represent an unset/null value for an int type. Skip setting.
|
||||
if (port != null && port > 0) {
|
||||
|
|
|
|||
|
|
@ -86,14 +86,10 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE> extends
|
|||
span.setAttribute(Tags.HTTP_URL, urlBuilder.toString());
|
||||
|
||||
if (Config.get().isHttpServerTagQueryString()) {
|
||||
if (url.getQuery() != null) {
|
||||
span.setAttribute(MoreTags.HTTP_QUERY, url.getQuery());
|
||||
}
|
||||
if (url.getFragment() != null) {
|
||||
span.setAttribute(MoreTags.HTTP_FRAGMENT, url.getFragment());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug("Error tagging url", e);
|
||||
}
|
||||
|
|
@ -105,10 +101,7 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE> extends
|
|||
public Span onConnection(final Span span, final CONNECTION connection) {
|
||||
assert span != null;
|
||||
if (connection != null) {
|
||||
final String ip = peerHostIP(connection);
|
||||
if (ip != null) {
|
||||
span.setAttribute(MoreTags.NET_PEER_IP, ip);
|
||||
}
|
||||
span.setAttribute(MoreTags.NET_PEER_IP, peerHostIP(connection));
|
||||
final Integer port = peerPort(connection);
|
||||
// Negative or Zero ports might represent an unset/null value for an int type. Skip setting.
|
||||
if (port != null && port > 0) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
public class AdviceUtils {
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.java-concurrent");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.java-concurrent");
|
||||
|
||||
/**
|
||||
* Start scope for a given task
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class BaseDecoratorTest extends AgentSpecification {
|
|||
1 * span.setStatus(Status.UNKNOWN)
|
||||
1 * span.setAttribute(MoreTags.ERROR_TYPE, error.getClass().getName())
|
||||
1 * span.setAttribute(MoreTags.ERROR_STACK, _)
|
||||
1 * span.setAttribute(MoreTags.ERROR_MSG, null)
|
||||
}
|
||||
0 * _
|
||||
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ class ClientDecoratorTest extends BaseDecoratorTest {
|
|||
decorator.afterStart(span)
|
||||
|
||||
then:
|
||||
if (serviceName != null) {
|
||||
1 * span.setAttribute(MoreTags.SERVICE_NAME, serviceName)
|
||||
}
|
||||
1 * span.setAttribute(Tags.COMPONENT, "test-component")
|
||||
_ * span.setAttribute(_, _) // Want to allow other calls from child implementations.
|
||||
0 * _
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
|
|||
decorator.afterStart(span)
|
||||
|
||||
then:
|
||||
if (serviceName != null) {
|
||||
1 * span.setAttribute(MoreTags.SERVICE_NAME, serviceName)
|
||||
}
|
||||
1 * span.setAttribute(Tags.COMPONENT, "test-component")
|
||||
1 * span.setAttribute(Tags.DB_TYPE, "test-db")
|
||||
0 * _
|
||||
|
|
@ -56,13 +54,9 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
|
|||
|
||||
then:
|
||||
if (session) {
|
||||
if (session.user) {
|
||||
1 * span.setAttribute(Tags.DB_USER, session.user)
|
||||
}
|
||||
if (session.instance) {
|
||||
1 * span.setAttribute(Tags.DB_INSTANCE, session.instance)
|
||||
}
|
||||
if (renameService && session.instance) {
|
||||
if (renameService) {
|
||||
1 * span.setAttribute(MoreTags.SERVICE_NAME, session.instance)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,13 +74,11 @@ class HttpClientDecoratorTest extends ClientDecoratorTest {
|
|||
1 * span.setAttribute(Tags.HTTP_URL, expectedUrl)
|
||||
}
|
||||
if (expectedUrl && tagQueryString) {
|
||||
if (expectedQuery) {
|
||||
1 * span.setAttribute(MoreTags.HTTP_QUERY, expectedQuery)
|
||||
}
|
||||
if (expectedFragment) {
|
||||
1 * span.setAttribute(MoreTags.HTTP_FRAGMENT, expectedFragment)
|
||||
}
|
||||
}
|
||||
1 * span.setAttribute(Tags.HTTP_METHOD, null)
|
||||
1 * span.setAttribute(MoreTags.NET_PEER_NAME, null)
|
||||
0 * _
|
||||
|
||||
where:
|
||||
|
|
|
|||
|
|
@ -65,13 +65,9 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
|
|||
1 * span.setAttribute(Tags.HTTP_URL, expectedUrl)
|
||||
}
|
||||
if (expectedUrl && tagQueryString) {
|
||||
if (expectedQuery != null) {
|
||||
1 * span.setAttribute(MoreTags.HTTP_QUERY, expectedQuery)
|
||||
}
|
||||
if (expectedFragment != null) {
|
||||
1 * span.setAttribute(MoreTags.HTTP_FRAGMENT, expectedFragment)
|
||||
}
|
||||
}
|
||||
1 * span.setAttribute(Tags.HTTP_METHOD, null)
|
||||
0 * _
|
||||
|
||||
|
|
@ -108,6 +104,8 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
|
|||
1 * span.setAttribute(MoreTags.NET_PEER_IP, "10.0.0.1")
|
||||
} else if (ipv4 != null) {
|
||||
1 * span.setAttribute(MoreTags.NET_PEER_IP, "3ffe:1900:4545:3:200:f8ff:fe21:67cf")
|
||||
} else {
|
||||
1 * span.setAttribute(MoreTags.NET_PEER_IP, null)
|
||||
}
|
||||
}
|
||||
0 * _
|
||||
|
|
|
|||
|
|
@ -71,17 +71,17 @@ public class AgentInstaller {
|
|||
|
||||
final ClassLoader savedContextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
// calling (shaded) OpenTelemetry.getTracerFactory() with context class loader set to the
|
||||
// calling (shaded) OpenTelemetry.getTracerProvider() with context class loader set to the
|
||||
// agent class loader, so that SPI finds the agent's (isolated) SDK, and (shaded)
|
||||
// OpenTelemetry registers it, and then when instrumentation calls (shaded)
|
||||
// OpenTelemetry.getTracerFactory() later, they get back the agent's (isolated) SDK
|
||||
// OpenTelemetry.getTracerProvider() later, they get back the agent's (isolated) SDK
|
||||
//
|
||||
// but if we don't trigger this early registration, then if instrumentation is the first to
|
||||
// call (shaded) OpenTelemetry.getTracerFactory(), then SPI can't see the agent class loader,
|
||||
// call (shaded) OpenTelemetry.getTracerProvider(), then SPI can't see the agent class loader,
|
||||
// and so (shaded) OpenTelemetry registers the no-op TracerFactory, and it cannot be replaced
|
||||
// later
|
||||
Thread.currentThread().setContextClassLoader(AgentInstaller.class.getClassLoader());
|
||||
OpenTelemetry.getTracerFactory();
|
||||
OpenTelemetry.getTracerProvider();
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(savedContextClassLoader);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,13 @@ public class ExporterClassLoader extends URLClassLoader {
|
|||
rule(
|
||||
"#io.opentelemetry.OpenTelemetry",
|
||||
"#io.opentelemetry.auto.shaded.io.opentelemetry.OpenTelemetry"),
|
||||
rule("#io.opentelemetry.common", "#io.opentelemetry.auto.shaded.io.opentelemetry.common"),
|
||||
rule(
|
||||
"#io.opentelemetry.context",
|
||||
"#io.opentelemetry.auto.shaded.io.opentelemetry.context"),
|
||||
rule(
|
||||
"#io.opentelemetry.correlationcontext",
|
||||
"#io.opentelemetry.auto.shaded.io.opentelemetry.correlationcontext"),
|
||||
rule(
|
||||
"#io.opentelemetry.distributedcontext",
|
||||
"#io.opentelemetry.auto.shaded.io.opentelemetry.distributedcontext"),
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class TracerInstaller {
|
|||
if (exporterJar != null) {
|
||||
final SpanExporter exporter = loadFromJar(exporterJar);
|
||||
if (exporter != null) {
|
||||
OpenTelemetrySdk.getTracerFactory()
|
||||
OpenTelemetrySdk.getTracerProvider()
|
||||
.addSpanProcessor(SimpleSpansProcessor.newBuilder(exporter).build());
|
||||
log.info("Installed span exporter: " + exporter.getClass().getCanonicalName());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class LogContextScopeListener {
|
|||
/** A reference to the log context method that removes an attribute from the log context */
|
||||
private final Method removeMethod;
|
||||
|
||||
final Tracer tracer = OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
final Tracer tracer = OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
public LogContextScopeListener(final Method putMethod, final Method removeMethod) {
|
||||
this.putMethod = putMethod;
|
||||
|
|
|
|||
|
|
@ -26,32 +26,32 @@ public abstract class BaseTypedTracer<T extends BaseTypedSpan, INSTANCE> {
|
|||
protected final Tracer tracer;
|
||||
|
||||
protected BaseTypedTracer() {
|
||||
tracer = OpenTelemetry.getTracerFactory().get(getInstrumentationName(), getVersion());
|
||||
tracer = OpenTelemetry.getTracerProvider().get(getInstrumentationName(), getVersion());
|
||||
}
|
||||
|
||||
protected abstract String getInstrumentationName();
|
||||
|
||||
protected abstract String getVersion();
|
||||
|
||||
public final T startSpan(INSTANCE instance) {
|
||||
public final T startSpan(final INSTANCE instance) {
|
||||
return startSpan(instance, tracer.spanBuilder(getSpanName(instance)));
|
||||
}
|
||||
|
||||
public final T startSpan(INSTANCE instance, Span parent) {
|
||||
public final T startSpan(final INSTANCE instance, final Span parent) {
|
||||
return startSpan(instance, tracer.spanBuilder(getSpanName(instance)).setParent(parent));
|
||||
}
|
||||
|
||||
public final T startSpan(INSTANCE instance, SpanContext parent) {
|
||||
public final T startSpan(final INSTANCE instance, final SpanContext parent) {
|
||||
return startSpan(instance, tracer.spanBuilder(getSpanName(instance)).setParent(parent));
|
||||
}
|
||||
|
||||
private T startSpan(INSTANCE instance, Span.Builder builder) {
|
||||
private T startSpan(final INSTANCE instance, Span.Builder builder) {
|
||||
builder = buildSpan(instance, builder.setSpanKind(getSpanKind()));
|
||||
T wrappedSpan = wrapSpan(builder.startSpan());
|
||||
final T wrappedSpan = wrapSpan(builder.startSpan());
|
||||
return startSpan(instance, wrappedSpan);
|
||||
}
|
||||
|
||||
public final Scope withSpan(T span) {
|
||||
public final Scope withSpan(final T span) {
|
||||
return tracer.withSpan(span);
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ public abstract class BaseTypedTracer<T extends BaseTypedSpan, INSTANCE> {
|
|||
|
||||
// Allow adding additional attributes before start.
|
||||
// eg spanBuilder.setNoParent() or tracer.extract.
|
||||
protected Span.Builder buildSpan(INSTANCE instance, Span.Builder spanBuilder) {
|
||||
protected Span.Builder buildSpan(final INSTANCE instance, final Span.Builder spanBuilder) {
|
||||
return spanBuilder;
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ public abstract class BaseTypedTracer<T extends BaseTypedSpan, INSTANCE> {
|
|||
protected abstract T wrapSpan(Span span);
|
||||
|
||||
// Allow adding additional attributes after start.
|
||||
protected T startSpan(INSTANCE instance, T span) {
|
||||
protected T startSpan(final INSTANCE instance, final T span) {
|
||||
return span;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.typed.base;
|
||||
|
||||
import io.opentelemetry.trace.AttributeValue;
|
||||
import io.opentelemetry.common.AttributeValue;
|
||||
import io.opentelemetry.trace.EndSpanOptions;
|
||||
import io.opentelemetry.trace.Event;
|
||||
import io.opentelemetry.trace.Span;
|
||||
|
|
@ -27,72 +27,73 @@ import java.util.Map;
|
|||
public class DelegatingSpan implements Span {
|
||||
protected final Span delegate;
|
||||
|
||||
public DelegatingSpan(Span delegate) {
|
||||
public DelegatingSpan(final Span delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, String value) {
|
||||
public void setAttribute(final String key, final String value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, long value) {
|
||||
public void setAttribute(final String key, final long value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, double value) {
|
||||
public void setAttribute(final String key, final double value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, boolean value) {
|
||||
public void setAttribute(final String key, final boolean value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, AttributeValue value) {
|
||||
public void setAttribute(final String key, final AttributeValue value) {
|
||||
delegate.setAttribute(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(String name) {
|
||||
public void addEvent(final String name) {
|
||||
delegate.addEvent(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(String name, long timestamp) {
|
||||
public void addEvent(final String name, final long timestamp) {
|
||||
delegate.addEvent(name, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(String name, Map<String, AttributeValue> attributes) {
|
||||
public void addEvent(final String name, final Map<String, AttributeValue> attributes) {
|
||||
delegate.addEvent(name, attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(String name, Map<String, AttributeValue> attributes, long timestamp) {
|
||||
public void addEvent(
|
||||
final String name, final Map<String, AttributeValue> attributes, final long timestamp) {
|
||||
delegate.addEvent(name, attributes, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event) {
|
||||
public void addEvent(final Event event) {
|
||||
delegate.addEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEvent(Event event, long timestamp) {
|
||||
public void addEvent(final Event event, final long timestamp) {
|
||||
delegate.addEvent(event, timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(Status status) {
|
||||
public void setStatus(final Status status) {
|
||||
delegate.setStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateName(String name) {
|
||||
public void updateName(final String name) {
|
||||
delegate.updateName(name);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +103,7 @@ public class DelegatingSpan implements Span {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void end(EndSpanOptions endOptions) {
|
||||
public void end(final EndSpanOptions endOptions) {
|
||||
delegate.end(endOptions);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,14 @@ public abstract class HttpServerTypedTracer<
|
|||
extends ServerTypedTracer<T, REQUEST, RESPONSE> {
|
||||
|
||||
@Override
|
||||
protected Span.Builder buildSpan(REQUEST request, Span.Builder spanBuilder) {
|
||||
SpanContext extract = tracer.getHttpTextFormat().extract(request, getGetter());
|
||||
protected Span.Builder buildSpan(final REQUEST request, final Span.Builder spanBuilder) {
|
||||
final SpanContext extract = tracer.getHttpTextFormat().extract(request, getGetter());
|
||||
if (extract.isValid()) {
|
||||
spanBuilder.setParent(extract);
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
return super.buildSpan(request, spanBuilder);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class SampleHttpClientTypedTracer
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getSpanName(String o) {
|
||||
protected String getSpanName(final String o) {
|
||||
return "test-span";
|
||||
}
|
||||
|
||||
|
|
@ -40,12 +40,12 @@ public class SampleHttpClientTypedTracer
|
|||
protected HttpTextFormat.Setter<String> getSetter() {
|
||||
return new HttpTextFormat.Setter<String>() {
|
||||
@Override
|
||||
public void put(String carrier, String key, String value) {}
|
||||
public void set(final String carrier, final String key, final String value) {}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SampleHttpClientTypedSpan wrapSpan(Span span) {
|
||||
protected SampleHttpClientTypedSpan wrapSpan(final Span span) {
|
||||
return new SampleHttpClientTypedSpan(span);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit;
|
|||
public class Worker {
|
||||
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
/** Simulate work for the give number of milliseconds. */
|
||||
public static void doWork(final long workTimeMS) {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class JettyPerftest {
|
|||
private static final ServletContextHandler servletContext = new ServletContextHandler();
|
||||
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
servletContext.addServlet(PerfServlet.class, PATH);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import play.api.mvc._
|
|||
* application's work page which does busy wait to simulate some work
|
||||
*/
|
||||
class HomeController @Inject()(cc: ControllerComponents) extends AbstractController(cc) {
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerFactory.get("io.opentelemetry.auto")
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerProvider.get("io.opentelemetry.auto")
|
||||
|
||||
/**
|
||||
* Create an Action to perform busy wait
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import io.opentelemetry.trace.Tracer
|
|||
import java.util.concurrent.TimeUnit
|
||||
|
||||
object Worker {
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerFactory.get("io.opentelemetry.auto")
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerProvider.get("io.opentelemetry.auto")
|
||||
|
||||
def doWork(workTimeMS: Long) = {
|
||||
val span = TRACER.spanBuilder("work").startSpan()
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
apply from: "${rootDir}/gradle/java.gradle"
|
||||
|
||||
dependencies {
|
||||
jmh group: 'io.opentelemetry', name: 'opentelemetry-api', version: '0.2.0'
|
||||
jmh group: 'io.opentelemetry', name: 'opentelemetry-api', version: '0.2.4'
|
||||
jmh deps.bytebuddyagent
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.opentelemetry.trace.Tracer;
|
|||
|
||||
public class TracedClass extends UntracedClass {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
@Override
|
||||
public void f() {
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@
|
|||
*/
|
||||
package io.opentelemetry.auto.exporters.loggingexporter;
|
||||
|
||||
import io.opentelemetry.sdk.trace.SpanData;
|
||||
import io.opentelemetry.common.AttributeValue;
|
||||
import io.opentelemetry.sdk.trace.data.SpanData;
|
||||
import io.opentelemetry.sdk.trace.export.SpanExporter;
|
||||
import io.opentelemetry.trace.AttributeValue;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ def spockGroovyVer = groovyVer.replaceAll(/\.\d+$/, '')
|
|||
|
||||
ext {
|
||||
versions = [
|
||||
opentelemetry: '0.2.0',
|
||||
opentelemetry: '0.2.4',
|
||||
|
||||
slf4j : "1.7.29",
|
||||
guava : "20.0", // Last version to support Java 7
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
|
||||
public class EchoServiceImpl implements EchoService {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
@Override
|
||||
public ServiceCall<Source<String, NotUsed>, Source<String, NotUsed>> echo() {
|
||||
|
|
@ -39,7 +39,7 @@ public class EchoServiceImpl implements EchoService {
|
|||
}
|
||||
|
||||
public List<String> tracedMethod() {
|
||||
Span span = TRACER.spanBuilder("tracedMethod").startSpan();
|
||||
final Span span = TRACER.spanBuilder("tracedMethod").startSpan();
|
||||
try {
|
||||
return java.util.Arrays.asList("msg1", "msg2", "msg3");
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class AkkaHttpClientDecorator extends HttpClientDecorator<HttpRequest, Ht
|
|||
public static final AkkaHttpClientDecorator DECORATE = new AkkaHttpClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.akka-http-10.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.akka-http-10.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ public final class AkkaHttpClientInstrumentation extends Instrumenter.Default {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void put(final HttpRequest carrier, final String key, final String value) {
|
||||
public void set(final HttpRequest carrier, final String key, final String value) {
|
||||
// It looks like this cast is only needed in Java, Scala would have figured it out
|
||||
request = (HttpRequest) request.addHeader(RawHeader.create(key, value));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class AkkaHttpServerDecorator
|
|||
public static final AkkaHttpServerDecorator DECORATE = new AkkaHttpServerDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.akka-http-10.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.akka-http-10.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -110,11 +110,12 @@ public final class AkkaHttpServerInstrumentation extends Instrumenter.Default {
|
|||
public static SpanWithScope createSpan(final HttpRequest request) {
|
||||
final Span.Builder spanBuilder =
|
||||
TRACER.spanBuilder(DECORATE.spanNameForRequest(request)).setSpanKind(SERVER);
|
||||
try {
|
||||
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(request, GETTER);
|
||||
if (extractedContext.isValid()) {
|
||||
spanBuilder.setParent(extractedContext);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context. We should treat this as a root span.
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
final Span span = spanBuilder.startSpan();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class ApacheHttpAsyncClientDecorator extends HttpClientDecorator<HttpRequ
|
|||
new ApacheHttpAsyncClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.apache-httpasyncclient-4.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.apache-httpasyncclient-4.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class HttpHeadersInjectAdapter implements HttpTextFormat.Setter<HttpReque
|
|||
public static final HttpHeadersInjectAdapter SETTER = new HttpHeadersInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final HttpRequest carrier, final String key, final String value) {
|
||||
public void set(final HttpRequest carrier, final String key, final String value) {
|
||||
carrier.setHeader(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class CommonsHttpClientDecorator extends HttpClientDecorator<HttpMethod,
|
|||
public static final CommonsHttpClientDecorator DECORATE = new CommonsHttpClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.apache-httpclient-2.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.apache-httpclient-2.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class HttpHeadersInjectAdapter implements HttpTextFormat.Setter<HttpMetho
|
|||
public static final HttpHeadersInjectAdapter SETTER = new HttpHeadersInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final HttpMethod carrier, final String key, final String value) {
|
||||
public void set(final HttpMethod carrier, final String key, final String value) {
|
||||
carrier.setRequestHeader(new Header(key, value));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ApacheHttpClientDecorator extends HttpClientDecorator<HttpUriReques
|
|||
public static final ApacheHttpClientDecorator DECORATE = new ApacheHttpClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.apache-httpclient-4.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.apache-httpclient-4.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class HttpHeadersInjectAdapter implements HttpTextFormat.Setter<HttpUriRe
|
|||
public static final HttpHeadersInjectAdapter SETTER = new HttpHeadersInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final HttpUriRequest carrier, final String key, final String value) {
|
||||
public void set(final HttpUriRequest carrier, final String key, final String value) {
|
||||
carrier.addHeader(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,26 +61,11 @@ public class AwsSdkClientDecorator extends HttpClientDecorator<Request, Response
|
|||
if (contextStore != null) {
|
||||
final RequestMeta requestMeta = contextStore.get(originalRequest);
|
||||
if (requestMeta != null) {
|
||||
final String bucketName = requestMeta.getBucketName();
|
||||
if (bucketName != null) {
|
||||
span.setAttribute("aws.bucket.name", bucketName);
|
||||
}
|
||||
final String queueUrl = requestMeta.getQueueUrl();
|
||||
if (queueUrl != null) {
|
||||
span.setAttribute("aws.queue.url", queueUrl);
|
||||
}
|
||||
final String queueName = requestMeta.getQueueName();
|
||||
if (queueName != null) {
|
||||
span.setAttribute("aws.queue.name", queueName);
|
||||
}
|
||||
final String streamName = requestMeta.getStreamName();
|
||||
if (streamName != null) {
|
||||
span.setAttribute("aws.stream.name", streamName);
|
||||
}
|
||||
final String tableName = requestMeta.getTableName();
|
||||
if (tableName != null) {
|
||||
span.setAttribute("aws.table.name", tableName);
|
||||
}
|
||||
span.setAttribute("aws.bucket.name", requestMeta.getBucketName());
|
||||
span.setAttribute("aws.queue.url", requestMeta.getQueueUrl());
|
||||
span.setAttribute("aws.queue.name", requestMeta.getQueueName());
|
||||
span.setAttribute("aws.stream.name", requestMeta.getStreamName());
|
||||
span.setAttribute("aws.table.name", requestMeta.getTableName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import io.opentelemetry.trace.Tracer;
|
|||
/** Tracing Request Handler */
|
||||
public class TracingRequestHandler extends RequestHandler2 {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.aws-sdk-1.11");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.aws-sdk-1.11");
|
||||
|
||||
private final AwsSdkClientDecorator decorate;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class AwsSdkClientDecorator extends HttpClientDecorator<SdkHttpRequest, S
|
|||
public static final AwsSdkClientDecorator DECORATE = new AwsSdkClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.aws-sdk-2.2");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.aws-sdk-2.2");
|
||||
|
||||
static final String COMPONENT_NAME = "java-aws-sdk";
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import java.util.concurrent.Executors;
|
|||
|
||||
public class TracingSession implements Session {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.cassandra-3.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.cassandra-3.0");
|
||||
|
||||
private final ExecutorService executorService = Executors.newCachedThreadPool();
|
||||
private final Session session;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import org.cassandraunit.utils.EmbeddedCassandraServerHelper
|
||||
import spock.lang.Shared
|
||||
|
||||
|
|
|
|||
|
|
@ -51,11 +51,7 @@ public class CouchbaseOnSubscribe extends TracedOnSubscribe {
|
|||
|
||||
span.setAttribute(MoreTags.RESOURCE_NAME, resourceName);
|
||||
|
||||
if (bucket != null) {
|
||||
span.setAttribute(Tags.DB_INSTANCE, bucket);
|
||||
}
|
||||
if (query != null) {
|
||||
span.setAttribute(Tags.DB_STATEMENT, query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import io.opentelemetry.auto.instrumentation.api.Tags
|
|||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.utils.PortUtils
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import spock.lang.Shared
|
||||
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class CouchbaseCoreInstrumentation extends Instrumenter.Default {
|
|||
|
||||
public static class CouchbaseCoreAdvice {
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.couchbase-2.6");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.couchbase-2.6");
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
public static void addOperationIdToSpan(@Advice.Argument(0) final CouchbaseRequest request) {
|
||||
|
|
@ -88,11 +88,9 @@ public class CouchbaseCoreInstrumentation extends Instrumenter.Default {
|
|||
span = parentSpan;
|
||||
contextStore.put(request, span);
|
||||
|
||||
if (request.operationId() != null) {
|
||||
span.setAttribute("couchbase.operation_id", request.operationId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
|
||||
import static io.opentelemetry.trace.Span.Kind.CLIENT
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import io.opentelemetry.auto.instrumentation.jaxrs2.JaxRsAnnotationsDecorator
|
|||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.auto.test.utils.PortUtils
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import org.eclipse.jetty.servlet.ServletHandler
|
||||
import spock.lang.Retry
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
|
|||
|
||||
public static class RenderAdvice {
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.dropwizard-views-0.7");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.dropwizard-views-0.7");
|
||||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static SpanWithScope onEnter(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class ElasticsearchRestClientDecorator extends DatabaseClientDecorator {
|
|||
new ElasticsearchRestClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.elasticsearch");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.elasticsearch");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ElasticsearchTransportClientDecorator extends DatabaseClientDecorat
|
|||
new ElasticsearchTransportClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.elasticsearch");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.elasticsearch");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -61,10 +61,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
|||
if (request instanceof DocumentRequest) {
|
||||
final DocumentRequest req = (DocumentRequest) request;
|
||||
span.setAttribute("elasticsearch.request.write.type", req.type());
|
||||
final String routing = req.routing();
|
||||
if (routing != null) {
|
||||
span.setAttribute("elasticsearch.request.write.routing", routing);
|
||||
}
|
||||
span.setAttribute("elasticsearch.request.write.routing", req.routing());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,10 +63,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
|||
if (request instanceof DocumentRequest) {
|
||||
final DocumentRequest req = (DocumentRequest) request;
|
||||
span.setAttribute("elasticsearch.request.write.type", req.type());
|
||||
final String routing = req.routing();
|
||||
if (routing != null) {
|
||||
span.setAttribute("elasticsearch.request.write.routing", routing);
|
||||
}
|
||||
span.setAttribute("elasticsearch.request.write.routing", req.routing());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,10 +63,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
|||
if (request instanceof DocWriteRequest) {
|
||||
final DocWriteRequest req = (DocWriteRequest) request;
|
||||
span.setAttribute("elasticsearch.request.write.type", req.type());
|
||||
final String routing = req.routing();
|
||||
if (routing != null) {
|
||||
span.setAttribute("elasticsearch.request.write.routing", routing);
|
||||
}
|
||||
span.setAttribute("elasticsearch.request.write.routing", req.routing());
|
||||
span.setAttribute("elasticsearch.request.write.version", req.version());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package springdata
|
|||
import io.opentelemetry.auto.instrumentation.api.MoreTags
|
||||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
||||
import spock.lang.Shared
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,7 @@ public class TransportActionListener<T extends ActionResponse> implements Action
|
|||
if (request instanceof DocWriteRequest) {
|
||||
final DocWriteRequest req = (DocWriteRequest) request;
|
||||
span.setAttribute("elasticsearch.request.write.type", req.type());
|
||||
final String routing = req.routing();
|
||||
if (routing != null) {
|
||||
span.setAttribute("elasticsearch.request.write.routing", routing);
|
||||
}
|
||||
span.setAttribute("elasticsearch.request.write.routing", req.routing());
|
||||
span.setAttribute("elasticsearch.request.write.version", req.version());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class FinatraDecorator extends HttpServerDecorator<Request, Request, Resp
|
|||
public static final FinatraDecorator DECORATE = new FinatraDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.finatra-2.9");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.finatra-2.9");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import io.opentelemetry.auto.instrumentation.api.Tags
|
|||
import io.opentelemetry.auto.instrumentation.finatra.FinatraDecorator
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.auto.test.base.HttpServerTest
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class GeodeDecorator extends DatabaseClientDecorator<Region> {
|
|||
public static GeodeDecorator DECORATE = new GeodeDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.geode-1.7");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.geode-1.7");
|
||||
|
||||
@Override
|
||||
protected String dbType() {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class GoogleHttpClientDecorator extends HttpClientDecorator<HttpRequest,
|
|||
public static final GoogleHttpClientDecorator DECORATE = new GoogleHttpClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.google-http-client-1.19");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.google-http-client-1.19");
|
||||
|
||||
@Override
|
||||
protected String method(final HttpRequest httpRequest) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class HeadersInjectAdapter implements HttpTextFormat.Setter<HttpRequest>
|
|||
public static final HeadersInjectAdapter SETTER = new HeadersInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final HttpRequest carrier, final String key, final String value) {
|
||||
public void set(final HttpRequest carrier, final String key, final String value) {
|
||||
carrier.getHeaders().put(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class GrizzlyDecorator extends HttpServerDecorator<Request, Request, Resp
|
|||
public static final GrizzlyDecorator DECORATE = new GrizzlyDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.grizzly-2.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.grizzly-2.0");
|
||||
|
||||
@Override
|
||||
protected String method(final Request request) {
|
||||
|
|
|
|||
|
|
@ -84,11 +84,12 @@ public class GrizzlyHttpHandlerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
final Span.Builder spanBuilder =
|
||||
TRACER.spanBuilder(DECORATE.spanNameForRequest(request)).setSpanKind(SERVER);
|
||||
try {
|
||||
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(request, GETTER);
|
||||
if (extractedContext.isValid()) {
|
||||
spanBuilder.setParent(extractedContext);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context. We should treat this as a root span.
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
final Span span = spanBuilder.startSpan();
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import io.opentelemetry.trace.Tracer;
|
|||
public class GrpcClientDecorator extends ClientDecorator {
|
||||
public static final GrpcClientDecorator DECORATE = new GrpcClientDecorator();
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.grpc-1.5");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.grpc-1.5");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
@ -39,9 +39,7 @@ public class GrpcClientDecorator extends ClientDecorator {
|
|||
public Span onClose(final Span span, final io.grpc.Status status) {
|
||||
|
||||
span.setAttribute("status.code", status.getCode().name());
|
||||
if (status.getDescription() != null) {
|
||||
span.setAttribute("status.description", status.getDescription());
|
||||
}
|
||||
|
||||
onError(span, status.getCause());
|
||||
if (!status.isOk()) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class GrpcInjectAdapter implements HttpTextFormat.Setter<Metadata>
|
|||
public static final GrpcInjectAdapter SETTER = new GrpcInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final Metadata carrier, final String key, final String value) {
|
||||
public void set(final Metadata carrier, final String key, final String value) {
|
||||
carrier.put(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER), value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ import io.grpc.Metadata;
|
|||
import io.grpc.MethodDescriptor;
|
||||
import io.grpc.Status;
|
||||
import io.opentelemetry.auto.instrumentation.grpc.common.GrpcHelper;
|
||||
import io.opentelemetry.common.AttributeValue;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.trace.AttributeValue;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import io.opentelemetry.trace.Tracer;
|
|||
public class GrpcServerDecorator extends ServerDecorator {
|
||||
public static final GrpcServerDecorator DECORATE = new GrpcServerDecorator();
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.grpc-1.5");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.grpc-1.5");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
@ -34,9 +34,7 @@ public class GrpcServerDecorator extends ServerDecorator {
|
|||
public Span onClose(final Span span, final Status status) {
|
||||
|
||||
span.setAttribute("status.code", status.getCode().name());
|
||||
if (status.getDescription() != null) {
|
||||
span.setAttribute("status.description", status.getDescription());
|
||||
}
|
||||
onError(span, status.getCause());
|
||||
if (!status.isOk()) {
|
||||
span.setStatus(io.opentelemetry.trace.Status.UNKNOWN);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ import io.grpc.ServerCallHandler;
|
|||
import io.grpc.ServerInterceptor;
|
||||
import io.grpc.Status;
|
||||
import io.opentelemetry.auto.instrumentation.grpc.common.GrpcHelper;
|
||||
import io.opentelemetry.common.AttributeValue;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.trace.AttributeValue;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
@ -53,11 +53,12 @@ public class TracingServerInterceptor implements ServerInterceptor {
|
|||
|
||||
final String methodName = call.getMethodDescriptor().getFullMethodName();
|
||||
final Span.Builder spanBuilder = TRACER.spanBuilder(methodName).setSpanKind(SERVER);
|
||||
try {
|
||||
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(headers, GETTER);
|
||||
if (extractedContext.isValid()) {
|
||||
spanBuilder.setParent(extractedContext);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context. We should treat this as a root span.
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
final Span span = spanBuilder.startSpan();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class HibernateDecorator extends OrmClientDecorator {
|
|||
// TODO use tracer names *.hibernate-3.3, *.hibernate-4.0, *.hibernate-4.3 respectively in each
|
||||
// module
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.hibernate");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.hibernate");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class HeadersInjectAdapter implements HttpTextFormat.Setter<HttpURLConnec
|
|||
public static final HeadersInjectAdapter SETTER = new HeadersInjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final HttpURLConnection carrier, final String key, final String value) {
|
||||
public void set(final HttpURLConnection carrier, final String key, final String value) {
|
||||
carrier.setRequestProperty(key, value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
public class HttpUrlConnectionDecorator extends HttpClientDecorator<HttpURLConnection, Integer> {
|
||||
public static final HttpUrlConnectionDecorator DECORATE = new HttpUrlConnectionDecorator();
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.http-url-connection");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.http-url-connection");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,9 @@ shadowJar {
|
|||
|
||||
// relocate OpenTelemetry API usage
|
||||
relocate "io.opentelemetry.OpenTelemetry", "io.opentelemetry.auto.shaded.io.opentelemetry.OpenTelemetry"
|
||||
relocate "io.opentelemetry.common", "io.opentelemetry.auto.shaded.io.opentelemetry.common"
|
||||
relocate "io.opentelemetry.context", "io.opentelemetry.auto.shaded.io.opentelemetry.context"
|
||||
relocate "io.opentelemetry.correlationcontext", "io.opentelemetry.auto.shaded.io.opentelemetry.correlationcontext"
|
||||
relocate "io.opentelemetry.distributedcontext", "io.opentelemetry.auto.shaded.io.opentelemetry.distributedcontext"
|
||||
relocate "io.opentelemetry.internal", "io.opentelemetry.auto.shaded.io.opentelemetry.internal"
|
||||
relocate "io.opentelemetry.metrics", "io.opentelemetry.auto.shaded.io.opentelemetry.metrics"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
import akka.dispatch.forkjoin.ForkJoinPool
|
||||
import akka.dispatch.forkjoin.ForkJoinTask
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import spock.lang.Shared
|
||||
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
public class AkkaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
private final AtomicBoolean blockThread;
|
||||
private final boolean doTraceableWork;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import scala.concurrent.duration._
|
|||
|
||||
// ! == send-message
|
||||
object AkkaActors {
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerFactory.get("io.opentelemetry.auto")
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerProvider.get("io.opentelemetry.auto")
|
||||
|
||||
val system: ActorSystem = ActorSystem("helloAkka")
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import kotlinx.coroutines.selects.select
|
|||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class KotlinCoroutineTests(private val dispatcher: CoroutineDispatcher) {
|
||||
val tracer: Tracer = OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto")
|
||||
val tracer: Tracer = OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto")
|
||||
|
||||
fun tracedAcrossChannels() = runTest {
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import scala.concurrent.forkjoin.ForkJoinPool
|
||||
import scala.concurrent.forkjoin.ForkJoinTask
|
||||
import spock.lang.Shared
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import scala.concurrent.forkjoin.ForkJoinTask;
|
|||
|
||||
public class ScalaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
private final AtomicBoolean blockThread;
|
||||
private final boolean doTraceableWork;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import scala.concurrent.duration._
|
|||
import scala.concurrent.{Await, Future, Promise}
|
||||
|
||||
class ScalaConcurrentTests {
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerFactory.get("io.opentelemetry.auto")
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerProvider.get("io.opentelemetry.auto")
|
||||
|
||||
/**
|
||||
* @return Number of expected spans in the trace
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import scala.concurrent.duration.Duration
|
|||
import scala.concurrent.{Await, Future}
|
||||
|
||||
class SlickUtils {
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerFactory.get("io.opentelemetry.auto")
|
||||
val TRACER: Tracer = OpenTelemetry.getTracerProvider.get("io.opentelemetry.auto")
|
||||
|
||||
import SlickUtils._
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.CallableW
|
|||
import io.opentelemetry.auto.bootstrap.instrumentation.java.concurrent.RunnableWrapper
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.auto.test.utils.ConfigUtils
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import spock.lang.Shared
|
||||
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
public class JavaAsyncChild extends ForkJoinTask implements Runnable, Callable {
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto");
|
||||
|
||||
private final AtomicBoolean blockThread;
|
||||
private final boolean doTraceableWork;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
public class JavaUtilLoggingSpans {
|
||||
|
||||
private static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.java-util-logging");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.java-util-logging");
|
||||
|
||||
private static final Formatter FORMATTER = new AccessibleFormatter();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class InjectAdapter implements HttpTextFormat.Setter<MultivaluedMap
|
|||
public static final InjectAdapter SETTER = new InjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final MultivaluedMap headers, final String key, final String value) {
|
||||
public void set(final MultivaluedMap headers, final String key, final String value) {
|
||||
// Don't allow duplicates.
|
||||
headers.putSingle(key, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class JaxRsClientV1Decorator extends HttpClientDecorator<ClientRequest, C
|
|||
public static final JaxRsClientV1Decorator DECORATE = new JaxRsClientV1Decorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jaxrs-client-1.1");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jaxrs-client-1.1");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class InjectAdapter implements HttpTextFormat.Setter<MultivaluedMap
|
|||
public static final InjectAdapter SETTER = new InjectAdapter();
|
||||
|
||||
@Override
|
||||
public void put(final MultivaluedMap headers, final String key, final String value) {
|
||||
public void set(final MultivaluedMap headers, final String key, final String value) {
|
||||
// Don't allow duplicates.
|
||||
headers.putSingle(key, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class JaxRsClientDecorator
|
|||
public static final JaxRsClientDecorator DECORATE = new JaxRsClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jaxrs-client-2.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jaxrs-client-2.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
private final WeakMap<Class, Map<Method, String>> resourceNames = newWeakMap();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jaxrs-1.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jaxrs-1.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class JaxRsAnnotationsDecorator extends BaseDecorator {
|
|||
public static final JaxRsAnnotationsDecorator DECORATE = new JaxRsAnnotationsDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jaxrs-2.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jaxrs-2.0");
|
||||
|
||||
private final WeakMap<Class, Map<Method, String>> resourceNames = newWeakMap();
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public class DataSourceDecorator extends BaseDecorator {
|
|||
public static final DataSourceDecorator DECORATE = new DataSourceDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jdbc");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jdbc");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class JDBCDecorator extends DatabaseClientDecorator<DBInfo> {
|
|||
public static final JDBCDecorator DECORATE = new JDBCDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jdbc");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jdbc");
|
||||
|
||||
private static final String DB_QUERY = "DB Query";
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class JedisClientDecorator extends DatabaseClientDecorator<Protocol.Comma
|
|||
public static final JedisClientDecorator DECORATE = new JedisClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jedis-1.4");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jedis-1.4");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class JedisClientDecorator extends DatabaseClientDecorator<ProtocolComman
|
|||
public static final JedisClientDecorator DECORATE = new JedisClientDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jedis-1.4");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jedis-1.4");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class JettyDecorator
|
|||
public static final JettyDecorator DECORATE = new JettyDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jetty-8.0");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jetty-8.0");
|
||||
|
||||
@Override
|
||||
protected String getComponentName() {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import io.opentelemetry.auto.instrumentation.api.SpanWithScope;
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags;
|
||||
import io.opentelemetry.trace.Span;
|
||||
import io.opentelemetry.trace.SpanContext;
|
||||
import java.security.Principal;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
|
@ -44,11 +45,12 @@ public class JettyHandlerAdvice {
|
|||
|
||||
final String resourceName = req.getMethod() + " " + source.getClass().getName();
|
||||
final Span.Builder spanBuilder = TRACER.spanBuilder(resourceName).setSpanKind(SERVER);
|
||||
try {
|
||||
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(req, GETTER);
|
||||
if (extractedContext.isValid()) {
|
||||
spanBuilder.setParent(extractedContext);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context. We should treat this as a root span.
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
final Span span = spanBuilder.startSpan();
|
||||
|
|
@ -75,8 +77,9 @@ public class JettyHandlerAdvice {
|
|||
return;
|
||||
}
|
||||
final Span span = spanWithScope.getSpan();
|
||||
if (req.getUserPrincipal() != null) {
|
||||
span.setAttribute(MoreTags.USER_NAME, req.getUserPrincipal().getName());
|
||||
final Principal userPrincipal = req.getUserPrincipal();
|
||||
if (userPrincipal != null) {
|
||||
span.setAttribute(MoreTags.USER_NAME, userPrincipal.getName());
|
||||
}
|
||||
if (throwable != null) {
|
||||
DECORATE.onResponse(span, resp);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import io.opentelemetry.auto.instrumentation.api.MoreTags
|
|||
import io.opentelemetry.auto.instrumentation.api.Tags
|
||||
import io.opentelemetry.auto.test.AgentTestRunner
|
||||
import io.opentelemetry.auto.test.asserts.TraceAssert
|
||||
import io.opentelemetry.sdk.trace.SpanData
|
||||
import io.opentelemetry.sdk.trace.data.SpanData
|
||||
import org.hornetq.api.core.TransportConfiguration
|
||||
import org.hornetq.api.core.client.HornetQClient
|
||||
import org.hornetq.api.jms.HornetQJMSClient
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class JMSDecorator extends ClientDecorator {
|
|||
public static final JMSDecorator DECORATE = new JMSDecorator();
|
||||
|
||||
public static final Tracer TRACER =
|
||||
OpenTelemetry.getTracerFactory().get("io.opentelemetry.auto.jms-1.1");
|
||||
OpenTelemetry.getTracerProvider().get("io.opentelemetry.auto.jms-1.1");
|
||||
|
||||
@Override
|
||||
protected String service() {
|
||||
|
|
|
|||
|
|
@ -106,13 +106,8 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
|
|||
.setSpanKind(CLIENT)
|
||||
.setStartTimestamp(TimeUnit.MILLISECONDS.toNanos(startTime));
|
||||
if (message != null) {
|
||||
SpanContext spanContext = null;
|
||||
try {
|
||||
spanContext = TRACER.getHttpTextFormat().extract(message, GETTER);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context
|
||||
}
|
||||
if (spanContext != null) {
|
||||
final SpanContext spanContext = TRACER.getHttpTextFormat().extract(message, GETTER);
|
||||
if (spanContext.isValid()) {
|
||||
spanBuilder.addLink(spanContext);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,11 +81,12 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
final Span.Builder spanBuilder =
|
||||
TRACER.spanBuilder(DECORATE.spanNameForConsumer(message)).setSpanKind(CONSUMER);
|
||||
try {
|
||||
final SpanContext extractedContext = TRACER.getHttpTextFormat().extract(message, GETTER);
|
||||
if (extractedContext.isValid()) {
|
||||
spanBuilder.setParent(extractedContext);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Couldn't extract a context. We should treat this as a root span.
|
||||
} else {
|
||||
// explicitly setting "no parent" in case a span was propagated to this thread
|
||||
// by the java-concurrent instrumentation when the thread was started
|
||||
spanBuilder.setNoParent();
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue