Skip to content

Commit

Permalink
Moved Http* related code to Tracing + removed the HttpHandlers
Browse files Browse the repository at this point in the history
  • Loading branch information
marcingrzejszczak committed Jul 18, 2022
1 parent 189427f commit 781aae9
Show file tree
Hide file tree
Showing 41 changed files with 559 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -335,11 +337,9 @@ private static Consumer<BraveBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) {
Tracer tracer = braveBuildingBlocks.tracer;
HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler;
LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -364,12 +366,10 @@ private static Consumer<OtelBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) {
OtelTracer tracer = otelBuildingBlocks.otelTracer;
HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler;

LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -417,11 +419,10 @@ private static Consumer<BraveBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) {
Tracer tracer = braveBuildingBlocks.tracer;
HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler;

LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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<BuildingBlocks, Deque<ObservationHandler<? extends Observation.Context>>> customizers, ArrayListSpanProcessor arrayListSpanProcessor) {
public OtelBuildingBlocks(WavefrontOtelSpanHandler wavefrontOTelSpanHandler, OtelTracer otelTracer, OtelPropagator propagator, HttpServerHandler httpServerHandler, HttpClientHandler httpClientHandler, BiConsumer<BuildingBlocks, Deque<ObservationHandler<? extends Observation.Context>>> customizers, ArrayListSpanProcessor arrayListSpanProcessor) {
this.wavefrontOTelSpanHandler = wavefrontOTelSpanHandler;
this.otelTracer = otelTracer;
this.otelPropagator = otelPropagator;
this.propagator = propagator;
this.httpServerHandler = httpServerHandler;
this.httpClientHandler = httpClientHandler;
this.customizers = customizers;
Expand All @@ -194,7 +196,7 @@ public io.micrometer.tracing.Tracer getTracer() {

@Override
public Propagator getPropagator() {
return this.otelPropagator;
return this.propagator;
}

@Override
Expand Down Expand Up @@ -448,11 +450,10 @@ private static Consumer<OtelBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) {
OtelTracer tracer = otelBuildingBlocks.otelTracer;
HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler;

LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -416,11 +418,10 @@ private static Consumer<BraveBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(BraveBuildingBlocks braveBuildingBlocks) {
Tracer tracer = braveBuildingBlocks.tracer;
HttpServerHandler httpServerHandler = braveBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = braveBuildingBlocks.httpClientHandler;

LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -455,11 +457,10 @@ private static Consumer<OtelBuildingBlocks> closingFunction() {
@SuppressWarnings("rawtypes")
private static ObservationHandler<Observation.Context> tracingHandlers(OtelBuildingBlocks otelBuildingBlocks) {
OtelTracer tracer = otelBuildingBlocks.otelTracer;
HttpServerHandler httpServerHandler = otelBuildingBlocks.httpServerHandler;
HttpClientHandler httpClientHandler = otelBuildingBlocks.httpClientHandler;

LinkedList<ObservationHandler<? extends Observation.Context>> 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);

Expand Down
Loading

0 comments on commit 781aae9

Please sign in to comment.