From 0478643356ca669dd86ae04e89edd3d59c618cb3 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 15 Jul 2022 13:52:07 +0200 Subject: [PATCH] Fixed wrong generics --- ...atingReceiverTracingObservationHandler.java | 12 ++++++------ ...agatingSenderTracingObservationHandler.java | 18 ++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingReceiverTracingObservationHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingReceiverTracingObservationHandler.java index eb4daedf..6d02215f 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingReceiverTracingObservationHandler.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingReceiverTracingObservationHandler.java @@ -28,7 +28,7 @@ * @author Marcin Grzejszczak * @since 1.0.0 */ -public class PropagatingReceiverTracingObservationHandler implements TracingObservationHandler> { +public class PropagatingReceiverTracingObservationHandler> implements TracingObservationHandler { private final Tracer tracer; @@ -46,7 +46,7 @@ public PropagatingReceiverTracingObservationHandler(Tracer tracer, Propagator pr } @Override - public void onStart(ReceiverContext context) { + public void onStart(T context) { Span.Builder extractedSpan = this.propagator.extract(context.getCarrier(), (carrier, key) -> context.getGetter().get(carrier, key)); extractedSpan.kind(Span.Kind.valueOf(context.getKind().name())); String name = context.getContextualName() != null ? context.getContextualName() : context.getName(); @@ -59,17 +59,17 @@ public void onStart(ReceiverContext context) { * @param builder span builder * @return span builder */ - public Span.Builder customizeExtractedSpan(ReceiverContext context, Span.Builder builder) { + public Span.Builder customizeExtractedSpan(T context, Span.Builder builder) { return builder; } @Override - public void onError(ReceiverContext context) { + public void onError(T context) { context.getError().ifPresent(throwable -> getRequiredSpan(context).error(throwable)); } @Override - public void onStop(ReceiverContext context) { + public void onStop(T context) { Span span = getRequiredSpan(context); tagSpan(context, span); customizeReceiverSpan(context, span); @@ -81,7 +81,7 @@ public void onStop(ReceiverContext context) { * @param context context * @param span span to customize */ - public void customizeReceiverSpan(ReceiverContext context, Span span) { + public void customizeReceiverSpan(T context, Span span) { } diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingSenderTracingObservationHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingSenderTracingObservationHandler.java index 0c2bc156..44519818 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingSenderTracingObservationHandler.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingSenderTracingObservationHandler.java @@ -28,7 +28,7 @@ * @author Marcin Grzejszczak * @since 1.0.0 */ -public class PropagatingSenderTracingObservationHandler implements TracingObservationHandler> { +public class PropagatingSenderTracingObservationHandler> implements TracingObservationHandler { private final Tracer tracer; private final Propagator propagator; @@ -45,7 +45,7 @@ public PropagatingSenderTracingObservationHandler(Tracer tracer, Propagator prop } @Override - public void onStart(SenderContext context) { + public void onStart(T context) { Span childSpan = createSenderSpan(context); this.propagator.inject(childSpan.context(), context.getCarrier(), (carrier, key, value) -> context.getSetter().set(carrier, key, value)); getTracingContext(context).setSpan(childSpan); @@ -56,23 +56,21 @@ public void onStart(SenderContext context) { * @param context context * @return sender span */ - public Span createSenderSpan(SenderContext context) { - // TODO: Rewrite this to use parent spans once they are done - TracingContext tracingContext = getTracingContext(context); - Span span = tracingContext.getSpan(); - Span senderSpan = span != null ? getTracer().nextSpan(span) : getTracer().nextSpan(); + public Span createSenderSpan(T context) { + Span parentSpan = getParentSpan(context); + Span senderSpan = parentSpan != null ? getTracer().nextSpan(parentSpan) : getTracer().nextSpan(); String name = context.getContextualName() != null ? context.getContextualName() : context.getName(); senderSpan.name(name); return senderSpan; } @Override - public void onError(SenderContext context) { + public void onError(T context) { context.getError().ifPresent(throwable -> getRequiredSpan(context).error(throwable)); } @Override - public void onStop(SenderContext context) { + public void onStop(T context) { Span span = getRequiredSpan(context); tagSpan(context, span); customizeSenderSpan(context, span); @@ -84,7 +82,7 @@ public void onStop(SenderContext context) { * @param context context * @param span span to customize */ - public void customizeSenderSpan(SenderContext context, Span span) { + public void customizeSenderSpan(T context, Span span) { }