Skip to content

Commit

Permalink
Add deprecation cycle for removed methods (#7020)
Browse files Browse the repository at this point in the history
Methods were removed in #6892, which was backported to the 1.19.x branch
and included in the 1.19.1 release.
  • Loading branch information
trask authored and opentelemetrybot committed Nov 1, 2022
1 parent 1540a22 commit 8f9136c
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,37 @@ public final class HttpServerAttributesExtractor<REQUEST, RESPONSE>
REQUEST, RESPONSE, HttpServerAttributesGetter<REQUEST, RESPONSE>>
implements SpanKeyProvider {

/**
* Creates the HTTP server attributes extractor with default configuration.
*
* @deprecated Use {@link #create(HttpServerAttributesGetter, NetServerAttributesGetter)} instead.
*/
@Deprecated
public static <REQUEST, RESPONSE> HttpServerAttributesExtractor<REQUEST, RESPONSE> create(
HttpServerAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter) {
return create(httpAttributesGetter, new NoopNetServerAttributesGetter<>());
}

/** Creates the HTTP server attributes extractor with default configuration. */
public static <REQUEST, RESPONSE> HttpServerAttributesExtractor<REQUEST, RESPONSE> create(
HttpServerAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter,
NetServerAttributesGetter<REQUEST> netAttributesGetter) {
return builder(httpAttributesGetter, netAttributesGetter).build();
}

/**
* Returns a new {@link HttpServerAttributesExtractorBuilder} that can be used to configure the
* HTTP client attributes extractor.
*
* @deprecated Use {@link #builder(HttpServerAttributesGetter, NetServerAttributesGetter)}
* instead.
*/
@Deprecated
public static <REQUEST, RESPONSE> HttpServerAttributesExtractorBuilder<REQUEST, RESPONSE> builder(
HttpServerAttributesGetter<REQUEST, RESPONSE> httpAttributesGetter) {
return builder(httpAttributesGetter, new NoopNetServerAttributesGetter<>());
}

/**
* Returns a new {@link HttpServerAttributesExtractorBuilder} that can be used to configure the
* HTTP client attributes extractor.
Expand Down Expand Up @@ -162,4 +186,26 @@ private String clientIp(REQUEST request) {
public SpanKey internalGetSpanKey() {
return SpanKey.HTTP_SERVER;
}

private static class NoopNetServerAttributesGetter<REQUEST>
implements NetServerAttributesGetter<REQUEST> {

@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;
}
}
}

0 comments on commit 8f9136c

Please sign in to comment.