Skip to content

Commit e5a9d1c

Browse files
authored
Change setKnownMethods(Set) to setKnownMethods(Collection) (#12902)
1 parent 02725c1 commit e5a9d1c

File tree

31 files changed

+163
-82
lines changed

31 files changed

+163
-82
lines changed

docs/apidiffs/current_vs_latest/opentelemetry-instrumentation-api.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,18 @@ Comparing source compatibility of opentelemetry-instrumentation-api-2.12.0-SNAPS
44
GENERIC TEMPLATES: === REQUEST:java.lang.Object, === RESPONSE:java.lang.Object
55
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.Collection<java.lang.String>)
66
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.Collection<java.lang.String>)
7+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Collection<java.lang.String>)
78
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder (not serializable)
89
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
910
GENERIC TEMPLATES: === REQUEST:java.lang.Object, === RESPONSE:java.lang.Object
1011
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.Collection<java.lang.String>)
1112
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.Collection<java.lang.String>)
13+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Collection<java.lang.String>)
14+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBuilder (not serializable)
15+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
16+
GENERIC TEMPLATES: === REQUEST:java.lang.Object
17+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBuilder<REQUEST> setKnownMethods(java.util.Collection<java.lang.String>)
18+
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder (not serializable)
19+
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
20+
GENERIC TEMPLATES: === REQUEST:java.lang.Object
21+
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(java.util.Collection<java.lang.String>)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.util.Collection;
3232
import java.util.List;
3333
import java.util.Objects;
34-
import java.util.Set;
3534
import java.util.function.Consumer;
3635
import java.util.function.Function;
3736
import java.util.function.Supplier;
@@ -155,11 +154,11 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
155154
* not supplement it.
156155
*
157156
* @param knownMethods A set of recognized HTTP request methods.
158-
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
157+
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
159158
*/
160159
@CanIgnoreReturnValue
161160
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
162-
Set<String> knownMethods) {
161+
Collection<String> knownMethods) {
163162
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
164163
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
165164
return this;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import java.util.Collection;
3131
import java.util.List;
3232
import java.util.Objects;
33-
import java.util.Set;
3433
import java.util.function.Consumer;
3534
import java.util.function.Function;
3635
import java.util.function.Supplier;
@@ -153,11 +152,11 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
153152
* not supplement it.
154153
*
155154
* @param knownMethods A set of recognized HTTP request methods.
156-
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set)
155+
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Collection)
157156
*/
158157
@CanIgnoreReturnValue
159158
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
160-
Set<String> knownMethods) {
159+
Collection<String> knownMethods) {
161160
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
162161
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
163162
httpServerRouteBuilder.setKnownMethods(knownMethods);

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpClientAttributesExtractorBuilder.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,34 @@ public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
137137
*/
138138
@CanIgnoreReturnValue
139139
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
140-
Set<String> knownMethods) {
140+
Collection<String> knownMethods) {
141141
this.knownMethods = new HashSet<>(knownMethods);
142142
return this;
143143
}
144144

145+
/**
146+
* Configures the extractor to recognize an alternative set of HTTP request methods.
147+
*
148+
* <p>By default, this extractor defines "known" methods as the ones listed in <a
149+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
150+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
151+
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
152+
* instead of it and put the original value in an extra {@code http.request.method_original}
153+
* attribute.
154+
*
155+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
156+
* not supplement it.
157+
*
158+
* @param knownMethods A set of recognized HTTP request methods.
159+
*/
160+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
161+
// it if they're using Set
162+
@CanIgnoreReturnValue
163+
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
164+
Set<String> knownMethods) {
165+
return setKnownMethods((Collection<String>) knownMethods);
166+
}
167+
145168
// visible for tests
146169
@CanIgnoreReturnValue
147170
HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setResendCountIncrementer(

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAttributesExtractorBuilder.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,34 @@ public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
144144
*/
145145
@CanIgnoreReturnValue
146146
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
147-
Set<String> knownMethods) {
147+
Collection<String> knownMethods) {
148148
this.knownMethods = new HashSet<>(knownMethods);
149149
return this;
150150
}
151151

