Skip to content

Commit

Permalink
how to debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Sep 26, 2024
1 parent 575bf43 commit a0f1db3
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setBuilderCustomi
}

public Instrumenter<REQUEST, RESPONSE> build() {
InstrumenterBuilder<REQUEST, RESPONSE> builder = builder();
InstrumenterBuilder<REQUEST, RESPONSE> builder = instrumenterBuilder();

if (headerGetter != null) {
return builder.buildServerInstrumenter(headerGetter);
}
return builder.buildInstrumenter(SpanKindExtractor.alwaysServer());
}

public InstrumenterBuilder<REQUEST, RESPONSE> builder() {
public InstrumenterBuilder<REQUEST, RESPONSE> instrumenterBuilder() {
SpanNameExtractor<? super REQUEST> spanNameExtractor =
spanNameExtractorTransformer.apply(httpSpanNameExtractorBuilder.build());

Expand All @@ -199,11 +199,7 @@ public InstrumenterBuilder<REQUEST, RESPONSE> builder() {
.addOperationMetrics(HttpServerExperimentalMetrics.get());
}
builderCustomizer.accept(builder);

if (headerGetter != null) {
return builder.buildServerInstrumenter(headerGetter);
}
return builder.buildInstrumenter(SpanKindExtractor.alwaysServer());
return builder;
}

@CanIgnoreReturnValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class KtorServerTracing private constructor(
DefaultHttpServerInstrumenterBuilder(
INSTRUMENTATION_NAME,
openTelemetry,
KtorHttpServerAttributesGetter.INSTANCE
KtorHttpServerAttributesGetter.INSTANCE,
null
)
}

Expand Down Expand Up @@ -111,7 +112,7 @@ class KtorServerTracing private constructor(
}

val instrumenter = InstrumenterUtil.buildUpstreamInstrumenter(
configuration.builder.builder(),
configuration.builder.instrumenterBuilder(),
ApplicationRequestGetter,
configuration.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class KtorServerTracing private constructor(
require(configuration.isOpenTelemetryInitialized()) { "OpenTelemetry must be set" }

val instrumenter = InstrumenterUtil.buildUpstreamInstrumenter(
configuration.serverBuilder.builder(),
configuration.serverBuilder.instrumenterBuilder(),
ApplicationRequestGetter,
configuration.spanKindExtractor(SpanKindExtractor.alwaysServer())
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public final class RatpackTelemetryBuilder {
.setHeaderSetter(RequestHeaderSetter.INSTANCE);
serverBuilder =
new DefaultHttpServerInstrumenterBuilder<>(
INSTRUMENTATION_NAME, openTelemetry, RatpackHttpAttributesGetter.INSTANCE, RatpackGetter.INSTANCE);
INSTRUMENTATION_NAME,
openTelemetry,
RatpackHttpAttributesGetter.INSTANCE,
RatpackGetter.INSTANCE);
}

/**
Expand Down Expand Up @@ -151,7 +154,9 @@ public RatpackTelemetryBuilder setEmitExperimentalHttpServerMetrics(
/** Sets custom client {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public RatpackTelemetryBuilder setClientSpanNameExtractor(
Function<SpanNameExtractor<? super RequestSpec>, ? extends SpanNameExtractor<? super RequestSpec>>
Function<
SpanNameExtractor<? super RequestSpec>,
? extends SpanNameExtractor<? super RequestSpec>>
clientSpanNameExtractor) {
clientBuilder.setSpanNameExtractor(clientSpanNameExtractor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public RestletTelemetryBuilder setSpanNameExtractor(
Function<SpanNameExtractor<Request>, ? extends SpanNameExtractor<? super Request>>
Function<SpanNameExtractor<? super Request>, ? extends SpanNameExtractor<? super Request>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ private RestletTelemetryBuilderFactory() {}
public static DefaultHttpServerInstrumenterBuilder<Request, Response> create(
OpenTelemetry openTelemetry) {
return new DefaultHttpServerInstrumenterBuilder<>(
INSTRUMENTATION_NAME, openTelemetry, RestletHttpAttributesGetter.INSTANCE)
.setHeaderGetter(RestletHeadersGetter.INSTANCE);
INSTRUMENTATION_NAME,
openTelemetry,
RestletHttpAttributesGetter.INSTANCE,
RestletHeadersGetter.INSTANCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public RestletTelemetryBuilder setEmitExperimentalHttpServerMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public RestletTelemetryBuilder setSpanNameExtractor(
Function<SpanNameExtractor<Request>, ? extends SpanNameExtractor<? super Request>>
Function<SpanNameExtractor<? super Request>, ? extends SpanNameExtractor<? super Request>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ private RestletTelemetryBuilderFactory() {}
public static DefaultHttpServerInstrumenterBuilder<Request, Response> create(
OpenTelemetry openTelemetry) {
return new DefaultHttpServerInstrumenterBuilder<>(
"io.opentelemetry.restlet-2.0", openTelemetry, RestletHttpAttributesGetter.INSTANCE)
.setHeaderGetter(new RestletHeadersGetter());
"io.opentelemetry.restlet-2.0",
openTelemetry,
RestletHttpAttributesGetter.INSTANCE,
new RestletHeadersGetter());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ public Instrumenter<ServletRequestContext<REQUEST>, ServletResponseContext<RESPO
ServletRequestContext<REQUEST>, ServletResponseContext<RESPONSE>>
serverBuilder =
new DefaultHttpServerInstrumenterBuilder<>(
instrumentationName, GlobalOpenTelemetry.get(), httpAttributesGetter)
.setHeaderGetter(new ServletRequestGetter<>(accessor));
instrumentationName,
GlobalOpenTelemetry.get(),
httpAttributesGetter,
new ServletRequestGetter<>(accessor));
serverBuilder.setSpanNameExtractor(e -> spanNameExtractor);

return JavaagentHttpServerInstrumenters.create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> create(
instrumenterBuilderConsumer);
}

private static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> create(
public static <REQUEST, RESPONSE> Instrumenter<REQUEST, RESPONSE> create(
DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> builder,
Consumer<InstrumenterBuilder<REQUEST, RESPONSE>> builderCustomizer) {
return builder
Expand Down

0 comments on commit a0f1db3

Please sign in to comment.