Remove deprecated methods
This commit is contained in:
parent
299c396eab
commit
b0c5b2cd78
|
@ -2,8 +2,6 @@ apply from: "${rootDir}/gradle/java.gradle"
|
|||
|
||||
minimumBranchCoverage = 0.6
|
||||
excludedClassesCoverage += ['datadog.trace.agent.tooling.*']
|
||||
// this exclusion is temporary, until deprecated methods are removed (see subsequent commit)
|
||||
excludedClassesCoverage += ['datadog.trace.agent.decorator.*']
|
||||
|
||||
configurations {
|
||||
// classpath used by the instrumentation muzzle plugin
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
package datadog.trace.agent.decorator;
|
||||
|
||||
import static io.opentracing.log.Fields.ERROR_OBJECT;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
||||
import datadog.trace.api.Config;
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentScope;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Scope;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.Inet4Address;
|
||||
|
@ -44,32 +39,12 @@ public abstract class BaseDecorator {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Scope afterStart(final Scope scope) {
|
||||
assert scope != null;
|
||||
afterStart(scope.span());
|
||||
return scope;
|
||||
}
|
||||
|
||||
public AgentScope afterStart(final AgentScope scope) {
|
||||
assert scope != null;
|
||||
afterStart(scope.span());
|
||||
return scope;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
if (spanType() != null) {
|
||||
span.setTag(DDTags.SPAN_TYPE, spanType());
|
||||
}
|
||||
Tags.COMPONENT.set(span, component());
|
||||
if (traceAnalyticsEnabled) {
|
||||
span.setTag(DDTags.ANALYTICS_SAMPLE_RATE, traceAnalyticsSampleRate);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan afterStart(final AgentSpan span) {
|
||||
assert span != null;
|
||||
if (spanType() != null) {
|
||||
|
@ -82,56 +57,23 @@ public abstract class BaseDecorator {
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Scope beforeFinish(final Scope scope) {
|
||||
assert scope != null;
|
||||
beforeFinish(scope.span());
|
||||
return scope;
|
||||
}
|
||||
|
||||
public AgentScope beforeFinish(final AgentScope scope) {
|
||||
assert scope != null;
|
||||
beforeFinish(scope.span());
|
||||
return scope;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span beforeFinish(final Span span) {
|
||||
assert span != null;
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan beforeFinish(final AgentSpan span) {
|
||||
assert span != null;
|
||||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Scope onError(final Scope scope, final Throwable throwable) {
|
||||
assert scope != null;
|
||||
onError(scope.span(), throwable);
|
||||
return scope;
|
||||
}
|
||||
|
||||
public AgentScope onError(final AgentScope scope, final Throwable throwable) {
|
||||
assert scope != null;
|
||||
onError(scope.span(), throwable);
|
||||
return scope;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onError(final Span span, final Throwable throwable) {
|
||||
assert span != null;
|
||||
if (throwable != null) {
|
||||
Tags.ERROR.set(span, true);
|
||||
span.log(
|
||||
singletonMap(
|
||||
ERROR_OBJECT,
|
||||
throwable instanceof ExecutionException ? throwable.getCause() : throwable));
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onError(final AgentSpan span, final Throwable throwable) {
|
||||
assert span != null;
|
||||
if (throwable != null) {
|
||||
|
@ -141,18 +83,6 @@ public abstract class BaseDecorator {
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onPeerConnection(final Span span, final InetSocketAddress remoteConnection) {
|
||||
assert span != null;
|
||||
if (remoteConnection != null) {
|
||||
onPeerConnection(span, remoteConnection.getAddress());
|
||||
|
||||
span.setTag(Tags.PEER_HOSTNAME.getKey(), remoteConnection.getHostName());
|
||||
span.setTag(Tags.PEER_PORT.getKey(), remoteConnection.getPort());
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onPeerConnection(
|
||||
final AgentSpan span, final InetSocketAddress remoteConnection) {
|
||||
assert span != null;
|
||||
|
@ -165,20 +95,6 @@ public abstract class BaseDecorator {
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onPeerConnection(final Span span, final InetAddress remoteAddress) {
|
||||
assert span != null;
|
||||
if (remoteAddress != null) {
|
||||
span.setTag(Tags.PEER_HOSTNAME.getKey(), remoteAddress.getHostName());
|
||||
if (remoteAddress instanceof Inet4Address) {
|
||||
Tags.PEER_HOST_IPV4.set(span, remoteAddress.getHostAddress());
|
||||
} else if (remoteAddress instanceof Inet6Address) {
|
||||
Tags.PEER_HOST_IPV6.set(span, remoteAddress.getHostAddress());
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onPeerConnection(final AgentSpan span, final InetAddress remoteAddress) {
|
||||
assert span != null;
|
||||
if (remoteAddress != null) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package datadog.trace.agent.decorator;
|
|||
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
|
||||
public abstract class ClientDecorator extends BaseDecorator {
|
||||
|
@ -13,16 +12,6 @@ public abstract class ClientDecorator extends BaseDecorator {
|
|||
return Tags.SPAN_KIND_CLIENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
if (service() != null) {
|
||||
span.setTag(DDTags.SERVICE_NAME, service());
|
||||
}
|
||||
Tags.SPAN_KIND.set(span, spanKind());
|
||||
return super.afterStart(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentSpan afterStart(final AgentSpan span) {
|
||||
assert span != null;
|
||||
|
|
|
@ -3,7 +3,6 @@ package datadog.trace.agent.decorator;
|
|||
import datadog.trace.api.Config;
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
|
||||
public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorator {
|
||||
|
@ -14,14 +13,6 @@ public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorato
|
|||
|
||||
protected abstract String dbInstance(CONNECTION connection);
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
Tags.DB_TYPE.set(span, dbType());
|
||||
return super.afterStart(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentSpan afterStart(final AgentSpan span) {
|
||||
assert span != null;
|
||||
|
@ -29,28 +20,6 @@ public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorato
|
|||
return super.afterStart(span);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be called when the connection is being used, not when it's created.
|
||||
*
|
||||
* @param span
|
||||
* @param connection
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public Span onConnection(final Span span, final CONNECTION connection) {
|
||||
assert span != null;
|
||||
if (connection != null) {
|
||||
Tags.DB_USER.set(span, dbUser(connection));
|
||||
final String instanceName = dbInstance(connection);
|
||||
Tags.DB_INSTANCE.set(span, instanceName);
|
||||
|
||||
if (instanceName != null && Config.get().isDbClientSplitByInstance()) {
|
||||
span.setTag(DDTags.SERVICE_NAME, instanceName);
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
/**
|
||||
* This should be called when the connection is being used, not when it's created.
|
||||
*
|
||||
|
@ -72,13 +41,6 @@ public abstract class DatabaseClientDecorator<CONNECTION> extends ClientDecorato
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onStatement(final Span span, final String statement) {
|
||||
assert span != null;
|
||||
Tags.DB_STATEMENT.set(span, statement);
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onStatement(final AgentSpan span, final String statement) {
|
||||
assert span != null;
|
||||
span.setTag(Tags.DB_STATEMENT.getKey(), statement);
|
||||
|
|
|
@ -4,7 +4,6 @@ import datadog.trace.api.Config;
|
|||
import datadog.trace.api.DDSpanTypes;
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -33,58 +32,6 @@ public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends ClientDecor
|
|||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onRequest(final Span span, final REQUEST request) {
|
||||
assert span != null;
|
||||
if (request != null) {
|
||||
Tags.HTTP_METHOD.set(span, method(request));
|
||||
|
||||
// Copy of HttpServerDecorator url handling
|
||||
try {
|
||||
final URI url = url(request);
|
||||
if (url != null) {
|
||||
final StringBuilder urlNoParams = new StringBuilder();
|
||||
if (url.getScheme() != null) {
|
||||
urlNoParams.append(url.getScheme());
|
||||
urlNoParams.append("://");
|
||||
}
|
||||
if (url.getHost() != null) {
|
||||
urlNoParams.append(url.getHost());
|
||||
if (url.getPort() > 0 && url.getPort() != 80 && url.getPort() != 443) {
|
||||
urlNoParams.append(":");
|
||||
urlNoParams.append(url.getPort());
|
||||
}
|
||||
}
|
||||
final String path = url.getPath();
|
||||
if (path.isEmpty()) {
|
||||
urlNoParams.append("/");
|
||||
} else {
|
||||
urlNoParams.append(path);
|
||||
}
|
||||
|
||||
Tags.HTTP_URL.set(span, urlNoParams.toString());
|
||||
|
||||
if (Config.get().isHttpClientTagQueryString()) {
|
||||
span.setTag(DDTags.HTTP_QUERY, url.getQuery());
|
||||
span.setTag(DDTags.HTTP_FRAGMENT, url.getFragment());
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug("Error tagging url", e);
|
||||
}
|
||||
|
||||
Tags.PEER_HOSTNAME.set(span, hostname(request));
|
||||
final Integer port = port(request);
|
||||
// Negative or Zero ports might represent an unset/null value for an int type. Skip setting.
|
||||
Tags.PEER_PORT.set(span, port != null && port > 0 ? port : null);
|
||||
|
||||
if (Config.get().isHttpClientSplitByDomain()) {
|
||||
span.setTag(DDTags.SERVICE_NAME, hostname(request));
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onRequest(final AgentSpan span, final REQUEST request) {
|
||||
assert span != null;
|
||||
if (request != null) {
|
||||
|
@ -138,22 +85,6 @@ public abstract class HttpClientDecorator<REQUEST, RESPONSE> extends ClientDecor
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onResponse(final Span span, final RESPONSE response) {
|
||||
assert span != null;
|
||||
if (response != null) {
|
||||
final Integer status = status(response);
|
||||
if (status != null) {
|
||||
Tags.HTTP_STATUS.set(span, status);
|
||||
|
||||
if (Config.get().getHttpClientErrorStatuses().contains(status)) {
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
|
||||
assert span != null;
|
||||
if (response != null) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import datadog.trace.api.Config;
|
|||
import datadog.trace.api.DDSpanTypes;
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -42,50 +41,6 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE> extends
|
|||
return Config.get().isTraceAnalyticsEnabled();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onRequest(final Span span, final REQUEST request) {
|
||||
assert span != null;
|
||||
if (request != null) {
|
||||
Tags.HTTP_METHOD.set(span, method(request));
|
||||
|
||||
// Copy of HttpClientDecorator url handling
|
||||
try {
|
||||
final URI url = url(request);
|
||||
if (url != null) {
|
||||
final StringBuilder urlNoParams = new StringBuilder();
|
||||
if (url.getScheme() != null) {
|
||||
urlNoParams.append(url.getScheme());
|
||||
urlNoParams.append("://");
|
||||
}
|
||||
if (url.getHost() != null) {
|
||||
urlNoParams.append(url.getHost());
|
||||
if (url.getPort() > 0 && url.getPort() != 80 && url.getPort() != 443) {
|
||||
urlNoParams.append(":");
|
||||
urlNoParams.append(url.getPort());
|
||||
}
|
||||
}
|
||||
final String path = url.getPath();
|
||||
if (path.isEmpty()) {
|
||||
urlNoParams.append("/");
|
||||
} else {
|
||||
urlNoParams.append(path);
|
||||
}
|
||||
|
||||
Tags.HTTP_URL.set(span, urlNoParams.toString());
|
||||
|
||||
if (Config.get().isHttpServerTagQueryString()) {
|
||||
span.setTag(DDTags.HTTP_QUERY, url.getQuery());
|
||||
span.setTag(DDTags.HTTP_FRAGMENT, url.getFragment());
|
||||
}
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug("Error tagging url", e);
|
||||
}
|
||||
// TODO set resource name from URL.
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onRequest(final AgentSpan span, final REQUEST request) {
|
||||
assert span != null;
|
||||
if (request != null) {
|
||||
|
@ -129,26 +84,6 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE> extends
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onConnection(final Span span, final CONNECTION connection) {
|
||||
assert span != null;
|
||||
if (connection != null) {
|
||||
Tags.PEER_HOSTNAME.set(span, peerHostname(connection));
|
||||
final String ip = peerHostIP(connection);
|
||||
if (ip != null) {
|
||||
if (VALID_IPV4_ADDRESS.matcher(ip).matches()) {
|
||||
Tags.PEER_HOST_IPV4.set(span, ip);
|
||||
} else if (ip.contains(":")) {
|
||||
Tags.PEER_HOST_IPV6.set(span, ip);
|
||||
}
|
||||
}
|
||||
final Integer port = peerPort(connection);
|
||||
// Negative or Zero ports might represent an unset/null value for an int type. Skip setting.
|
||||
Tags.PEER_PORT.set(span, port != null && port > 0 ? port : null);
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection) {
|
||||
assert span != null;
|
||||
if (connection != null) {
|
||||
|
@ -170,22 +105,6 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE> extends
|
|||
return span;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Span onResponse(final Span span, final RESPONSE response) {
|
||||
assert span != null;
|
||||
if (response != null) {
|
||||
final Integer status = status(response);
|
||||
if (status != null) {
|
||||
Tags.HTTP_STATUS.set(span, status);
|
||||
|
||||
if (Config.get().getHttpServerErrorStatuses().contains(status)) {
|
||||
Tags.ERROR.set(span, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
|
||||
assert span != null;
|
||||
if (response != null) {
|
||||
|
|
|
@ -2,25 +2,11 @@ package datadog.trace.agent.decorator;
|
|||
|
||||
import datadog.trace.api.DDTags;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
|
||||
public abstract class OrmClientDecorator extends DatabaseClientDecorator {
|
||||
|
||||
public abstract String entityName(final Object entity);
|
||||
|
||||
@Deprecated
|
||||
public Span onOperation(final Span span, final Object entity) {
|
||||
|
||||
assert span != null;
|
||||
if (entity != null) {
|
||||
final String name = entityName(entity);
|
||||
if (name != null) {
|
||||
span.setTag(DDTags.RESOURCE_NAME, name);
|
||||
} // else we keep any existing resource.
|
||||
}
|
||||
return span;
|
||||
}
|
||||
|
||||
public AgentSpan onOperation(final AgentSpan span, final Object entity) {
|
||||
|
||||
assert span != null;
|
||||
|
|
|
@ -2,20 +2,10 @@ package datadog.trace.agent.decorator;
|
|||
|
||||
import datadog.trace.api.Config;
|
||||
import datadog.trace.instrumentation.api.AgentSpan;
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.tag.Tags;
|
||||
|
||||
public abstract class ServerDecorator extends BaseDecorator {
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Span afterStart(final Span span) {
|
||||
assert span != null;
|
||||
Tags.SPAN_KIND.set(span, Tags.SPAN_KIND_SERVER);
|
||||
span.setTag(Config.LANGUAGE_TAG_KEY, Config.LANGUAGE_TAG_VALUE);
|
||||
return super.afterStart(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AgentSpan afterStart(final AgentSpan span) {
|
||||
assert span != null;
|
||||
|
|
|
@ -89,13 +89,13 @@ class DatabaseClientDecoratorTest extends ClientDecoratorTest {
|
|||
thrown(AssertionError)
|
||||
|
||||
when:
|
||||
decorator.onConnection((AgentSpan) null, null)
|
||||
decorator.onConnection(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
||||
when:
|
||||
decorator.onStatement((AgentSpan) null, null)
|
||||
decorator.onStatement(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
|
|
@ -120,13 +120,13 @@ class HttpClientDecoratorTest extends ClientDecoratorTest {
|
|||
def decorator = newDecorator()
|
||||
|
||||
when:
|
||||
decorator.onRequest((AgentSpan) null, null)
|
||||
decorator.onRequest(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
||||
when:
|
||||
decorator.onRequest((AgentSpan) null, null)
|
||||
decorator.onResponse(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
|
|
@ -138,13 +138,13 @@ class HttpServerDecoratorTest extends ServerDecoratorTest {
|
|||
def decorator = newDecorator()
|
||||
|
||||
when:
|
||||
decorator.onRequest((AgentSpan) null, null)
|
||||
decorator.onRequest(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
||||
when:
|
||||
decorator.onRequest((AgentSpan) null, null)
|
||||
decorator.onResponse(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package datadog.trace.agent.decorator
|
||||
|
||||
import datadog.trace.api.DDTags
|
||||
import datadog.trace.instrumentation.api.AgentSpan
|
||||
|
||||
class OrmClientDecoratorTest extends DatabaseClientDecoratorTest {
|
||||
|
||||
|
@ -30,7 +29,7 @@ class OrmClientDecoratorTest extends DatabaseClientDecoratorTest {
|
|||
decorator = newDecorator({ e -> null })
|
||||
|
||||
when:
|
||||
decorator.onOperation((AgentSpan) null, null)
|
||||
decorator.onOperation(null, null)
|
||||
|
||||
then:
|
||||
thrown(AssertionError)
|
||||
|
|
Loading…
Reference in New Issue