Assume parent span is netty

This commit is contained in:
Laplie Anderson 2020-01-30 18:21:49 -05:00
parent 37a279069b
commit ed12af6994
1 changed files with 8 additions and 16 deletions

View File

@ -73,22 +73,15 @@ public class FinatraInstrumentation extends Instrumenter.Default {
@Advice.FieldValue("clazz") final Class clazz, @Advice.FieldValue("clazz") final Class clazz,
@Advice.Origin final Method method) { @Advice.Origin final Method method) {
// Update the parent "netty.request"
final AgentSpan parent = activeSpan(); final AgentSpan parent = activeSpan();
parent.setTag(DDTags.RESOURCE_NAME, request.method().name() + " " + path);
parent.setTag(Tags.COMPONENT, "finatra");
parent.setSpanName("finatra.request");
final AgentSpan span = startSpan("finatra.request"); final AgentSpan span = startSpan("finatra.controller");
DECORATE.afterStart(span); DECORATE.afterStart(span);
span.setTag(DDTags.RESOURCE_NAME, DECORATE.spanNameForClass(clazz));
if (parent != null && "netty.request".equals(parent.getSpanName())) {
parent.setTag(DDTags.RESOURCE_NAME, request.method().name() + " " + path);
parent.setTag(Tags.COMPONENT, "finatra");
parent.setSpanName("finatra.request");
span.setSpanName("finatra.controller");
span.setTag(DDTags.RESOURCE_NAME, DECORATE.spanNameForClass(clazz));
} else {
DECORATE.onConnection(span, request);
DECORATE.onRequest(span, request);
}
final AgentScope scope = activateSpan(span, false); final AgentScope scope = activateSpan(span, false);
scope.setAsyncPropagation(true); scope.setAsyncPropagation(true);
@ -127,9 +120,8 @@ public class FinatraInstrumentation extends Instrumenter.Default {
@Override @Override
public void onSuccess(final Response response) { public void onSuccess(final Response response) {
if ("finatra.request".equals(scope.span().getSpanName())) { // Don't use DECORATE.onResponse because this is the controller span
DECORATE.onResponse(scope.span(), response); if (Config.get().getHttpServerErrorStatuses().contains(DECORATE.status(response))) {
} else if (Config.get().getHttpServerErrorStatuses().contains(DECORATE.status(response))) {
scope.span().setError(true); scope.span().setError(true);
} }