Skip to content

Commit

Permalink
Simplify signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed Dec 10, 2024
1 parent beec8e1 commit 7795dec
Show file tree
Hide file tree
Showing 25 changed files with 61 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,15 @@ public final class DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> {

private final List<AttributesExtractor<? super REQUEST, ? super RESPONSE>> additionalExtractors =
new ArrayList<>();
private Function<
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
private Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
statusExtractorTransformer = Function.identity();
private final HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE>
httpAttributesExtractorBuilder;
private final HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter;
private final HttpSpanNameExtractorBuilder<REQUEST> httpSpanNameExtractorBuilder;

@Nullable private final TextMapSetter<REQUEST> headerSetter;
private Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
private Function<SpanNameExtractor<REQUEST>, ? extends SpanNameExtractor<REQUEST>>
spanNameExtractorTransformer = Function.identity();
private boolean emitExperimentalHttpClientMetrics = false;
private Consumer<InstrumenterBuilder<REQUEST, RESPONSE>> builderCustomizer = b -> {};
Expand Down Expand Up @@ -111,9 +109,7 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> addAttributesExtr

@CanIgnoreReturnValue
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtractor(
Function<
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
statusExtractor) {
this.statusExtractorTransformer = statusExtractor;
return this;
Expand Down Expand Up @@ -180,7 +176,7 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
spanNameExtractorTransformer) {
this.spanNameExtractorTransformer = spanNameExtractorTransformer;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ public final class DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> {

private final List<AttributesExtractor<? super REQUEST, ? super RESPONSE>> additionalExtractors =
new ArrayList<>();
private Function<
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
private Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
statusExtractorTransformer = Function.identity();
private final HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE>
httpAttributesExtractorBuilder;
private final HttpSpanNameExtractorBuilder<REQUEST> httpSpanNameExtractorBuilder;

@Nullable private final TextMapGetter<REQUEST> headerGetter;
private Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
private Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
spanNameExtractorTransformer = Function.identity();
private final HttpServerRouteBuilder<REQUEST> httpServerRouteBuilder;
private final HttpServerAttributesGetter<REQUEST, RESPONSE> attributesGetter;
Expand Down Expand Up @@ -109,9 +107,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> addAttributesExtr

@CanIgnoreReturnValue
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtractor(
Function<
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
statusExtractor) {
this.statusExtractorTransformer = statusExtractor;
return this;
Expand Down Expand Up @@ -179,7 +175,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
spanNameExtractorTransformer) {
this.spanNameExtractorTransformer = spanNameExtractorTransformer;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public ApacheHttpClientTelemetryBuilder addAttributeExtractor(
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super ApacheHttpClientRequest, ? super HttpResponse>
attributesExtractor) {
AttributesExtractor<ApacheHttpClientRequest, HttpResponse> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -120,8 +119,8 @@ public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super ApacheHttpClientRequest>,
? extends SpanNameExtractor<? super ApacheHttpClientRequest>>
SpanNameExtractor<ApacheHttpClientRequest>,
SpanNameExtractor<ApacheHttpClientRequest>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics(
@CanIgnoreReturnValue
public ApacheHttpClient5TelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super ApacheHttpClient5Request>,
? extends SpanNameExtractor<? super ApacheHttpClient5Request>>
SpanNameExtractor<ApacheHttpClient5Request>,
SpanNameExtractor<ApacheHttpClient5Request>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public final class ApacheHttpClientTelemetryBuilder {
* items. The {@link AttributesExtractor} will be executed after all default extractors.
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder addAttributeExtractor(
AttributesExtractor<? super ApacheHttpClientRequest, ? super HttpResponse>
attributesExtractor) {
builder.addAttributeExtractor(attributesExtractor);
public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<ApacheHttpClientRequest, HttpResponse> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}

Expand Down Expand Up @@ -88,8 +87,8 @@ public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super ApacheHttpClientRequest>,
? extends SpanNameExtractor<? super ApacheHttpClientRequest>>
SpanNameExtractor<ApacheHttpClientRequest>,
SpanNameExtractor<ApacheHttpClientRequest>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public final class ArmeriaClientTelemetryBuilder {
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder setStatusExtractor(
Function<
SpanStatusExtractor<? super ClientRequestContext, ? super RequestLog>,
? extends SpanStatusExtractor<? super ClientRequestContext, ? super RequestLog>>
SpanStatusExtractor<ClientRequestContext, RequestLog>,
SpanStatusExtractor<ClientRequestContext, RequestLog>>
statusExtractor) {
builder.setStatusExtractor(statusExtractor);
return this;
Expand All @@ -50,8 +50,8 @@ public ArmeriaClientTelemetryBuilder setStatusExtractor(
*/
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super ClientRequestContext, ? super RequestLog> attributesExtractor) {
builder.addAttributeExtractor(attributesExtractor);
AttributesExtractor<ClientRequestContext, RequestLog> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}

Expand Down Expand Up @@ -99,9 +99,7 @@ public ArmeriaClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
/** Sets custom client {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super ClientRequestContext>,
? extends SpanNameExtractor<? super ClientRequestContext>>
Function<SpanNameExtractor<ClientRequestContext>, SpanNameExtractor<ClientRequestContext>>
clientSpanNameExtractor) {
builder.setSpanNameExtractor(clientSpanNameExtractor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public final class ArmeriaServerTelemetryBuilder {
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder setStatusExtractor(
Function<
SpanStatusExtractor<? super ServiceRequestContext, ? super RequestLog>,
? extends SpanStatusExtractor<? super ServiceRequestContext, ? super RequestLog>>
SpanStatusExtractor<ServiceRequestContext, RequestLog>,
SpanStatusExtractor<ServiceRequestContext, RequestLog>>
statusExtractor) {
builder.setStatusExtractor(statusExtractor);
return this;
Expand All @@ -50,7 +50,7 @@ public ArmeriaServerTelemetryBuilder setStatusExtractor(
*/
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super ServiceRequestContext, ? super RequestLog> attributesExtractor) {
AttributesExtractor<ServiceRequestContext, RequestLog> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -99,9 +99,7 @@ public ArmeriaServerTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
/** Sets custom server {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super ServiceRequestContext>,
? extends SpanNameExtractor<? super ServiceRequestContext>>
Function<SpanNameExtractor<ServiceRequestContext>, SpanNameExtractor<ServiceRequestContext>>
serverSpanNameExtractor) {
builder.setSpanNameExtractor(serverSpanNameExtractor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public ArmeriaTelemetryBuilder setStatusExtractor(
@CanIgnoreReturnValue
public ArmeriaTelemetryBuilder setClientStatusExtractor(
Function<
SpanStatusExtractor<? super ClientRequestContext, ? super RequestLog>,
? extends SpanStatusExtractor<? super ClientRequestContext, ? super RequestLog>>
SpanStatusExtractor<ClientRequestContext, RequestLog>,
SpanStatusExtractor<ClientRequestContext, RequestLog>>
statusExtractor) {
clientBuilder.setStatusExtractor(statusExtractor);
return this;
Expand All @@ -85,8 +85,8 @@ public ArmeriaTelemetryBuilder setClientStatusExtractor(
@CanIgnoreReturnValue
public ArmeriaTelemetryBuilder setServerStatusExtractor(
Function<
SpanStatusExtractor<? super ServiceRequestContext, ? super RequestLog>,
? extends SpanStatusExtractor<? super ServiceRequestContext, ? super RequestLog>>
SpanStatusExtractor<ServiceRequestContext, RequestLog>,
SpanStatusExtractor<ServiceRequestContext, RequestLog>>
statusExtractor) {
serverBuilder.setStatusExtractor(statusExtractor);
return this;
Expand Down Expand Up @@ -270,9 +270,7 @@ public ArmeriaTelemetryBuilder setEmitExperimentalHttpServerMetrics(
@Deprecated
@CanIgnoreReturnValue
public ArmeriaTelemetryBuilder setClientSpanNameExtractor(
Function<
SpanNameExtractor<? super ClientRequestContext>,
? extends SpanNameExtractor<? super ClientRequestContext>>
Function<SpanNameExtractor<ClientRequestContext>, SpanNameExtractor<ClientRequestContext>>
clientSpanNameExtractor) {
clientBuilder.setSpanNameExtractor(clientSpanNameExtractor);
return this;
Expand All @@ -286,9 +284,7 @@ public ArmeriaTelemetryBuilder setClientSpanNameExtractor(
@Deprecated
@CanIgnoreReturnValue
public ArmeriaTelemetryBuilder setServerSpanNameExtractor(
Function<
SpanNameExtractor<? super ServiceRequestContext>,
? extends SpanNameExtractor<? super ServiceRequestContext>>
Function<SpanNameExtractor<ServiceRequestContext>, SpanNameExtractor<ServiceRequestContext>>
serverSpanNameExtractor) {
serverBuilder.setSpanNameExtractor(serverSpanNameExtractor);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public JavaHttpClientTelemetryBuilder addAttributeExtractor(
*/
@CanIgnoreReturnValue
public JavaHttpClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super HttpRequest, ? super HttpResponse<?>> attributesExtractor) {
AttributesExtractor<HttpRequest, HttpResponse<?>> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -116,9 +116,7 @@ public JavaHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public JavaHttpClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super HttpRequest>,
? extends SpanNameExtractor<? super HttpRequest>>
Function<SpanNameExtractor<HttpRequest>, SpanNameExtractor<HttpRequest>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public JettyClientTelemetryBuilder addAttributeExtractor(
*/
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super Request, ? super Response> attributesExtractor) {
AttributesExtractor<Request, Response> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setSpanNameExtractor(
Function<SpanNameExtractor<? super Request>, ? extends SpanNameExtractor<? super Request>>
Function<SpanNameExtractor<Request>, SpanNameExtractor<Request>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public JettyClientTelemetryBuilder addAttributeExtractor(
*/
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super Request, ? super Response> attributesExtractor) {
AttributesExtractor<Request, Response> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public JettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setSpanNameExtractor(
Function<SpanNameExtractor<? super Request>, ? extends SpanNameExtractor<? super Request>>
Function<SpanNameExtractor<Request>, SpanNameExtractor<Request>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class AbstractKtorClientTelemetryBuilder(

fun attributesExtractor(extractorBuilder: ExtractorBuilder.() -> Unit = {}) {
val builder = ExtractorBuilder().apply(extractorBuilder).build()
this.builder.addAttributeExtractor(
this.builder.addAttributesExtractor(
object : AttributesExtractor<HttpRequestData, HttpResponse> {
override fun onStart(attributes: AttributesBuilder, parentContext: Context, request: HttpRequestData) {
builder.onStart(OnStartData(attributes, parentContext, request))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ public NettyClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public NettyClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super HttpRequestAndChannel>,
? extends SpanNameExtractor<? super HttpRequestAndChannel>>
Function<SpanNameExtractor<HttpRequestAndChannel>, SpanNameExtractor<HttpRequestAndChannel>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public OkHttpTelemetryBuilder addAttributeExtractor(
*/
@CanIgnoreReturnValue
public OkHttpTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super Interceptor.Chain, ? super Response> attributesExtractor) {
AttributesExtractor<Interceptor.Chain, Response> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}
Expand Down Expand Up @@ -115,9 +115,7 @@ public OkHttpTelemetryBuilder setEmitExperimentalHttpClientMetrics(
/** Sets custom {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public OkHttpTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super Interceptor.Chain>,
? extends SpanNameExtractor<? super Interceptor.Chain>>
Function<SpanNameExtractor<Interceptor.Chain>, SpanNameExtractor<Interceptor.Chain>>
spanNameExtractorTransformer) {
builder.setSpanNameExtractor(spanNameExtractorTransformer);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public final class RatpackClientTelemetryBuilder {

@CanIgnoreReturnValue
public RatpackClientTelemetryBuilder addAttributesExtractor(
AttributesExtractor<? super RequestSpec, ? super HttpResponse> attributesExtractor) {
builder.addAttributeExtractor(attributesExtractor);
AttributesExtractor<RequestSpec, HttpResponse> attributesExtractor) {
builder.addAttributesExtractor(attributesExtractor);
return this;
}

Expand Down Expand Up @@ -81,9 +81,7 @@ public RatpackClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
/** Sets custom client {@link SpanNameExtractor} via transform function. */
@CanIgnoreReturnValue
public RatpackClientTelemetryBuilder setSpanNameExtractor(
Function<
SpanNameExtractor<? super RequestSpec>,
? extends SpanNameExtractor<? super RequestSpec>>
Function<SpanNameExtractor<RequestSpec>, SpanNameExtractor<RequestSpec>>
clientSpanNameExtractor) {
builder.setSpanNameExtractor(clientSpanNameExtractor);
return this;
Expand Down
Loading

0 comments on commit 7795dec

Please sign in to comment.