diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientHandler.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientHandler.java index 8e44d877..d9bf348a 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientHandler.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientHandler.java @@ -18,8 +18,8 @@ import io.micrometer.common.util.internal.logging.InternalLogger; import io.micrometer.common.util.internal.logging.InternalLoggerFactory; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.TraceContext; import io.micrometer.tracing.http.HttpClientHandler; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientRequest.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientRequest.java index a1df15d8..516e5dc3 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientRequest.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientRequest.java @@ -19,7 +19,7 @@ import java.util.Collection; import java.util.Collections; -import io.micrometer.observation.transport.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientRequest; /** * Brave implementation of a {@link HttpClientRequest}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientResponse.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientResponse.java index 6af8ca46..77c9f616 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientResponse.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpClientResponse.java @@ -19,8 +19,8 @@ import java.util.Collection; import java.util.Collections; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; /** * Brave implementation of a {@link HttpClientResponse}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequest.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequest.java index bcf7da44..1749e600 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequest.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequest.java @@ -20,7 +20,7 @@ import java.util.Collections; import io.micrometer.observation.transport.Kind; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpRequest; /** * Brave implementation of a {@link HttpRequest}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequestParser.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequestParser.java index 8b2e8a3f..f5653100 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequestParser.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpRequestParser.java @@ -16,9 +16,9 @@ package io.micrometer.tracing.brave.bridge; -import io.micrometer.observation.transport.http.HttpRequest; import io.micrometer.tracing.SpanCustomizer; import io.micrometer.tracing.TraceContext; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.tracing.http.HttpRequestParser; /** diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponse.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponse.java index bbc034eb..fca91ce1 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponse.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponse.java @@ -20,8 +20,8 @@ import java.util.Collections; import io.micrometer.observation.transport.Kind; -import io.micrometer.observation.transport.http.HttpRequest; -import io.micrometer.observation.transport.http.HttpResponse; +import io.micrometer.tracing.http.HttpRequest; +import io.micrometer.tracing.http.HttpResponse; /** * Brave implementation of a {@link HttpResponse}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponseParser.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponseParser.java index 99430368..f0621889 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponseParser.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpResponseParser.java @@ -16,7 +16,7 @@ package io.micrometer.tracing.brave.bridge; -import io.micrometer.observation.transport.http.HttpResponse; +import io.micrometer.tracing.http.HttpResponse; import io.micrometer.tracing.SpanCustomizer; import io.micrometer.tracing.TraceContext; import io.micrometer.tracing.http.HttpResponseParser; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerHandler.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerHandler.java index d8a7e9f8..a5ca3da1 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerHandler.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerHandler.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.brave.bridge; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.http.HttpServerHandler; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerRequest.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerRequest.java index f9756de8..2c181ad9 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerRequest.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerRequest.java @@ -20,7 +20,7 @@ import java.util.Collections; import io.micrometer.observation.transport.Kind; -import io.micrometer.observation.transport.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerRequest; /** * Brave implementation of a {@link HttpServerRequest}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerResponse.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerResponse.java index c123b55b..1cdb04e1 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerResponse.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveHttpServerResponse.java @@ -20,8 +20,8 @@ import java.util.Collections; import io.micrometer.observation.transport.Kind; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; /** * Brave implementation of a {@link HttpServerResponse}. diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveSamplerFunction.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveSamplerFunction.java index 1665ba10..f780d7f1 100755 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveSamplerFunction.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/src/main/java/io/micrometer/tracing/brave/bridge/BraveSamplerFunction.java @@ -17,7 +17,7 @@ package io.micrometer.tracing.brave.bridge; import brave.sampler.SamplerFunctions; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.tracing.SamplerFunction; /** diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpClientAttributesGetter.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpClientAttributesGetter.java index a65352e9..2fee7029 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpClientAttributesGetter.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpClientAttributesGetter.java @@ -19,8 +19,8 @@ import java.util.Collections; import java.util.List; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; import io.micrometer.common.lang.Nullable; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpServerAttributesExtractor.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpServerAttributesExtractor.java index 83177170..051a200f 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpServerAttributesExtractor.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/DefaultHttpServerAttributesExtractor.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.List; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; import io.micrometer.common.lang.Nullable; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetClientAttributesExtractor.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetClientAttributesExtractor.java index 78199e18..db6903ce 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetClientAttributesExtractor.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetClientAttributesExtractor.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.otel.bridge; -import io.micrometer.observation.transport.http.HttpRequest; -import io.micrometer.observation.transport.http.HttpResponse; +import io.micrometer.tracing.http.HttpRequest; +import io.micrometer.tracing.http.HttpResponse; import io.micrometer.common.lang.Nullable; import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetServerAttributesExtractor.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetServerAttributesExtractor.java index dd5d290f..fe1f53f1 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetServerAttributesExtractor.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/HttpRequestNetServerAttributesExtractor.java @@ -16,7 +16,7 @@ package io.micrometer.tracing.otel.bridge; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.common.lang.Nullable; import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpClientHandler.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpClientHandler.java index 3359c5ab..8444a6bd 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpClientHandler.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpClientHandler.java @@ -19,9 +19,9 @@ import io.micrometer.common.lang.Nullable; import io.micrometer.common.util.internal.logging.InternalLogger; import io.micrometer.common.util.internal.logging.InternalLoggerFactory; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.Span; import io.micrometer.tracing.TraceContext; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpServerHandler.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpServerHandler.java index 3daf6026..5bc07e63 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpServerHandler.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/OtelHttpServerHandler.java @@ -22,8 +22,8 @@ import io.micrometer.common.util.internal.logging.InternalLogger; import io.micrometer.common.util.internal.logging.InternalLoggerFactory; import io.micrometer.common.lang.Nullable; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.http.HttpRequestParser; import io.micrometer.tracing.http.HttpResponseParser; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/PathAttributeExtractor.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/PathAttributeExtractor.java index 5116606c..85a80771 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/PathAttributeExtractor.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/PathAttributeExtractor.java @@ -17,8 +17,8 @@ package io.micrometer.tracing.otel.bridge; import io.micrometer.common.util.StringUtils; -import io.micrometer.observation.transport.http.HttpRequest; -import io.micrometer.observation.transport.http.HttpResponse; +import io.micrometer.tracing.http.HttpRequest; +import io.micrometer.tracing.http.HttpResponse; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/SkipPatternSampler.java b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/SkipPatternSampler.java index eca9e8ee..a823e964 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/SkipPatternSampler.java +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-otel/src/main/java/io/micrometer/tracing/otel/bridge/SkipPatternSampler.java @@ -18,7 +18,7 @@ import java.util.regex.Pattern; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.tracing.SamplerFunction; diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryBraveSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryBraveSetup.java index 4591ef33..65672244 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryBraveSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryBraveSetup.java @@ -41,6 +41,8 @@ import io.micrometer.tracing.brave.bridge.BraveTracer; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.propagation.Propagator; @@ -335,11 +337,9 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) { Tracer tracer = braveBuildingBlocks.tracer; - HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler; LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); braveBuildingBlocks.customizers.accept(braveBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryOtelSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryOtelSetup.java index d1ae5e1a..ee738ab4 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryOtelSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/inmemory/InMemoryOtelSetup.java @@ -32,6 +32,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.otel.bridge.ArrayListSpanProcessor; @@ -364,12 +366,10 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) { OtelTracer tracer = otelBuildingBlocks.otelTracer; - HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler; LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); otelBuildingBlocks.customizers.accept(otelBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontBraveSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontBraveSetup.java index 31684c44..158ed5ea 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontBraveSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontBraveSetup.java @@ -46,6 +46,8 @@ import io.micrometer.tracing.brave.bridge.BraveTracer; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.reporter.wavefront.WavefrontBraveSpanHandler; @@ -417,11 +419,10 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) { Tracer tracer = braveBuildingBlocks.tracer; - HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler; + LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); braveBuildingBlocks.customizers.accept(braveBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontOtelSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontOtelSetup.java index e04c65ef..1e87bdcc 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontOtelSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/wavefront/WavefrontOtelSetup.java @@ -36,6 +36,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.otel.bridge.ArrayListSpanProcessor; @@ -156,7 +158,7 @@ public static class OtelBuildingBlocks implements BuildingBlocks { private final OtelTracer otelTracer; - private final OtelPropagator otelPropagator; + private final OtelPropagator propagator; private final HttpServerHandler httpServerHandler; @@ -171,16 +173,16 @@ public static class OtelBuildingBlocks implements BuildingBlocks { * * @param wavefrontOTelSpanHandler span handler * @param otelTracer otel tracer - * @param otelPropagator otel propagator + * @param propagator otel propagator * @param httpServerHandler otel http server handler * @param httpClientHandler otel http client handler * @param customizers observation customizers * @param arrayListSpanProcessor array list span processor */ - public OtelBuildingBlocks(WavefrontOtelSpanHandler wavefrontOTelSpanHandler, OtelTracer otelTracer, OtelPropagator otelPropagator, HttpServerHandler httpServerHandler, HttpClientHandler httpClientHandler, BiConsumer>> customizers, ArrayListSpanProcessor arrayListSpanProcessor) { + public OtelBuildingBlocks(WavefrontOtelSpanHandler wavefrontOTelSpanHandler, OtelTracer otelTracer, OtelPropagator propagator, HttpServerHandler httpServerHandler, HttpClientHandler httpClientHandler, BiConsumer>> customizers, ArrayListSpanProcessor arrayListSpanProcessor) { this.wavefrontOTelSpanHandler = wavefrontOTelSpanHandler; this.otelTracer = otelTracer; - this.otelPropagator = otelPropagator; + this.propagator = propagator; this.httpServerHandler = httpServerHandler; this.httpClientHandler = httpClientHandler; this.customizers = customizers; @@ -194,7 +196,7 @@ public io.micrometer.tracing.Tracer getTracer() { @Override public Propagator getPropagator() { - return this.otelPropagator; + return this.propagator; } @Override @@ -448,11 +450,10 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) { OtelTracer tracer = otelBuildingBlocks.otelTracer; - HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler; + LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); otelBuildingBlocks.customizers.accept(otelBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinBraveSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinBraveSetup.java index acd6fdac..feca823f 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinBraveSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinBraveSetup.java @@ -42,6 +42,8 @@ import io.micrometer.tracing.brave.bridge.BraveTracer; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.propagation.Propagator; @@ -416,11 +418,10 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) { Tracer tracer = braveBuildingBlocks.tracer; - HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler; + LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, braveBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); braveBuildingBlocks.customizers.accept(braveBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinOtelSetup.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinOtelSetup.java index ba906ebe..58d9c7b4 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinOtelSetup.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/reporter/zipkin/ZipkinOtelSetup.java @@ -34,6 +34,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingReceiverTracingObservationHandler; +import io.micrometer.tracing.handler.PropagatingSenderTracingObservationHandler; import io.micrometer.tracing.http.HttpClientHandler; import io.micrometer.tracing.http.HttpServerHandler; import io.micrometer.tracing.otel.bridge.ArrayListSpanProcessor; @@ -455,11 +457,10 @@ private static Consumer closingFunction() { @SuppressWarnings("rawtypes") private static ObservationHandler tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) { OtelTracer tracer = otelBuildingBlocks.otelTracer; - HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler; - HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler; + LinkedList> handlers = new LinkedList<>(); - handlers.add(new HttpServerTracingObservationHandler(tracer, httpServerHandler)); - handlers.add(new HttpClientTracingObservationHandler(tracer, httpClientHandler)); + handlers.add(new PropagatingSenderTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); + handlers.add(new PropagatingReceiverTracingObservationHandler<>(tracer, otelBuildingBlocks.propagator)); handlers.add(new DefaultTracingObservationHandler(tracer)); otelBuildingBlocks.customizers.accept(otelBuildingBlocks, handlers); diff --git a/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpClientHandler.java b/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpClientHandler.java index a25fbbb6..2c6a7394 100644 --- a/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpClientHandler.java +++ b/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpClientHandler.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.test.simple; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.TraceContext; import io.micrometer.tracing.http.HttpClientHandler; diff --git a/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpServerHandler.java b/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpServerHandler.java index ac71f3e5..f179f000 100644 --- a/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpServerHandler.java +++ b/micrometer-tracing-tests/micrometer-tracing-test/src/main/java/io/micrometer/tracing/test/simple/SimpleHttpServerHandler.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.test.simple; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.http.HttpServerHandler; 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 1e175c8a..eb4daedf 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 @@ -16,6 +16,7 @@ package io.micrometer.tracing.handler; +import io.micrometer.observation.Observation; import io.micrometer.observation.transport.ReceiverContext; import io.micrometer.tracing.Span; import io.micrometer.tracing.Tracer; @@ -84,6 +85,11 @@ public void customizeReceiverSpan(ReceiverContext context, Span span) { } + @Override + public boolean supportsContext(Observation.Context context) { + return context instanceof ReceiverContext; + } + @Override public Tracer getTracer() { return this.tracer; 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 aef4f27d..0c2bc156 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 @@ -16,6 +16,7 @@ package io.micrometer.tracing.handler; +import io.micrometer.observation.Observation; import io.micrometer.observation.transport.SenderContext; import io.micrometer.tracing.Span; import io.micrometer.tracing.Tracer; @@ -27,7 +28,7 @@ * @author Marcin Grzejszczak * @since 1.0.0 */ -public abstract class PropagatingSenderTracingObservationHandler implements TracingObservationHandler> { +public class PropagatingSenderTracingObservationHandler implements TracingObservationHandler> { private final Tracer tracer; private final Propagator propagator; @@ -87,6 +88,11 @@ public void customizeSenderSpan(SenderContext context, Span span) { } + @Override + public boolean supportsContext(Observation.Context context) { + return context instanceof SenderContext; + } + @Override public Tracer getTracer() { return this.tracer; diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientHandler.java index 0e75b365..8888982b 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientHandler.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientHandler.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.http; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; +import io.micrometer.tracing.http.HttpClientRequest; +import io.micrometer.tracing.http.HttpClientResponse; import io.micrometer.tracing.Span; import io.micrometer.tracing.TraceContext; import io.micrometer.common.lang.Nullable; diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientRequest.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientRequest.java new file mode 100644 index 00000000..2137daad --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientRequest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract request type used for parsing and sampling. Represents an HTTP Client request. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpClientRequest extends HttpRequest { + + /** + * Adds a new header. + * @param name header name + * @param value header value + */ + void header(String name, String value); + + @Override + default Kind kind() { + return Kind.CLIENT; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientResponse.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientResponse.java new file mode 100644 index 00000000..a97529e6 --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpClientResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.common.lang.Nullable; +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract response type used for parsing and sampling. Represents an HTTP Client + * response. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpClientResponse extends HttpResponse { + + @Nullable + default HttpClientRequest request() { + return null; + } + + @Override + default Throwable error() { + return null; + } + + @Override + default Kind kind() { + return Kind.CLIENT; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequest.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequest.java new file mode 100644 index 00000000..591fad55 --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequest.java @@ -0,0 +1,87 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.common.lang.Nullable; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract response type used for parsing and sampling. Represents an HTTP request. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpRequest extends Request { + + /** + * Returns an HTTP method. + * @return an HTTP method. + */ + String method(); + + /** + * Returns an HTTP path. + * @return an HTTP path or {@code null} if not set. + */ + @Nullable + String path(); + + /** + * Returns an expression such as "/items/:itemId" representing an application + * endpoint, conventionally associated with the tag key "http.route". If no route + * matched, "" (empty string) is returned. {@code null} indicates this instrumentation + * doesn't understand http routes. + * @return an HTTP route or {@code null} if not set + */ + @Nullable + default String route() { + return null; + } + + /** + * Returns an HTTP URL. + * @return an HTTP URL or {@code null} if not set. + */ + @Nullable + String url(); + + /** + * Returns a header. + * @param name header name + * @return an HTTP header or {@code null} if not set. + */ + @Nullable + String header(String name); + + /** + * Returns a remote IP. + * @return remote IP for the given connection. + */ + default String remoteIp() { + return null; + } + + /** + * Returns a remote port. + * @return remote port for the given connection. + */ + default int remotePort() { + return 0; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequestParser.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequestParser.java index 560cbd93..12f3d98f 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequestParser.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpRequestParser.java @@ -16,7 +16,7 @@ package io.micrometer.tracing.http; -import io.micrometer.observation.transport.http.HttpRequest; +import io.micrometer.tracing.http.HttpRequest; import io.micrometer.tracing.SpanCustomizer; import io.micrometer.tracing.TraceContext; diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponse.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponse.java new file mode 100644 index 00000000..7d603e3c --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponse.java @@ -0,0 +1,75 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.common.lang.Nullable; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract response type used for parsing and sampling. Represents an HTTP response. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpResponse extends Response { + + @Nullable + @Override + default HttpRequest request() { + return null; + } + + /** + * Returns an HTTP method. + * @return an HTTP method + */ + @Nullable + default String method() { + HttpRequest request = request(); + return request != null ? request.method() : null; + } + + /** + * Returns an expression such as "/items/:itemId" representing an application + * endpoint, conventionally associated with the tag key "http.route". If no route + * matched, "" (empty string) is returned. {@code null} indicates this instrumentation + * doesn't understand http routes. + * @return an HTTP route or {@code null} if not set + */ + @Nullable + default String route() { + HttpRequest request = request(); + return request != null ? request.route() : null; + } + + /** + * Returns the HTTP status code. + * @return an HTTP status code or zero if unreadable + */ + int statusCode(); + + /** + * Returns the header value. + * @param header header name + * @return an HTTP header or {@code null} if not set. + */ + default String header(String header) { + return null; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponseParser.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponseParser.java index 7081d652..962cd9c3 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponseParser.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpResponseParser.java @@ -16,7 +16,7 @@ package io.micrometer.tracing.http; -import io.micrometer.observation.transport.http.HttpResponse; +import io.micrometer.tracing.http.HttpResponse; import io.micrometer.tracing.SpanCustomizer; import io.micrometer.tracing.TraceContext; diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerHandler.java index 181767ae..0a84db6f 100644 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerHandler.java +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerHandler.java @@ -16,8 +16,8 @@ package io.micrometer.tracing.http; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; +import io.micrometer.tracing.http.HttpServerRequest; +import io.micrometer.tracing.http.HttpServerResponse; import io.micrometer.tracing.Span; /** diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerRequest.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerRequest.java new file mode 100644 index 00000000..6d0637bd --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerRequest.java @@ -0,0 +1,54 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract request type used for parsing and sampling. Represents an HTTP Server request. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpServerRequest extends HttpRequest { + + /** + * Returns an HTTP attribute. + * @param key attribute key + * @return attribute with the given key or {@code null} if not set + */ + default Object getAttribute(String key) { + return null; + } + + /** + * Sets an HTTP attribute. + * @param key attribute key + * @param value attribute value + */ + default void setAttribute(String key, Object value) { + + } + + @Override + default Kind kind() { + return Kind.SERVER; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerResponse.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerResponse.java new file mode 100644 index 00000000..f988616e --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/HttpServerResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import io.micrometer.common.lang.Nullable; +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract response type used for parsing and sampling. Represents an HTTP Server + * response. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface HttpServerResponse extends HttpResponse { + + @Nullable + default HttpServerRequest request() { + return null; + } + + @Override + default Throwable error() { + return null; + } + + @Override + default Kind kind() { + return Kind.SERVER; + } + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Request.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Request.java new file mode 100644 index 00000000..fe54f084 --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Request.java @@ -0,0 +1,51 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import java.util.Collection; + +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract request type used for parsing and sampling. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface Request { + + /** + * Returns the header names. + * @return collection of header names + */ + Collection headerNames(); + + /** + * Returns the transport kind. + * @return the remote kind describing the direction and type of the request + */ + Kind kind(); + + /** + * Returns the underlying request object. + * @return the underlying request object or {@code null} if there is none + */ + Object unwrap(); + +} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Response.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Response.java new file mode 100644 index 00000000..d1ad11dd --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/http/Response.java @@ -0,0 +1,66 @@ +/* + * Copyright 2021 VMware, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.micrometer.tracing.http; + +import java.util.Collection; + +import io.micrometer.common.lang.Nullable; +import io.micrometer.observation.transport.Kind; + +/** + * This API is taken from OpenZipkin Brave. + * + * Abstract response type used for parsing and sampling. + * + * @author OpenZipkin Brave Authors + * @author Marcin Grzejszczak + * @since 1.10.0 + */ +public interface Response { + + /** + * Returns the header names. + * @return collection of header names + */ + Collection headerNames(); + + /** + * Returns the HTTP request. + * @return corresponding request + */ + @Nullable + Request request(); + + /** + * Returns the exception. + * @return exception that occurred or {@code null} if there was none. + */ + @Nullable + Throwable error(); + + /** + * Returns the underlying response object. + * @return the underlying response object or {@code null} if there is none. + */ + Object unwrap(); + + /** + * Returns the transport kind. + * @return the remote kind describing the direction and type of the response + */ + Kind kind(); + +}