From 8f9136c7c568fbacc4d614d997da113a4f26d4e5 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 1 Nov 2022 12:25:28 -0700 Subject: [PATCH] Add deprecation cycle for removed methods (#7020) Methods were removed in #6892, which was backported to the 1.19.x branch and included in the 1.19.1 release. --- .../http/HttpServerAttributesExtractor.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractor.java index 7b23a3fa3757..e319593fbafb 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpServerAttributesExtractor.java @@ -36,6 +36,17 @@ public final class HttpServerAttributesExtractor REQUEST, RESPONSE, HttpServerAttributesGetter> implements SpanKeyProvider { + /** + * Creates the HTTP server attributes extractor with default configuration. + * + * @deprecated Use {@link #create(HttpServerAttributesGetter, NetServerAttributesGetter)} instead. + */ + @Deprecated + public static HttpServerAttributesExtractor create( + HttpServerAttributesGetter httpAttributesGetter) { + return create(httpAttributesGetter, new NoopNetServerAttributesGetter<>()); + } + /** Creates the HTTP server attributes extractor with default configuration. */ public static HttpServerAttributesExtractor create( HttpServerAttributesGetter httpAttributesGetter, @@ -43,6 +54,19 @@ public static HttpServerAttributesExtractor HttpServerAttributesExtractorBuilder builder( + HttpServerAttributesGetter httpAttributesGetter) { + return builder(httpAttributesGetter, new NoopNetServerAttributesGetter<>()); + } + /** * Returns a new {@link HttpServerAttributesExtractorBuilder} that can be used to configure the * HTTP client attributes extractor. @@ -162,4 +186,26 @@ private String clientIp(REQUEST request) { public SpanKey internalGetSpanKey() { return SpanKey.HTTP_SERVER; } + + private static class NoopNetServerAttributesGetter + implements NetServerAttributesGetter { + + @Nullable + @Override + public String transport(REQUEST request) { + return null; + } + + @Nullable + @Override + public String hostName(REQUEST request) { + return null; + } + + @Nullable + @Override + public Integer hostPort(REQUEST request) { + return null; + } + } }