Add decorator hooks during lifecycle of Publisher
This commit is contained in:
parent
ac11bba616
commit
23b8caa27c
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.instrumentation.springwebflux.client;
|
||||
|
||||
import static datadog.trace.instrumentation.springwebflux.client.SpringWebfluxHttpClientDecorator.DECORATE;
|
||||
|
||||
import io.opentracing.Scope;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.Tracer;
|
||||
|
@ -38,6 +40,7 @@ public class TracingClientResponseMono extends Mono<ClientResponse> {
|
|||
.asChildOf(parentSpan)
|
||||
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
|
||||
.start();
|
||||
DECORATE.afterStart(span);
|
||||
|
||||
try (final Scope scope = tracer.scopeManager().activate(span, false)) {
|
||||
final ClientRequest mutatedRequest =
|
||||
|
|
|
@ -44,6 +44,7 @@ public class TracingClientResponseSubscriber implements CoreSubscriber<ClientRes
|
|||
@Override
|
||||
public void cancel() {
|
||||
DECORATE.onCancel(span);
|
||||
DECORATE.beforeFinish(span);
|
||||
subscription.cancel();
|
||||
span.finish();
|
||||
}
|
||||
|
@ -73,6 +74,7 @@ public class TracingClientResponseSubscriber implements CoreSubscriber<ClientRes
|
|||
subscriber.onError(throwable);
|
||||
} finally {
|
||||
DECORATE.onError(span, throwable);
|
||||
DECORATE.beforeFinish(span);
|
||||
span.finish();
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +84,7 @@ public class TracingClientResponseSubscriber implements CoreSubscriber<ClientRes
|
|||
try {
|
||||
subscriber.onComplete();
|
||||
} finally {
|
||||
DECORATE.beforeFinish(span);
|
||||
span.finish();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue