diff --git a/dependencies.gradle b/dependencies.gradle index 6eb570fb..edb5fc29 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -23,8 +23,7 @@ def VERSIONS = [ 'org.mockito:mockito-inline:latest.release', 'com.github.tomakehurst:wiremock-jre8-standalone:latest.release', 'org.testcontainers:testcontainers:latest.release', - 'org.testcontainers:junit-jupiter:latest.release', - 'org.apiguardian:apiguardian-api:latest.release' // to make CI pass + 'org.testcontainers:junit-jupiter:latest.release' ] def PLATFORM_VERSIONS = [ @@ -33,8 +32,7 @@ def PLATFORM_VERSIONS = [ // opentelemetry-instrumentation-api dependency above with this 'io.opentelemetry:opentelemetry-bom:1.+', 'io.opentelemetry:opentelemetry-bom-alpha:1.+', - 'org.junit:junit-bom:5.8.2', - 'com.fasterxml.jackson:jackson-bom:2.13.3' // to make CI pass + 'org.junit:junit-bom:5.8.2' ] subprojects { diff --git a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/build.gradle b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/build.gradle index d099ccea..9f02c9bc 100644 --- a/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/build.gradle +++ b/micrometer-tracing-bridges/micrometer-tracing-bridge-brave/build.gradle @@ -16,7 +16,6 @@ dependencies { api("io.zipkin.brave:brave-instrumentation-http") api("io.zipkin.aws:brave-propagation-aws") - testImplementation 'org.apiguardian:apiguardian-api' // to make CI pass testImplementation 'io.micrometer:micrometer-observation-test' testImplementation project(':micrometer-tracing-test') testImplementation 'org.junit.jupiter:junit-jupiter' 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/SampleTestRunner.java b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/SampleTestRunner.java index 0cc79847..c8a51695 100644 --- a/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/SampleTestRunner.java +++ b/micrometer-tracing-tests/micrometer-tracing-integration-test/src/main/java/io/micrometer/tracing/test/SampleTestRunner.java @@ -81,7 +81,7 @@ public abstract class SampleTestRunner { private MeterRegistry meterRegistry; - private final List> observationHandlersCopy; + private final List> observationHandlersCopy; /** * Creates a new instance of the {@link SampleTestRunner} with a pre-created configuration and {@link MeterRegistry}. 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 b4f747ec..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,8 +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.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -337,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 3e9e12b2..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,8 +32,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; -import io.micrometer.tracing.handler.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -366,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 3fc6f2bc..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,8 +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.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -419,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 0d320286..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,8 +36,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; -import io.micrometer.tracing.handler.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -158,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; @@ -173,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; @@ -196,7 +196,7 @@ public io.micrometer.tracing.Tracer getTracer() { @Override public Propagator getPropagator() { - return this.otelPropagator; + return this.propagator; } @Override @@ -450,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 98e88904..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,8 +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.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -418,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 821deded..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,8 +34,8 @@ import io.micrometer.tracing.SamplerFunction; import io.micrometer.tracing.exporter.FinishedSpan; import io.micrometer.tracing.handler.DefaultTracingObservationHandler; -import io.micrometer.tracing.handler.HttpClientTracingObservationHandler; -import io.micrometer.tracing.handler.HttpServerTracingObservationHandler; +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; @@ -457,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/HttpClientTracingObservationHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpClientTracingObservationHandler.java deleted file mode 100755 index b5ced0e7..00000000 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpClientTracingObservationHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2021-2021 the original author or authors. - * - * 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.handler; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - -import io.micrometer.observation.Observation; -import io.micrometer.observation.transport.http.HttpClientRequest; -import io.micrometer.observation.transport.http.HttpClientResponse; -import io.micrometer.observation.transport.http.context.HttpClientContext; -import io.micrometer.tracing.Span; -import io.micrometer.tracing.Tracer; -import io.micrometer.tracing.http.HttpClientHandler; - -/** - * TracingRecordingListener that uses the Tracing API to record events for HTTP client - * side. - * - * @author Marcin Grzejszczak - * @since 1.0.0 - */ -public class HttpClientTracingObservationHandler extends - HttpTracingObservationHandler - implements TracingObservationHandler { - - /** - * Creates a new instance of {@link HttpClientTracingObservationHandler}. - * - * @param tracer tracer - * @param handler http client handler - */ - public HttpClientTracingObservationHandler(Tracer tracer, HttpClientHandler handler) { - super(tracer, (httpClientRequest, span) -> handler.handleSend(httpClientRequest, span != null ? span.context() : null), handler::handleReceive); - } - - /** - * - * Creates a new instance of {@link HttpClientTracingObservationHandler}. - * - * @param tracer tracer - * @param startFunction function that creates a span - * @param stopConsumer lambda to be applied on the span upon receiving the response - */ - public HttpClientTracingObservationHandler(Tracer tracer, BiFunction startFunction, - BiConsumer stopConsumer) { - super(tracer, startFunction, stopConsumer); - } - - @Override - public boolean supportsContext(Observation.Context context) { - return context instanceof HttpClientContext; - } - - @Override - HttpClientRequest getRequest(HttpClientContext ctx) { - return ctx.getRequest(); - } - - @Override - public String getSpanName(HttpClientContext ctx) { - return getRequest(ctx).method(); - } - - @Override - HttpClientResponse getResponse(HttpClientContext ctx) { - return ctx.getResponse(); - } - -} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpServerTracingObservationHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpServerTracingObservationHandler.java deleted file mode 100755 index 57d7e637..00000000 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpServerTracingObservationHandler.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2021-2021 the original author or authors. - * - * 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.handler; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - -import io.micrometer.observation.Observation; -import io.micrometer.observation.transport.http.HttpResponse; -import io.micrometer.observation.transport.http.HttpServerRequest; -import io.micrometer.observation.transport.http.HttpServerResponse; -import io.micrometer.observation.transport.http.context.HttpServerContext; -import io.micrometer.tracing.Span; -import io.micrometer.tracing.Tracer; -import io.micrometer.tracing.http.HttpServerHandler; - -/** - * TracingRecordingListener that uses the Tracing API to record events for HTTP server - * side. - * - * @author Marcin Grzejszczak - * @since 1.0.0 - */ -public class HttpServerTracingObservationHandler extends - HttpTracingObservationHandler - implements TracingObservationHandler { - - /** - * Creates a new instance of {@link HttpServerTracingObservationHandler}. - * - * @param tracer tracer - * @param handler http server handler - */ - public HttpServerTracingObservationHandler(Tracer tracer, HttpServerHandler handler) { - super(tracer, (httpServerRequest, span) -> handler.handleReceive(httpServerRequest), handler::handleSend); - } - - /** - * - * Creates a new instance of {@link HttpServerTracingObservationHandler}. - * - * @param tracer tracer - * @param startFunction function that creates a span - * @param stopConsumer lambda to be applied on the span upon receiving the response - */ - public HttpServerTracingObservationHandler(Tracer tracer, BiFunction startFunction, - BiConsumer stopConsumer) { - super(tracer, startFunction, stopConsumer); - } - - @Override - HttpServerRequest getRequest(HttpServerContext ctx) { - return ctx.getRequest(); - } - - @Override - public String getSpanName(HttpServerContext ctx) { - if (ctx.getResponse() != null) { - return spanNameFromRoute(ctx.getResponse()); - } - return ctx.getRequest().method(); - } - - @Override - public boolean supportsContext(Observation.Context context) { - return context instanceof HttpServerContext; - } - - // taken from Brave - private String spanNameFromRoute(HttpResponse response) { - int statusCode = response.statusCode(); - String method = response.method(); - if (method == null) { - return null; // don't undo a valid name elsewhere - } - String route = response.route(); - if (route == null) { - return null; // don't undo a valid name elsewhere - } - if (!"".equals(route)) { - return method + " " + route; - } - return catchAllName(method, statusCode); - } - - // taken from Brave - private String catchAllName(String method, int statusCode) { - switch (statusCode) { - // from https://tools.ietf.org/html/rfc7231#section-6.4 - case 301: - case 302: - case 303: - case 305: - case 306: - case 307: - return method + " redirected"; - case 404: - return method + " not_found"; - default: - return null; - } - } - - @Override - HttpServerResponse getResponse(HttpServerContext ctx) { - return ctx.getResponse(); - } - -} diff --git a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpTracingObservationHandler.java b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpTracingObservationHandler.java deleted file mode 100755 index d0475d4c..00000000 --- a/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/HttpTracingObservationHandler.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2021-2021 the original author or authors. - * - * 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.handler; - -import java.util.function.BiConsumer; -import java.util.function.BiFunction; - -import io.micrometer.common.lang.Nullable; -import io.micrometer.observation.Observation; -import io.micrometer.observation.transport.http.HttpRequest; -import io.micrometer.observation.transport.http.HttpResponse; -import io.micrometer.observation.transport.http.context.HttpContext; -import io.micrometer.tracing.CurrentTraceContext; -import io.micrometer.tracing.Span; -import io.micrometer.tracing.Tracer; - -@SuppressWarnings({"rawtypes", "unchecked"}) -abstract class HttpTracingObservationHandler - implements TracingObservationHandler { - - private final Tracer tracer; - - private final CurrentTraceContext currentTraceContext; - - private final BiFunction startFunction; - - private final BiConsumer stopConsumer; - - HttpTracingObservationHandler(Tracer tracer, BiFunction startFunction, - BiConsumer stopConsumer) { - this.tracer = tracer; - this.currentTraceContext = tracer.currentTraceContext(); - this.startFunction = startFunction; - this.stopConsumer = stopConsumer; - } - - @Override - public void onStart(CTX ctx) { - Span parentSpan = getParentSpan(ctx); - REQ request = getRequest(ctx); - Span span = this.startFunction.apply(request, parentSpan); - getTracingContext(ctx).setSpan(span); - } - - @Override - public boolean supportsContext(Observation.Context context) { - return context instanceof HttpContext; - } - - @Override - public Tracer getTracer() { - return this.tracer; - } - - abstract REQ getRequest(CTX ctx); - - @Override - public void onError(CTX context) { - - } - - @Override - public void onStop(CTX ctx) { - Span span = getRequiredSpan(ctx); - span.name(getSpanName(ctx)); - tagSpan(ctx, span); - RES response = getResponse(ctx); - error(response, span); - this.stopConsumer.accept(response, span); - } - - abstract RES getResponse(CTX ctx); - - private void error(@Nullable HttpResponse response, Span span) { - if (response == null) { - return; - } - int httpStatus = response.statusCode(); - Throwable error = response.error(); - if (error != null) { - return; - } - if (httpStatus == 0) { - return; - } - if (httpStatus < 100 || httpStatus > 399) { - // TODO: Move to a common place - span.tag("error", String.valueOf(httpStatus)); - } - } - -} 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 new file mode 100644 index 00000000..4e473961 --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingReceiverTracingObservationHandler.java @@ -0,0 +1,101 @@ +/* + * Copyright 2021-2021 the original author or authors. + * + * 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.handler; + +import io.micrometer.observation.Observation; +import io.micrometer.observation.transport.ReceiverContext; +import io.micrometer.tracing.Span; +import io.micrometer.tracing.Tracer; +import io.micrometer.tracing.propagation.Propagator; + +/** + * A {@link TracingObservationHandler} called when receiving occurred - e.g. of messages or http requests. + * + * @author Marcin Grzejszczak + * @since 1.0.0 + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class PropagatingReceiverTracingObservationHandler implements TracingObservationHandler { + + private final Tracer tracer; + + private final Propagator propagator; + + /** + * Creates a new instance of {@link PropagatingReceiverTracingObservationHandler}. + * + * @param tracer the tracer to use to record events + * @param propagator the mechanism to propagate tracing information from the carrier + */ + public PropagatingReceiverTracingObservationHandler(Tracer tracer, Propagator propagator) { + this.tracer = tracer; + this.propagator = propagator; + } + + @Override + 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(); + extractedSpan.name(name); + getTracingContext(context).setSpan(customizeExtractedSpan(context, extractedSpan).start()); + } + + /** + * Customizes the extracted span (e.g. you can set the {@link Span.Kind} via {@link Span.Builder#kind(Span.Kind)}). + * + * @param builder span builder + * @return span builder + */ + public Span.Builder customizeExtractedSpan(T context, Span.Builder builder) { + return builder; + } + + @Override + public void onError(T context) { + context.getError().ifPresent(throwable -> getRequiredSpan(context).error(throwable)); + } + + @Override + public void onStop(T context) { + Span span = getRequiredSpan(context); + tagSpan(context, span); + customizeReceiverSpan(context, span); + span.end(); + } + + /** + * Allows to customize the receiver span before reporting it. + * + * @param context context + * @param span span to customize + */ + public void customizeReceiverSpan(T 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 new file mode 100644 index 00000000..d7fea874 --- /dev/null +++ b/micrometer-tracing/src/main/java/io/micrometer/tracing/handler/PropagatingSenderTracingObservationHandler.java @@ -0,0 +1,100 @@ +/* + * Copyright 2021-2021 the original author or authors. + * + * 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.handler; + +import io.micrometer.observation.Observation; +import io.micrometer.observation.transport.SenderContext; +import io.micrometer.tracing.Span; +import io.micrometer.tracing.Tracer; +import io.micrometer.tracing.propagation.Propagator; + +/** + * A {@link TracingObservationHandler} called when sending occurred - e.g. of messages or http requests. + * + * @author Marcin Grzejszczak + * @since 1.0.0 + */ +@SuppressWarnings({"rawtypes", "unchecked"}) +public class PropagatingSenderTracingObservationHandler implements TracingObservationHandler { + private final Tracer tracer; + + private final Propagator propagator; + + /** + * Creates a new instance of {@link PropagatingSenderTracingObservationHandler}. + * + * @param tracer the tracer to use to record events + * @param propagator the mechanism to propagate tracing information into the carrier + */ + public PropagatingSenderTracingObservationHandler(Tracer tracer, Propagator propagator) { + this.tracer = tracer; + this.propagator = propagator; + } + + @Override + 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); + } + + /** + * Method to be used to create a sender span. + * @param context context + * @return sender span + */ + public Span createSenderSpan(T context) { + Span parentSpan = getParentSpan(context); + Span.Builder builder = getTracer().spanBuilder().kind(Span.Kind.valueOf(context.getKind().name())); + builder = parentSpan != null ? builder.setParent(parentSpan.context()) : builder.setNoParent(); + String name = context.getContextualName() != null ? context.getContextualName() : context.getName(); + return builder.name(name).start(); + } + + @Override + public void onError(T context) { + context.getError().ifPresent(throwable -> getRequiredSpan(context).error(throwable)); + } + + @Override + public void onStop(T context) { + Span span = getRequiredSpan(context); + tagSpan(context, span); + customizeSenderSpan(context, span); + span.end(); + } + + /** + * Allows to customize the receiver span before reporting it. + * @param context context + * @param span span to customize + */ + public void customizeSenderSpan(T 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(); + +}