Skip to content

Commit 96f4e96

Browse files
committed
Simplify signatures
1 parent b996ef4 commit 96f4e96

File tree

29 files changed

+541
-126
lines changed

29 files changed

+541
-126
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
Comparing source compatibility of opentelemetry-instrumentation-api-2.11.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.10.0.jar
2-
No changes.
2+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder (not serializable)
3+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
4+
GENERIC TEMPLATES: +++ REQUEST:java.lang.Object, +++ RESPONSE:java.lang.Object
5+
+++ NEW SUPERCLASS: java.lang.Object
6+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>)
7+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Object build()
8+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.List<java.lang.String>)
9+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.List<java.lang.String>)
10+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Set<java.lang.String>)
11+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> setSpanNameExtractor(java.util.function.Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<REQUEST>,io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<REQUEST>>)
12+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder<REQUEST,RESPONSE> setStatusExtractor(java.util.function.Function<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<REQUEST,RESPONSE>,io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<REQUEST,RESPONSE>>)
13+
+++ NEW INTERFACE: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder (not serializable)
14+
+++ CLASS FILE FORMAT VERSION: 52.0 <- n.a.
15+
GENERIC TEMPLATES: +++ REQUEST:java.lang.Object, +++ RESPONSE:java.lang.Object
16+
+++ NEW SUPERCLASS: java.lang.Object
17+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> addAttributesExtractor(io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor<REQUEST,RESPONSE>)
18+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) java.lang.Object build()
19+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.List<java.lang.String>)
20+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.List<java.lang.String>)
21+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Set<java.lang.String>)
22+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> setSpanNameExtractor(java.util.function.Function<io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<REQUEST>,io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor<REQUEST>>)
23+
+++ NEW METHOD: PUBLIC(+) ABSTRACT(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerTelemetryBuilder<REQUEST,RESPONSE> setStatusExtractor(java.util.function.Function<io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<REQUEST,RESPONSE>,io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor<REQUEST,RESPONSE>>)

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpClientInstrumenterBuilder.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,15 @@ public final class DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> {
5050

5151
private final List<AttributesExtractor<? super REQUEST, ? super RESPONSE>> additionalExtractors =
5252
new ArrayList<>();
53-
private Function<
54-
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
55-
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
53+
private Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
5654
statusExtractorTransformer = Function.identity();
5755
private final HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE>
5856
httpAttributesExtractorBuilder;
5957
private final HttpClientAttributesGetter<REQUEST, RESPONSE> attributesGetter;
6058
private final HttpSpanNameExtractorBuilder<REQUEST> httpSpanNameExtractorBuilder;
6159

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

112110
@CanIgnoreReturnValue
113111
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtractor(
114-
Function<
115-
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
116-
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
112+
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
117113
statusExtractor) {
118114
this.statusExtractorTransformer = statusExtractor;
119115
return this;
@@ -180,7 +176,7 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
180176
/** Sets custom {@link SpanNameExtractor} via transform function. */
181177
@CanIgnoreReturnValue
182178
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
183-
Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
179+
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
184180
spanNameExtractorTransformer) {
185181
this.spanNameExtractorTransformer = spanNameExtractorTransformer;
186182
return this;

instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/builder/internal/DefaultHttpServerInstrumenterBuilder.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,14 @@ public final class DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> {
4646

4747
private final List<AttributesExtractor<? super REQUEST, ? super RESPONSE>> additionalExtractors =
4848
new ArrayList<>();
49-
private Function<
50-
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
51-
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
49+
private Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
5250
statusExtractorTransformer = Function.identity();
5351
private final HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE>
5452
httpAttributesExtractorBuilder;
5553
private final HttpSpanNameExtractorBuilder<REQUEST> httpSpanNameExtractorBuilder;
5654

5755
@Nullable private final TextMapGetter<REQUEST> headerGetter;
58-
private Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
56+
private Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
5957
spanNameExtractorTransformer = Function.identity();
6058
private final HttpServerRouteBuilder<REQUEST> httpServerRouteBuilder;
6159
private final HttpServerAttributesGetter<REQUEST, RESPONSE> attributesGetter;
@@ -109,9 +107,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> addAttributesExtr
109107

110108
@CanIgnoreReturnValue
111109
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtractor(
112-
Function<
113-
SpanStatusExtractor<? super REQUEST, ? super RESPONSE>,
114-
? extends SpanStatusExtractor<? super REQUEST, ? super RESPONSE>>
110+
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
115111
statusExtractor) {
116112
this.statusExtractorTransformer = statusExtractor;
117113
return this;
@@ -179,7 +175,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
179175
/** Sets custom {@link SpanNameExtractor} via transform function. */
180176
@CanIgnoreReturnValue
181177
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
182-
Function<SpanNameExtractor<? super REQUEST>, ? extends SpanNameExtractor<? super REQUEST>>
178+
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
183179
spanNameExtractorTransformer) {
184180
this.spanNameExtractorTransformer = spanNameExtractorTransformer;
185181
return this;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.api.semconv.http;
7+
8+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
9+
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
10+
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
11+
import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor;
12+
import java.util.List;
13+
import java.util.Set;
14+
import java.util.function.Function;
15+
16+
public interface HttpClientTelemetryBuilder<REQUEST, RESPONSE> {
17+
18+
@CanIgnoreReturnValue
19+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> addAttributesExtractor(
20+
AttributesExtractor<REQUEST, RESPONSE> attributesExtractor);
21+
22+
@CanIgnoreReturnValue
23+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
24+
List<String> requestHeaders);
25+
26+
@CanIgnoreReturnValue
27+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
28+
List<String> responseHeaders);
29+
30+
@CanIgnoreReturnValue
31+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> setKnownMethods(Set<String> knownMethods);
32+
33+
@CanIgnoreReturnValue
34+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
35+
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
36+
spanNameExtractorTransformer);
37+
38+
@CanIgnoreReturnValue
39+
HttpClientTelemetryBuilder<REQUEST, RESPONSE> setStatusExtractor(
40+
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
41+
statusExtractorTransformer);
42+
43+
Object build();
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.opentelemetry.instrumentation.api.semconv.http;
7+
8+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
9+
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
10+
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
11+
import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor;
12+
import java.util.List;
13+
import java.util.Set;
14+
import java.util.function.Function;
15+
16+
public interface HttpServerTelemetryBuilder<REQUEST, RESPONSE> {
17+
18+
@CanIgnoreReturnValue
19+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> addAttributesExtractor(
20+
AttributesExtractor<REQUEST, RESPONSE> attributesExtractor);
21+
22+
@CanIgnoreReturnValue
23+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
24+
List<String> requestHeaders);
25+
26+
@CanIgnoreReturnValue
27+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
28+
List<String> responseHeaders);
29+
30+
@CanIgnoreReturnValue
31+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> setKnownMethods(Set<String> knownMethods);
32+
33+
@CanIgnoreReturnValue
34+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> setSpanNameExtractor(
35+
Function<SpanNameExtractor<REQUEST>, SpanNameExtractor<REQUEST>>
36+
spanNameExtractorTransformer);
37+
38+
@CanIgnoreReturnValue
39+
HttpServerTelemetryBuilder<REQUEST, RESPONSE> setStatusExtractor(
40+
Function<SpanStatusExtractor<REQUEST, RESPONSE>, SpanStatusExtractor<REQUEST, RESPONSE>>
41+
statusExtractorTransformer);
42+
43+
Object build();
44+
}

instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientTelemetryBuilder.java

+23-5
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
import io.opentelemetry.instrumentation.api.incubator.builder.internal.DefaultHttpClientInstrumenterBuilder;
1212
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
1313
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
14+
import io.opentelemetry.instrumentation.api.instrumenter.SpanStatusExtractor;
1415
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
16+
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientTelemetryBuilder;
1517
import java.util.List;
1618
import java.util.Set;
1719
import java.util.function.Function;
1820
import org.apache.http.HttpResponse;
1921

2022
/** A builder for {@link ApacheHttpClientTelemetry}. */
21-
public final class ApacheHttpClientTelemetryBuilder {
23+
public final class ApacheHttpClientTelemetryBuilder
24+
implements HttpClientTelemetryBuilder<ApacheHttpClientRequest, HttpResponse> {
2225

2326
private static final String INSTRUMENTATION_NAME = "io.opentelemetry.apache-httpclient-4.3";
2427
private final DefaultHttpClientInstrumenterBuilder<ApacheHttpClientRequest, HttpResponse> builder;
@@ -50,10 +53,10 @@ public ApacheHttpClientTelemetryBuilder addAttributeExtractor(
5053
* Adds an additional {@link AttributesExtractor} to invoke to set attributes to instrumented
5154
* items. The {@link AttributesExtractor} will be executed after all default extractors.
5255
*/
56+
@Override
5357
@CanIgnoreReturnValue
5458
public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
55-
AttributesExtractor<? super ApacheHttpClientRequest, ? super HttpResponse>
56-
attributesExtractor) {
59+
AttributesExtractor<ApacheHttpClientRequest, HttpResponse> attributesExtractor) {
5760
builder.addAttributesExtractor(attributesExtractor);
5861
return this;
5962
}
@@ -63,6 +66,7 @@ public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
6366
*
6467
* @param requestHeaders A list of HTTP header names.
6568
*/
69+
@Override
6670
@CanIgnoreReturnValue
6771
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
6872
builder.setCapturedRequestHeaders(requestHeaders);
@@ -74,6 +78,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> r
7478
*
7579
* @param responseHeaders A list of HTTP header names.
7680
*/
81+
@Override
7782
@CanIgnoreReturnValue
7883
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
7984
builder.setCapturedResponseHeaders(responseHeaders);
@@ -93,6 +98,7 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List<String>
9398
* @param knownMethods A set of recognized HTTP request methods.
9499
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
95100
*/
101+
@Override
96102
@CanIgnoreReturnValue
97103
public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
98104
builder.setKnownMethods(knownMethods);
@@ -117,20 +123,32 @@ public ApacheHttpClientTelemetryBuilder setEmitExperimentalHttpClientMetrics(
117123
}
118124

119125
/** Sets custom {@link SpanNameExtractor} via transform function. */
126+
@Override
120127
@CanIgnoreReturnValue
121128
public ApacheHttpClientTelemetryBuilder setSpanNameExtractor(
122129
Function<
123-
SpanNameExtractor<? super ApacheHttpClientRequest>,
124-
? extends SpanNameExtractor<? super ApacheHttpClientRequest>>
130+
SpanNameExtractor<ApacheHttpClientRequest>,
131+
SpanNameExtractor<ApacheHttpClientRequest>>
125132
spanNameExtractorTransformer) {
126133
builder.setSpanNameExtractor(spanNameExtractorTransformer);
127134
return this;
128135
}
129136

137+
@Override
138+
public HttpClientTelemetryBuilder<ApacheHttpClientRequest, HttpResponse> setStatusExtractor(
139+
Function<
140+
SpanStatusExtractor<ApacheHttpClientRequest, HttpResponse>,
141+
SpanStatusExtractor<ApacheHttpClientRequest, HttpResponse>>
142+
statusExtractorTransformer) {
143+
builder.setStatusExtractor(statusExtractorTransformer);
144+
return this;
145+
}
146+
130147
/**
131148
* Returns a new {@link ApacheHttpClientTelemetry} configured with this {@link
132149
* ApacheHttpClientTelemetryBuilder}.
133150
*/
151+
@Override
134152
public ApacheHttpClientTelemetry build() {
135153
return new ApacheHttpClientTelemetry(builder.build(), openTelemetry.getPropagators());
136154
}

instrumentation/apache-httpclient/apache-httpclient-5.2/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v5_2/ApacheHttpClient5TelemetryBuilder.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ public ApacheHttpClient5TelemetryBuilder setEmitExperimentalHttpClientMetrics(
112112
@CanIgnoreReturnValue
113113
public ApacheHttpClient5TelemetryBuilder setSpanNameExtractor(
114114
Function<
115-
SpanNameExtractor<? super ApacheHttpClient5Request>,
116-
? extends SpanNameExtractor<? super ApacheHttpClient5Request>>
115+
SpanNameExtractor<ApacheHttpClient5Request>,
116+
SpanNameExtractor<ApacheHttpClient5Request>>
117117
spanNameExtractorTransformer) {
118118
builder.setSpanNameExtractor(spanNameExtractorTransformer);
119119
return this;

0 commit comments

Comments
 (0)