Skip to content

Commit

Permalink
Change setCaptured*Headers(List) to `setCaptured*Headers(Collection…
Browse files Browse the repository at this point in the history
…)` (#12901)
  • Loading branch information
trask authored Dec 23, 2024
1 parent 5f135ba commit 6b9e68e
Show file tree
Hide file tree
Showing 36 changed files with 235 additions and 100 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
Comparing source compatibility of opentelemetry-instrumentation-api-2.12.0-SNAPSHOT.jar against opentelemetry-instrumentation-api-2.11.0.jar
No changes.
*** MODIFIED CLASS: PUBLIC FINAL io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder (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.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>)
*** 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>)
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -126,7 +127,7 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtracto
*/
@CanIgnoreReturnValue
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
Collection<String> requestHeaders) {
httpAttributesExtractorBuilder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -138,7 +139,7 @@ public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedReques
*/
@CanIgnoreReturnValue
public DefaultHttpClientInstrumenterBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
Collection<String> responseHeaders) {
httpAttributesExtractorBuilder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanNameExtractorBuilder;
import io.opentelemetry.instrumentation.api.semconv.http.HttpSpanStatusExtractor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -124,7 +125,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setStatusExtracto
*/
@CanIgnoreReturnValue
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
Collection<String> requestHeaders) {
httpAttributesExtractorBuilder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -136,7 +137,7 @@ public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedReques
*/
@CanIgnoreReturnValue
public DefaultHttpServerInstrumenterBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
Collection<String> responseHeaders) {
httpAttributesExtractorBuilder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/** A builder of {@link MessagingAttributesExtractor}. */
Expand All @@ -35,8 +37,8 @@ public final class MessagingAttributesExtractorBuilder<REQUEST, RESPONSE> {
*/
@CanIgnoreReturnValue
public MessagingAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedHeaders(
List<String> capturedHeaders) {
this.capturedHeaders = capturedHeaders;
Collection<String> capturedHeaders) {
this.capturedHeaders = new ArrayList<>(capturedHeaders);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.network.internal.ServerAddressAndPortExtractor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -57,11 +58,29 @@ public final class HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> {
*/
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
Collection<String> requestHeaders) {
this.capturedRequestHeaders = new ArrayList<>(requestHeaders);
return this;
}

/**
* Configures the HTTP request headers that will be captured as span attributes as described in <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#http-client">HTTP
* semantic conventions</a>.
*
* <p>The HTTP request header values will be captured under the {@code http.request.header.<key>}
* attribute key. The {@code <key>} part in the attribute key is the lowercase header name.
*
* @param requestHeaders A list of HTTP header names.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using List
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
return setCapturedRequestHeaders((Collection<String>) requestHeaders);
}

/**
* Configures the HTTP response headers that will be captured as span attributes as described in
* <a
Expand All @@ -76,11 +95,31 @@ public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedReques
*/
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
Collection<String> responseHeaders) {
this.capturedResponseHeaders = new ArrayList<>(responseHeaders);
return this;
}

/**
* Configures the HTTP response headers that will be captured as span attributes as described in
* <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#common-attributes">HTTP
* semantic conventions</a>.
*
* <p>The HTTP response header values will be captured under the {@code
* http.response.header.<key>} attribute key. The {@code <key>} part in the attribute key is the
* lowercase header name.
*
* @param responseHeaders A list of HTTP header names.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using List
@CanIgnoreReturnValue
public HttpClientAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
return setCapturedResponseHeaders((Collection<String>) responseHeaders);
}

/**
* Configures the extractor to recognize an alternative set of HTTP request methods.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.opentelemetry.instrumentation.api.semconv.network.internal.InternalServerAttributesExtractor;
import io.opentelemetry.instrumentation.api.semconv.url.internal.InternalUrlAttributesExtractor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -63,11 +64,30 @@ public final class HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> {
*/
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
Collection<String> requestHeaders) {
this.capturedRequestHeaders = new ArrayList<>(requestHeaders);
return this;
}

/**
* Configures the HTTP response headers that will be captured as span attributes as described in
* <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#http-server-semantic-conventions">HTTP
* semantic conventions</a>.
*
* <p>The HTTP request header values will be captured under the {@code http.request.header.<key>}
* attribute key. The {@code <key>} part in the attribute key is the lowercase header name.
*
* @param requestHeaders A list of HTTP header names.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using List
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedRequestHeaders(
List<String> requestHeaders) {
return setCapturedRequestHeaders((Collection<String>) requestHeaders);
}

/**
* Configures the HTTP response headers that will be captured as span attributes as described in
* <a
Expand All @@ -82,11 +102,31 @@ public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedReques
*/
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
Collection<String> responseHeaders) {
this.capturedResponseHeaders = new ArrayList<>(responseHeaders);
return this;
}

