Skip to content

Commit 4bad1b4

Browse files
committed
part1
1 parent 9865c17 commit 4bad1b4

File tree

6 files changed

+103
-10
lines changed

6 files changed

+103
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
2929
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
3030
import java.util.ArrayList;
31+
import java.util.Collection;
3132
import java.util.List;
3233
import java.util.Objects;
33-
import java.util.Set;
3434
import java.util.function.Consumer;
3535
import java.util.function.Function;
3636
import java.util.function.Supplier;
@@ -154,11 +154,11 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
154154
* not supplement it.
155155
*
156156
* @param knownMethods A set of recognized HTTP request methods.
157-
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
157+
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
158158
*/
159159
@CanIgnoreReturnValue
160160
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
161-
Set<String> knownMethods) {
161+
Collection<String> knownMethods) {
162162
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
163163
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
164164
return this;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
2828
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
2929
import java.util.ArrayList;
30+
import java.util.Collection;
3031
import java.util.List;
3132
import java.util.Objects;
32-
import java.util.Set;
3333
import java.util.function.Consumer;
3434
import java.util.function.Function;
3535
import java.util.function.Supplier;
@@ -152,11 +152,11 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
152152
* not supplement it.
153153
*
154154
* @param knownMethods A set of recognized HTTP request methods.
155-
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set)
155+
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Collection)
156156
*/
157157
@CanIgnoreReturnValue
158158
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
159-
Set<String> knownMethods) {
159+
Collection<String> knownMethods) {
160160
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
161161
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
162162
httpServerRouteBuilder.setKnownMethods(knownMethods);

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
1818
import io.opentelemetry.instrumentation.api.semconv.network.internal.ServerAddressAndPortExtractor;
1919
import java.util.ArrayList;
20+
import java.util.Collection;
2021
import java.util.HashSet;
2122
import java.util.List;
2223
import java.util.Set;
@@ -98,11 +99,34 @@ public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
9899
*/
99100
@CanIgnoreReturnValue
100101
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
101-
Set<String> knownMethods) {
102+
Collection<String> knownMethods) {
102103
this.knownMethods = new HashSet<>(knownMethods);
103104
return this;
104105
}
105106

107+
/**
108+
* Configures the extractor to recognize an alternative set of HTTP request methods.
109+
*
110+
* <p>By default, this extractor defines "known" methods as the ones listed in <a
111+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
112+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
113+
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
114+
* instead of it and put the original value in an extra {@code http.request.method_original}
115+
* attribute.
116+
*
117+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
118+
* not supplement it.
119+
*
120+
* @param knownMethods A set of recognized HTTP request methods.
121+
*/
122+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
123+
// it if they're using Set
124+
@CanIgnoreReturnValue
125+
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
126+
Set<String> knownMethods) {
127+
return setKnownMethods((Collection<String>) knownMethods);
128+
}
129+
106130
// visible for tests
107131
@CanIgnoreReturnValue
108132
HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setResendCountIncrementer(

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
2020
import io.opentelemetry.instrumentation.api.semconv.url.internal.InternalUrlAttributesExtractor;
2121
import java.util.ArrayList;
22+
import java.util.Collection;
2223
import java.util.HashSet;
2324
import java.util.List;
2425
import java.util.Set;
@@ -104,11 +105,34 @@ public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
104105
*/
105106
@CanIgnoreReturnValue
106107
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
107-
Set<String> knownMethods) {
108+
Collection<String> knownMethods) {
108109
this.knownMethods = new HashSet<>(knownMethods);
109110
return this;
110111
}
111112

113+
/**
114+
* Configures the extractor to recognize an alternative set of HTTP request methods.
115+
*
116+
* <p>By default, this extractor defines "known" methods as the ones listed in <a
117+
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
118+
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
119+
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
120+
* instead of it and put the original value in an extra {@code http.request.method_original}
121+
* attribute.
122+
*
123+
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
124+
* not supplement it.
125+
*
126+
* @param knownMethods A set of recognized HTTP request methods.
127+
*/
128+
// don't deprecate this since users will get deprecation warning without a clean way to suppress
129+
// it if they're using Set
130+
@CanIgnoreReturnValue
131+
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
132+
Set<String> knownMethods) {
133+
return setKnownMethods((Collection<String>) knownMethods);
134+
}
135+
112136
// visible for tests
113137
@CanIgnoreReturnValue
114138
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}.

0 commit comments

Comments
 (0)