Merge pull request #824 from DataDog/mar-kolya/allow-tracing-agent-to-be-disabled
Update to latest versions of groovy and spock
This commit is contained in:
commit
e4416464cb
|
@ -43,8 +43,10 @@ public class AgentInstaller {
|
|||
return INSTRUMENTATION;
|
||||
}
|
||||
|
||||
public static ResettableClassFileTransformer installBytebuddyAgent(final Instrumentation inst) {
|
||||
return installBytebuddyAgent(inst, new AgentBuilder.Listener[0]);
|
||||
public static void installBytebuddyAgent(final Instrumentation inst) {
|
||||
if (Config.get().isTraceEnabled()) {
|
||||
installBytebuddyAgent(inst, new AgentBuilder.Listener[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import datadog.opentracing.DDTracer;
|
||||
import datadog.trace.api.Config;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TracerInstaller {
|
||||
/** Register a global tracer if no global tracer is already registered. */
|
||||
public static synchronized void installGlobalTracer() {
|
||||
if (!io.opentracing.util.GlobalTracer.isRegistered()) {
|
||||
if (Config.get().isTraceEnabled() && !io.opentracing.util.GlobalTracer.isRegistered()) {
|
||||
final DDTracer tracer = new DDTracer();
|
||||
try {
|
||||
io.opentracing.util.GlobalTracer.register(tracer);
|
||||
|
|
|
@ -32,5 +32,6 @@ dependencies {
|
|||
}
|
||||
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.0.0'
|
||||
|
||||
latestDepTestCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '[3.11.0,)'
|
||||
// 4.x.x-alpha has been released and it looks like there are lots of incompatible changes
|
||||
latestDepTestCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '[3.11.0, 4.0.0*)'
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public class Config {
|
|||
|
||||
public static final String SERVICE_NAME = "service.name";
|
||||
public static final String SERVICE = "service";
|
||||
public static final String TRACE_ENABLED = "trace.enabled";
|
||||
public static final String WRITER_TYPE = "writer.type";
|
||||
public static final String AGENT_HOST = "agent.host";
|
||||
public static final String TRACE_AGENT_PORT = "trace.agent.port";
|
||||
|
@ -65,24 +66,24 @@ public class Config {
|
|||
public static final String JMX_FETCH_REFRESH_BEANS_PERIOD = "jmxfetch.refresh-beans-period";
|
||||
public static final String JMX_FETCH_STATSD_HOST = "jmxfetch.statsd.host";
|
||||
public static final String JMX_FETCH_STATSD_PORT = "jmxfetch.statsd.port";
|
||||
public static final String APP_CUSTOM_LOG_MANAGER = "app.customlogmanager";
|
||||
public static final String LOGS_INJECTION_ENABLED = "logs.injection";
|
||||
private static final String APP_CUSTOM_LOG_MANAGER = "app.customlogmanager";
|
||||
|
||||
public static final String RUNTIME_ID_TAG = "runtime-id";
|
||||
public static final String LANGUAGE_TAG_KEY = "language";
|
||||
public static final String LANGUAGE_TAG_VALUE = "jvm";
|
||||
|
||||
public static final String DEFAULT_SERVICE_NAME = "unnamed-java-app";
|
||||
|
||||
private static final boolean DEFAULT_TRACE_ENABLED = true;
|
||||
public static final String DD_AGENT_WRITER_TYPE = "DDAgentWriter";
|
||||
public static final String LOGGING_WRITER_TYPE = "LoggingWriter";
|
||||
public static final String DEFAULT_AGENT_WRITER_TYPE = DD_AGENT_WRITER_TYPE;
|
||||
private static final String DEFAULT_AGENT_WRITER_TYPE = DD_AGENT_WRITER_TYPE;
|
||||
|
||||
public static final String DEFAULT_AGENT_HOST = "localhost";
|
||||
public static final int DEFAULT_TRACE_AGENT_PORT = 8126;
|
||||
public static final String DEFAULT_AGENT_UNIX_DOMAIN_SOCKET = null;
|
||||
|
||||
public static final String LOGS_INJECTION_ENABLED = "logs.injection";
|
||||
public static final boolean DEFAULT_LOGS_INJECTION_ENABLED = false;
|
||||
|
||||
private static final boolean DEFAULT_RUNTIME_CONTEXT_FIELD_INJECTION = true;
|
||||
|
||||
private static final boolean DEFAULT_PRIORITY_SAMPLING_ENABLED = true;
|
||||
|
@ -99,6 +100,7 @@ public class Config {
|
|||
|
||||
public static final int DEFAULT_JMX_FETCH_STATSD_PORT = 8125;
|
||||
|
||||
public static final boolean DEFAULT_LOGS_INJECTION_ENABLED = false;
|
||||
private static final boolean DEFAULT_APP_CUSTOM_LOG_MANAGER = false;
|
||||
|
||||
private static final String SPLIT_BY_SPACE_OR_COMMA_REGEX = "[,\\s]+";
|
||||
|
@ -115,6 +117,7 @@ public class Config {
|
|||
@Getter private final String runtimeId;
|
||||
|
||||
@Getter private final String serviceName;
|
||||
@Getter private final boolean traceEnabled;
|
||||
@Getter private final String writerType;
|
||||
@Getter private final String agentHost;
|
||||
@Getter private final int agentPort;
|
||||
|
@ -149,6 +152,8 @@ public class Config {
|
|||
runtimeId = UUID.randomUUID().toString();
|
||||
|
||||
serviceName = getSettingFromEnvironment(SERVICE_NAME, DEFAULT_SERVICE_NAME);
|
||||
|
||||
traceEnabled = getBooleanSettingFromEnvironment(TRACE_ENABLED, DEFAULT_TRACE_ENABLED);
|
||||
writerType = getSettingFromEnvironment(WRITER_TYPE, DEFAULT_AGENT_WRITER_TYPE);
|
||||
agentHost = getSettingFromEnvironment(AGENT_HOST, DEFAULT_AGENT_HOST);
|
||||
agentPort =
|
||||
|
@ -166,6 +171,7 @@ public class Config {
|
|||
globalTags = getMapSettingFromEnvironment(GLOBAL_TAGS, null);
|
||||
spanTags = getMapSettingFromEnvironment(SPAN_TAGS, null);
|
||||
jmxTags = getMapSettingFromEnvironment(JMX_TAGS, null);
|
||||
|
||||
excludedClasses = getListSettingFromEnvironment(TRACE_CLASSES_EXCLUDE, null);
|
||||
headerTags = getMapSettingFromEnvironment(HEADER_TAGS, null);
|
||||
|
||||
|
@ -225,6 +231,8 @@ public class Config {
|
|||
runtimeId = parent.runtimeId;
|
||||
|
||||
serviceName = properties.getProperty(SERVICE_NAME, parent.serviceName);
|
||||
|
||||
traceEnabled = getPropertyBooleanValue(properties, TRACE_ENABLED, parent.traceEnabled);
|
||||
writerType = properties.getProperty(WRITER_TYPE, parent.writerType);
|
||||
agentHost = properties.getProperty(AGENT_HOST, parent.agentHost);
|
||||
agentPort =
|
||||
|
|
|
@ -35,6 +35,7 @@ import static datadog.trace.api.Config.SERVICE_MAPPING
|
|||
import static datadog.trace.api.Config.SERVICE_NAME
|
||||
import static datadog.trace.api.Config.SPAN_TAGS
|
||||
import static datadog.trace.api.Config.TRACE_AGENT_PORT
|
||||
import static datadog.trace.api.Config.TRACE_ENABLED
|
||||
import static datadog.trace.api.Config.TRACE_RESOLVER_ENABLED
|
||||
import static datadog.trace.api.Config.WRITER_TYPE
|
||||
|
||||
|
@ -45,6 +46,7 @@ class ConfigTest extends Specification {
|
|||
public final EnvironmentVariables environmentVariables = new EnvironmentVariables()
|
||||
|
||||
private static final DD_SERVICE_NAME_ENV = "DD_SERVICE_NAME"
|
||||
private static final DD_TRACE_ENABLED_ENV = "DD_TRACE_ENABLED"
|
||||
private static final DD_WRITER_TYPE_ENV = "DD_WRITER_TYPE"
|
||||
private static final DD_SERVICE_MAPPING_ENV = "DD_SERVICE_MAPPING"
|
||||
private static final DD_SPAN_TAGS_ENV = "DD_SPAN_TAGS"
|
||||
|
@ -61,6 +63,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == "unnamed-java-app"
|
||||
config.traceEnabled == true
|
||||
config.writerType == "DDAgentWriter"
|
||||
config.agentHost == "localhost"
|
||||
config.agentPort == 8126
|
||||
|
@ -98,6 +101,7 @@ class ConfigTest extends Specification {
|
|||
setup:
|
||||
def prop = new Properties()
|
||||
prop.setProperty(SERVICE_NAME, "something else")
|
||||
prop.setProperty(TRACE_ENABLED, "false")
|
||||
prop.setProperty(WRITER_TYPE, "LoggingWriter")
|
||||
prop.setProperty(AGENT_HOST, "somehost")
|
||||
prop.setProperty(TRACE_AGENT_PORT, "123")
|
||||
|
@ -129,6 +133,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == "something else"
|
||||
config.traceEnabled == false
|
||||
config.writerType == "LoggingWriter"
|
||||
config.agentHost == "somehost"
|
||||
config.agentPort == 123
|
||||
|
@ -157,6 +162,7 @@ class ConfigTest extends Specification {
|
|||
def "specify overrides via system properties"() {
|
||||
setup:
|
||||
System.setProperty(PREFIX + SERVICE_NAME, "something else")
|
||||
System.setProperty(PREFIX + TRACE_ENABLED, "false")
|
||||
System.setProperty(PREFIX + WRITER_TYPE, "LoggingWriter")
|
||||
System.setProperty(PREFIX + AGENT_HOST, "somehost")
|
||||
System.setProperty(PREFIX + TRACE_AGENT_PORT, "123")
|
||||
|
@ -188,6 +194,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == "something else"
|
||||
config.traceEnabled == false
|
||||
config.writerType == "LoggingWriter"
|
||||
config.agentHost == "somehost"
|
||||
config.agentPort == 123
|
||||
|
@ -216,6 +223,7 @@ class ConfigTest extends Specification {
|
|||
def "specify overrides via env vars"() {
|
||||
setup:
|
||||
environmentVariables.set(DD_SERVICE_NAME_ENV, "still something else")
|
||||
environmentVariables.set(DD_TRACE_ENABLED_ENV, "false")
|
||||
environmentVariables.set(DD_WRITER_TYPE_ENV, "LoggingWriter")
|
||||
environmentVariables.set(DD_PROPAGATION_STYLE_EXTRACT, "B3 Datadog")
|
||||
environmentVariables.set(DD_PROPAGATION_STYLE_INJECT, "Datadog B3")
|
||||
|
@ -226,6 +234,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == "still something else"
|
||||
config.traceEnabled == false
|
||||
config.writerType == "LoggingWriter"
|
||||
config.propagationStylesToExtract.toList() == [Config.PropagationStyle.B3, Config.PropagationStyle.DATADOG]
|
||||
config.propagationStylesToInject.toList() == [Config.PropagationStyle.DATADOG, Config.PropagationStyle.B3]
|
||||
|
@ -256,6 +265,7 @@ class ConfigTest extends Specification {
|
|||
def "default when configured incorrectly"() {
|
||||
setup:
|
||||
System.setProperty(PREFIX + SERVICE_NAME, " ")
|
||||
System.setProperty(PREFIX + TRACE_ENABLED, " ")
|
||||
System.setProperty(PREFIX + WRITER_TYPE, " ")
|
||||
System.setProperty(PREFIX + AGENT_HOST, " ")
|
||||
System.setProperty(PREFIX + TRACE_AGENT_PORT, " ")
|
||||
|
@ -276,6 +286,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == " "
|
||||
config.traceEnabled == true
|
||||
config.writerType == " "
|
||||
config.agentHost == " "
|
||||
config.agentPort == 8126
|
||||
|
@ -337,6 +348,7 @@ class ConfigTest extends Specification {
|
|||
setup:
|
||||
Properties properties = new Properties()
|
||||
properties.setProperty(SERVICE_NAME, "something else")
|
||||
properties.setProperty(TRACE_ENABLED, "false")
|
||||
properties.setProperty(WRITER_TYPE, "LoggingWriter")
|
||||
properties.setProperty(AGENT_HOST, "somehost")
|
||||
properties.setProperty(TRACE_AGENT_PORT, "123")
|
||||
|
@ -365,6 +377,7 @@ class ConfigTest extends Specification {
|
|||
|
||||
then:
|
||||
config.serviceName == "something else"
|
||||
config.traceEnabled == false
|
||||
config.writerType == "LoggingWriter"
|
||||
config.agentHost == "somehost"
|
||||
config.agentPort == 123
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
def groovyVer = "2.5.3"
|
||||
def groovyVer = "2.5.6"
|
||||
def spockGroovyVer = groovyVer.replaceAll(/\.\d+$/, '')
|
||||
|
||||
ext {
|
||||
|
@ -9,7 +9,7 @@ ext {
|
|||
guava : "20.0", // Last version to support Java 7
|
||||
jackson : "2.9.8", // https://nvd.nist.gov/vuln/detail/CVE-2018-1000873
|
||||
|
||||
spock : "1.2-groovy-$spockGroovyVer",
|
||||
spock : "1.3-groovy-$spockGroovyVer",
|
||||
groovy : groovyVer,
|
||||
junit : "4.12",
|
||||
logback : "1.2.3",
|
||||
|
|
Loading…
Reference in New Issue