/**
* Configures the HTTP response headers that will be captured as span attributes as described in
* <a
* href="https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/http/http-spans.md#common-attributes">HTTP
* semantic conventions</a>.
*
* <p>The HTTP response header values will be captured under the {@code
* http.response.header.<key>} attribute key. The {@code <key>} part in the attribute key is the
* lowercase header name.
*
* @param responseHeaders A list of HTTP header names.
*/
// don't deprecate this since users will get deprecation warning without a clean way to suppress
// it if they're using List
@CanIgnoreReturnValue
public HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> setCapturedResponseHeaders(
List<String> responseHeaders) {
return setCapturedResponseHeaders((Collection<String>) responseHeaders);
}

/**
* Configures the extractor to recognize an alternative set of HTTP request methods.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import java.util.List;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import org.apache.http.HttpResponse;
Expand Down Expand Up @@ -69,7 +69,8 @@ public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
* @param requestHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(
Collection<String> requestHeaders) {
builder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -80,7 +81,8 @@ public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> r
* @param responseHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
Collection<String> responseHeaders) {
builder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor;
import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractorBuilder;
import java.util.List;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import org.apache.hc.core5.http.HttpResponse;
Expand Down Expand Up @@ -54,7 +54,8 @@ public ApacheHttpClientTelemetryBuilder addAttributesExtractor(
* @param requestHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(
Collection<String> requestHeaders) {
builder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -65,7 +66,8 @@ public ApacheHttpClientTelemetryBuilder setCapturedRequestHeaders(List<String> r
* @param responseHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
public ApacheHttpClientTelemetryBuilder setCapturedResponseHeaders(
Collection<String> responseHeaders) {
builder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.List;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

Expand Down Expand Up @@ -65,7 +65,8 @@ public ArmeriaClientTelemetryBuilder addAttributesExtractor(
* @param requestHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
public ArmeriaClientTelemetryBuilder setCapturedRequestHeaders(
Collection<String> requestHeaders) {
builder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -76,7 +77,8 @@ public ArmeriaClientTelemetryBuilder setCapturedRequestHeaders(List<String> requ
* @param responseHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
public ArmeriaClientTelemetryBuilder setCapturedResponseHeaders(
Collection<String> responseHeaders) {
builder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderUtil;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.List;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;

Expand Down Expand Up @@ -63,7 +63,8 @@ public ArmeriaServerTelemetryBuilder addAttributesExtractor(
* @param requestHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder setCapturedRequestHeaders(List<String> requestHeaders) {
public ArmeriaServerTelemetryBuilder setCapturedRequestHeaders(
Collection<String> requestHeaders) {
builder.setCapturedRequestHeaders(requestHeaders);
return this;
}
Expand All @@ -74,7 +75,8 @@ public ArmeriaServerTelemetryBuilder setCapturedRequestHeaders(List<String> requ
* @param responseHeaders A list of HTTP header names.
*/
@CanIgnoreReturnValue
public ArmeriaServerTelemetryBuilder setCapturedResponseHeaders(List<String> responseHeaders) {
public ArmeriaServerTelemetryBuilder setCapturedResponseHeaders(
Collection<String> responseHeaders) {
builder.setCapturedResponseHeaders(responseHeaders);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.opentelemetry.instrumentation.api.semconv.http.HttpServerAttributesExtractorBuilder;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.ArmeriaInstrumenterBuilderFactory;
import io.opentelemetry.instrumentation.armeria.v1_3.internal.Experimental;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -158,7 +159,8 @@ public ArmeriaTelemetryBuilder setPeerService(String peerService) {
* Configures the HTTP client request headers that will be captured as span attributes.
*
* @param requestHeaders A list of HTTP header names.
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setCapturedRequestHeaders(List)} instead.
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setCapturedRequestHeaders(Collection)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
Expand All @@ -171,7 +173,8 @@ public ArmeriaTelemetryBuilder setCapturedClientRequestHeaders(List<String> requ
* Configures the HTTP client response headers that will be captured as span attributes.
*
* @param responseHeaders A list of HTTP header names.
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setCapturedResponseHeaders(List)} instead.
* @deprecated Use {@link ArmeriaClientTelemetryBuilder#setCapturedResponseHeaders(Collection)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
Expand All @@ -184,7 +187,8 @@ public ArmeriaTelemetryBuilder setCapturedClientResponseHeaders(List<String> res
* Configures the HTTP server request headers that will be captured as span attributes.
*
* @param requestHeaders A list of HTTP header names.
* @deprecated Use {@link ArmeriaServerTelemetryBuilder#setCapturedRequestHeaders(List)} instead.
* @deprecated Use {@link ArmeriaServerTelemetryBuilder#setCapturedRequestHeaders(Collection)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
Expand All @@ -197,7 +201,8 @@ public ArmeriaTelemetryBuilder setCapturedServerRequestHeaders(List<String> requ
* Configures the HTTP server response headers that will be captured as span attributes.
*
* @param responseHeaders A list of HTTP header names.
* @deprecated Use {@link ArmeriaServerTelemetryBuilder#setCapturedResponseHeaders(List)} instead.
* @deprecated Use {@link ArmeriaServerTelemetryBuilder#setCapturedResponseHeaders(Collection)}
* instead.
*/
@Deprecated
@CanIgnoreReturnValue
Expand Down
Loading

0 comments on commit 6b9e68e

Please sign in to comment.