Skip to content

Commit

Permalink
Change setKnownMethods(Set) to setKnownMethods(Collection) (#12902)
Browse files Browse the repository at this point in the history
  • Loading branch information
trask authored Dec 24, 2024
1 parent 02725c1 commit e5a9d1c
Show file tree
Hide file tree
Showing 31 changed files with 163 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ Comparing source compatibility of opentelemetry-instrumentation-api-2.12.0-SNAPS
GENERIC TEMPLATES: === REQUEST:java.lang.Object, === RESPONSE:java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.Collection<java.lang.String>)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.Collection<java.lang.String>)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Collection<java.lang.String>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
GENERIC TEMPLATES: === REQUEST:java.lang.Object, === RESPONSE:java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedRequestHeaders(java.util.Collection<java.lang.String>)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setCapturedResponseHeaders(java.util.Collection<java.lang.String>)
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder<REQUEST,RESPONSE> setKnownMethods(java.util.Collection<java.lang.String>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
GENERIC TEMPLATES: === REQUEST:java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpServerRouteBuilder<REQUEST> setKnownMethods(java.util.Collection<java.lang.String>)
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder (not serializable)
=== CLASS FILE FORMAT VERSION: 52.0 <- 52.0
GENERIC TEMPLATES: === REQUEST:java.lang.Object
+++ NEW METHOD: PUBLIC(+) io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(java.util.Collection<java.lang.String>)
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
Expand Down Expand Up @@ -155,11 +154,11 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
Collection<String> knownMethods) {
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
Expand Down Expand Up @@ -153,11 +152,11 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRespon
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
Collection<String> knownMethods) {
httpAttributesExtractorBuilder.setKnownMethods(knownMethods);
httpSpanNameExtractorBuilder.setKnownMethods(knownMethods);
httpServerRouteBuilder.setKnownMethods(knownMethods);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,34 @@ public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
*/
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
Collection<String> knownMethods) {
this.knownMethods = new HashSet<>(knownMethods);
return this;
}

/**
* Configures the extractor to recognize an alternative set of HTTP request methods.
*
* <p>By default, this extractor defines "known" methods as the ones listed in <a
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
* instead of it and put the original value in an extra {@code http.request.method_original}
* attribute.
*
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using Set
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
return setKnownMethods((Collection<String>) knownMethods);
}

// visible for tests
@CanIgnoreReturnValue
HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setResendCountIncrementer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,34 @@ public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRespon
*/
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
Collection<String> knownMethods) {
this.knownMethods = new HashSet<>(knownMethods);
return this;
}

/**
* Configures the extractor to recognize an alternative set of HTTP request methods.
*
* <p>By default, this extractor defines "known" methods as the ones listed in <a
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
* instead of it and put the original value in an extra {@code http.request.method_original}
* attribute.
*
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using Set
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setKnownMethods(
Set<String> knownMethods) {
return setKnownMethods((Collection<String>) knownMethods);
}

// visible for tests
@CanIgnoreReturnValue
HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setHttpRouteGetter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder;
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
import io.opentelemetry.instrumentation.api.internal.HttpRouteState;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -44,11 +45,32 @@ public final class HttpServerRouteBuilder<REQUEST> {
* @param knownMethods A set of recognized HTTP request methods.
*/
@CanIgnoreReturnValue
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Collection<String> knownMethods) {
this.knownMethods = new HashSet<>(knownMethods);
return this;
}

/**
* Configures the customizer to recognize an alternative set of HTTP request methods.
*
* <p>By default, this customizer defines "known" methods as the ones listed in <a
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
* unknown method is encountered, the customizer will use the value {@value HttpConstants#_OTHER}
* instead.
*
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using Set
@CanIgnoreReturnValue
public HttpServerRouteBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
return setKnownMethods((Collection<String>) knownMethods);
}

/**
* Returns a {@link ContextCustomizer} that initializes an {@link HttpServerRoute} in the {@link
* Context} returned from {@link Instrumenter#start(Context, Object)}. The returned customizer is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.internal.HttpConstants;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -50,11 +51,33 @@ public HttpSpanNameExtractorBuilder(
* @param knownMethods A set of recognized HTTP request methods.
*/
@CanIgnoreReturnValue
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Collection<String> knownMethods) {
this.knownMethods = new HashSet<>(knownMethods);
return this;
}