152+
/**
153+
* Configures the extractor to recognize an alternative set of HTTP request methods.
154+
*
155+
* <p>By default, this extractor defines "known" methods as the ones listed in <a
156+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
157+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
158+
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
159+
* instead of it and put the original value in an extra {@code http.request.method_original}
160+
* attribute.
161+
*
162+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
163+
* not supplement it.
164+
*
165+
* @param knownMethods A set of recognized HTTP request methods.
166+
*/
167+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
168+
// it if they're using Set
169+
@CanIgnoreReturnValue
170+
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
171+
Set<String> knownMethods) {
172+
return setKnownMethods((Collection<String>) knownMethods);
173+
}
174+
152175
// visible for tests
153176
@CanIgnoreReturnValue
154177
HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setHttpRouteGetter(

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerRouteBuilder.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
1313
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
1414
import io.opentelemetry.instrumentation.api.internal.HttpRouteState;
15+
import java.util.Collection;
1516
import java.util.HashSet;
1617
import java.util.Set;
1718

@@ -44,11 +45,32 @@ public final class HttpServerRouteBuilder<REQUEST> {
4445
* @param knownMethods A set of recognized HTTP request methods.
4546
*/
4647
@CanIgnoreReturnValue
47-
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
48+
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Collection<String> knownMethods) {
4849
this.knownMethods = new HashSet<>(knownMethods);
4950
return this;
5051
}
5152

53+
/**
54+
* Configures the customizer to recognize an alternative set of HTTP request methods.
55+
*
56+
* <p>By default, this customizer defines "known" methods as the ones listed in <a
57+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
58+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
59+
* unknown method is encountered, the customizer will use the value {@value HttpConstants#_OTHER}
60+
* instead.
61+
*
62+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
63+
* not supplement it.
64+
*
65+
* @param knownMethods A set of recognized HTTP request methods.
66+
*/
67+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
68+
// it if they're using Set
69+
@CanIgnoreReturnValue
70+
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
71+
return setKnownMethods((Collection<String>) knownMethods);
72+
}
73+
5274
/**
5375
* Returns a {@link ContextCustomizer} that initializes an {@link HttpServerRoute} in the {@link
5476
* Context} returned from {@link Instrumenter#start(Context, Object)}. The returned customizer is

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/http/HttpSpanNameExtractorBuilder.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
1313
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1414
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
15+
import java.util.Collection;
1516
import java.util.HashSet;
1617
import java.util.Set;
1718
import javax.annotation.Nullable;
@@ -50,11 +51,33 @@ public HttpSpanNameExtractorBuilder(
5051
* @param knownMethods A set of recognized HTTP request methods.
5152
*/
5253
@CanIgnoreReturnValue
53-
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
54+
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Collection<String> knownMethods) {
5455
this.knownMethods = new HashSet<>(knownMethods);
5556
return this;
5657
}
5758

59+
/**
60+
* Configures the extractor to recognize an alternative set of HTTP request methods.
61+
*
62+
* <p>By default, this extractor defines "known" methods as the ones listed in <a
63+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
64+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
65+
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
66+
* instead of it and put the original value in an extra {@code http.request.method_original}
67+
* attribute.
68+
*
69+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
70+
* not supplement it.
71+
*
72+
* @param knownMethods A set of recognized HTTP request methods.
73+
*/
74+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
75+
// it if they're using Set
76+
@CanIgnoreReturnValue
77+
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
78+
return setKnownMethods((Collection<String>) knownMethods);
79+
}
80+
5881
/**
5982
* Returns a new {@link HttpSpanNameExtractor} with the settings of this {@link
6083
* HttpSpanNameExtractorBuilder}.

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1414
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
1515
import java.util.Collection;
16-
import java.util.Set;
1716
import java.util.function.Function;
1817
import org.apache.http.HttpResponse;
1918

@@ -98,10 +97,10 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
9897
* not supplement it.
9998
*
10099
* @param knownMethods A set of recognized HTTP request methods.
101-
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
100+
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
102101
*/
103102
@CanIgnoreReturnValue
104-
public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
103+
public ApacheHttpClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
105104
builder.setKnownMethods(knownMethods);
106105
return this;
107106
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
1414
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
1515
import java.util.Collection;
16-
import java.util.Set;
1716
import java.util.function.Function;
1817
import org.apache.hc.core5.http.HttpResponse;
1918

@@ -83,10 +82,10 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
8382
* not supplement it.
8483
*
8584
* @param knownMethods A set of recognized HTTP request methods.
86-
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
85+
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
8786
*/
8887
@CanIgnoreReturnValue
89-
public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
88+
public ApacheHttpClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
9089
builder.setKnownMethods(knownMethods);
9190
return this;
9291
}

instrumentation/armeria/armeria-1.3/library/src/main/java/io/opentelemetry/instrumentation/armeria/v1_3/ArmeriaClientTelemetryBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
1919
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
2020
import java.util.Collection;
21-
import java.util.Set;
2221
import java.util.function.Function;
2322

2423
public final class ArmeriaClientTelemetryBuilder {
@@ -94,10 +93,10 @@ public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(
9493
* not supplement it.
9594
*
9695
* @param knownMethods A set of recognized HTTP request methods.
97-
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
96+
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
9897
*/
9998
@CanIgnoreReturnValue
100-
public ArmeriaClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
99+
public ArmeriaClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
101100
builder.setKnownMethods(knownMethods);
102101
return this;
103102
}

0 commit comments

Comments
 (0)