Better span names for netty (#247)
This commit is contained in:
parent
5089a05c44
commit
11566b7e5e
|
@ -17,6 +17,7 @@ package io.opentelemetry.auto.instrumentation.netty40;
|
||||||
|
|
||||||
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
|
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
|
||||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
|
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
|
||||||
|
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
@ -104,7 +105,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
||||||
final Scope parentScope = NettyHttpServerDecorator.TRACER.withSpan(parentSpan);
|
final Scope parentScope = NettyHttpServerDecorator.TRACER.withSpan(parentSpan);
|
||||||
|
|
||||||
final Span errorSpan =
|
final Span errorSpan =
|
||||||
NettyHttpServerDecorator.TRACER.spanBuilder("netty.connect").startSpan();
|
NettyHttpServerDecorator.TRACER.spanBuilder("CONNECT").setSpanKind(CLIENT).startSpan();
|
||||||
errorSpan.setAttribute(Tags.COMPONENT, "netty");
|
errorSpan.setAttribute(Tags.COMPONENT, "netty");
|
||||||
try (final Scope scope = NettyHttpServerDecorator.TRACER.withSpan(errorSpan)) {
|
try (final Scope scope = NettyHttpServerDecorator.TRACER.withSpan(errorSpan)) {
|
||||||
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
|
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Netty40ClientTest extends HttpClientTest {
|
||||||
// for up to a total of 10 seconds (default connection time limit)
|
// for up to a total of 10 seconds (default connection time limit)
|
||||||
for (def i = 1; i < size; i++) {
|
for (def i = 1; i < size; i++) {
|
||||||
span(i) {
|
span(i) {
|
||||||
operationName "netty.connect"
|
operationName "CONNECT"
|
||||||
childOf span(0)
|
childOf span(0)
|
||||||
errored true
|
errored true
|
||||||
tags {
|
tags {
|
||||||
|
|
|
@ -17,6 +17,7 @@ package io.opentelemetry.auto.instrumentation.netty41;
|
||||||
|
|
||||||
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
|
import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
|
||||||
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
|
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
|
||||||
|
import static io.opentelemetry.trace.Span.Kind.CLIENT;
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
|
@ -104,7 +105,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
||||||
final Scope parentScope = NettyHttpServerDecorator.TRACER.withSpan(parentSpan);
|
final Scope parentScope = NettyHttpServerDecorator.TRACER.withSpan(parentSpan);
|
||||||
|
|
||||||
final Span errorSpan =
|
final Span errorSpan =
|
||||||
NettyHttpServerDecorator.TRACER.spanBuilder("netty.connect").startSpan();
|
NettyHttpServerDecorator.TRACER.spanBuilder("CONNECT").setSpanKind(CLIENT).startSpan();
|
||||||
errorSpan.setAttribute(Tags.COMPONENT, "netty");
|
errorSpan.setAttribute(Tags.COMPONENT, "netty");
|
||||||
try (final Scope scope = NettyHttpServerDecorator.TRACER.withSpan(errorSpan)) {
|
try (final Scope scope = NettyHttpServerDecorator.TRACER.withSpan(errorSpan)) {
|
||||||
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
|
NettyHttpServerDecorator.DECORATE.onError(errorSpan, cause);
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Netty41ClientTest extends HttpClientTest {
|
||||||
// for up to a total of 10 seconds (default connection time limit)
|
// for up to a total of 10 seconds (default connection time limit)
|
||||||
for (def i = 1; i < size; i++) {
|
for (def i = 1; i < size; i++) {
|
||||||
span(i) {
|
span(i) {
|
||||||
operationName "netty.connect"
|
operationName "CONNECT"
|
||||||
childOf span(0)
|
childOf span(0)
|
||||||
errored true
|
errored true
|
||||||
tags {
|
tags {
|
||||||
|
|
Loading…
Reference in New Issue