/**
* Configures the extractor to recognize an alternative set of HTTP request methods.
*
* <p>By default, this extractor defines "known" methods as the ones listed in <a
* href="https://www.rfc-editor.org/rfc/rfc9110.html#name-methods">RFC9110</a> and the PATCH
* method defined in <a href="https://www.rfc-editor.org/rfc/rfc5789.html">RFC5789</a>. If an
* unknown method is encountered, the extractor will use the value {@value HttpConstants#_OTHER}
* instead of it and put the original value in an extra {@code http.request.method_original}
* attribute.
*
* <p>Note: calling this method <b>overrides</b> the default known method sets completely; it does
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using Set
@CanIgnoreReturnValue
public HttpSpanNameExtractorBuilder<REQUEST> setKnownMethods(Set<String> knownMethods) {
return setKnownMethods((Collection<String>) knownMethods);
}

/**
* Returns a new {@link HttpSpanNameExtractor} with the settings of this {@link
* HttpSpanNameExtractorBuilder}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import org.apache.http.HttpResponse;

Expand Down Expand Up @@ -98,10 +97,10 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public ApacheHttpClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import org.apache.hc.core5.http.HttpResponse;

Expand Down Expand Up @@ -83,10 +82,10 @@ public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public ApacheHttpClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

public final class ArmeriaClientTelemetryBuilder {
Expand Down Expand Up @@ -94,10 +93,10 @@ public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public ArmeriaClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

public final class ArmeriaServerTelemetryBuilder {
Expand Down Expand Up @@ -92,10 +91,10 @@ public ArmeriaServerTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public ArmeriaServerTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ public ArmeriaTelemetryBuilder setCapturedServerResponseHeaders(List<String> res
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Set)
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setKnownMethods(Set)} and {@link
* ArmeriaServerTelemetryBuilder#setKnownMethods(Set)} instead.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
* @see HttpServerAttributesExtractorBuilder#setKnownMethods(Collection)
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setKnownMethods(Collection)} and {@link
* ArmeriaServerTelemetryBuilder#setKnownMethods(Collection)} instead.
*/
@Deprecated
@CanIgnoreReturnValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.instrumentation.elasticsearch.rest.internal.ElasticsearchRestInstrumenterFactory;
import io.opentelemetry.instrumentation.elasticsearch.rest.internal.ElasticsearchRestRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -60,10 +61,10 @@ public ElasticsearchRest7TelemetryBuilder addAttributesExtractor(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public ElasticsearchRest7TelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public ElasticsearchRest7TelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
this.knownMethods = new HashSet<>(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

public final class JavaHttpClientTelemetryBuilder {
Expand Down Expand Up @@ -95,10 +94,10 @@ public JavaHttpClientTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public JavaHttpClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public JavaHttpClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.Experimental;
import io.opentelemetry.instrumentation.jetty.httpclient.v12_0.internal.JettyHttpClientInstrumenterBuilderFactory;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.Request;
Expand Down Expand Up @@ -109,10 +108,10 @@ public JettyClientTelemetryBuilder setCapturedResponseHeaders(
* not supplement it.
*
* @param knownMethods A set of recognized HTTP request methods.
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Set)
* @see HttpClientAttributesExtractorBuilder#setKnownMethods(Collection)
*/
@CanIgnoreReturnValue
public JettyClientTelemetryBuilder setKnownMethods(Set<String> knownMethods) {
public JettyClientTelemetryBuilder setKnownMethods(Collection<String> knownMethods) {
builder.setKnownMethods(knownMethods);
return this;
}
Expand Down
Loading

0 comments on commit e5a9d1c

Please sign in to comment.