Fix aws version in readme, add finals and reformatting
MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/JMSInstrumentationTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/JMSInstrumentationTest.java
@@ -24,10 +24,10 @@ public class JMSInstrumentationTest {
public static void start() throws JMSException {
broker.start();
- ActiveMQConnectionFactory connectionFactory = broker.createConnectionFactory();
+ final ActiveMQConnectionFactory connectionFactory = broker.createConnectionFactory();
destination = new ActiveMQQueue("someQueue");
- Connection connection = connectionFactory.createConnection();
+ final Connection connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
}
@@ -35,8 +35,8 @@ public class JMSInstrumentationTest {
@Test
public void test() throws Exception {
- MessageProducer producer = session.createProducer(destination);
- MessageConsumer consumer = session.createConsumer(destination);
+ final MessageProducer producer = session.createProducer(destination);
+ final MessageConsumer consumer = session.createConsumer(destination);
assertThat(producer.getClass().getSimpleName()).isEqualTo("TracingMessageProducer");
assertThat(consumer.getClass().getSimpleName()).isEqualTo("TracingMessageConsumer");

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/MongoClientInstrumentationTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/MongoClientInstrumentationTest.java
@@ -9,7 +9,7 @@ public class MongoClientInstrumentationTest {
@Test
public void test() {
- MongoClient mongoClient = new MongoClient();
+ final MongoClient mongoClient = new MongoClient();
assertThat(mongoClient.getMongoClientOptions().getCommandListeners().size()).isEqualTo(1);
assertThat(

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/OkHTTPInstrumentationTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/OkHTTPInstrumentationTest.java
@@ -9,7 +9,7 @@ public class OkHTTPInstrumentationTest {
@Test
public void test() {
- OkHttpClient client = new OkHttpClient().newBuilder().build();
+ final OkHttpClient client = new OkHttpClient().newBuilder().build();
assertThat(client.interceptors().size()).isEqualTo(1);
assertThat(client.interceptors().get(0).getClass().getSimpleName())

MODIFY
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/TomcatServletInstrumentationTest.java
dd-java-agent-ittests/src/test/java/com/datadoghq/agent/integration/TomcatServletInstrumentationTest.java
@@ -11,7 +11,7 @@ import org.junit.Test;
public class TomcatServletInstrumentationTest {
- private int serverPort = 9786;
+ private final int serverPort = 9786;
protected Tomcat tomcatServer;
Context appContext;
@@ -21,10 +21,10 @@ public class TomcatServletInstrumentationTest {
tomcatServer = new Tomcat();
tomcatServer.setPort(serverPort);
- File baseDir = new File("tomcat");
+ final File baseDir = new File("tomcat");
tomcatServer.setBaseDir(baseDir.getAbsolutePath());
- File applicationDir = new File(baseDir + "/webapps", "/ROOT");
+ final File applicationDir = new File(baseDir + "/webapps", "/ROOT");
if (!applicationDir.exists()) {
applicationDir.mkdirs();
}

MODIFY
dd-java-agent/integrations/helpers/src/main/java/com/datadoghq/agent/integration/OpenTracingHelper.java
dd-java-agent/integrations/helpers/src/main/java/com/datadoghq/agent/integration/OpenTracingHelper.java
@@ -51,7 +51,7 @@ public class OpenTracingHelper extends Helper {
private static final Object SYNC = new Object();
- public OpenTracingHelper(Rule rule) {
+ public OpenTracingHelper(final Rule rule) {
super(rule);
}
@@ -73,11 +73,11 @@ public class OpenTracingHelper extends Helper {
if (tracer == null) {
if (!GlobalTracer.isRegistered()) {
// Try to obtain a tracer using the TracerResolver
- Tracer resolved = TracerResolver.resolveTracer();
+ final Tracer resolved = TracerResolver.resolveTracer();
if (resolved != null) {
try {
GlobalTracer.register(resolved);
- } catch (RuntimeException re) {
+ } catch (final RuntimeException re) {
log.log(Level.WARNING, "Failed to register tracer '" + resolved + "'", re);
}
}
@@ -97,7 +97,7 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object to be associated with the span
* @param span The span
*/
- public void associateSpan(Object obj, Span span) {
+ public void associateSpan(final Object obj, final Span span) {
spanAssociations.put(obj, span);
}
@@ -107,17 +107,17 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @return The span, or null if no associated span exists
*/
- public Span retrieveSpan(Object obj) {
+ public Span retrieveSpan(final Object obj) {
return spanAssociations.get(obj);
}
/** ******************************************* */
/** Needs to be replaced by span.isFinished() */
- public void finishedSpan(Object key, Span span) {
+ public void finishedSpan(final Object key, final Span span) {
finished.put(key, span);
}
- public boolean isFinished(Object key) {
+ public boolean isFinished(final Object key) {
return finished.containsKey(key);
}
/** ******************************************* */
@@ -134,7 +134,7 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @param value The state value
*/
- public void setState(Object obj, int value) {
+ public void setState(final Object obj, final int value) {
state.put(obj, new Integer(value));
}
@@ -145,8 +145,8 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @return The state, or 0 if no state currently exists
*/
- public int getState(Object obj) {
- Integer value = state.get(obj);
+ public int getState(final Object obj) {
+ final Integer value = state.get(obj);
return value == null ? 0 : value.intValue();
}
@@ -157,11 +157,11 @@ public class OpenTracingHelper extends Helper {
* @param obj The instrumentation target
* @return Whether the instrumentation point should be ignored
*/
- public boolean ignore(Object obj) {
+ public boolean ignore(final Object obj) {
boolean ignore = false;
if (obj instanceof HttpURLConnection) {
- String value = ((HttpURLConnection) obj).getRequestProperty("opentracing.ignore");
+ final String value = ((HttpURLConnection) obj).getRequestProperty("opentracing.ignore");
ignore = value != null && value.equalsIgnoreCase("true");
}
@@ -184,24 +184,24 @@ public class OpenTracingHelper extends Helper {
*/
public static class AgentTracer implements Tracer {
- private Tracer tracer;
+ private final Tracer tracer;
- public AgentTracer(Tracer tracer) {
+ public AgentTracer(final Tracer tracer) {
this.tracer = tracer;
}
@Override
- public SpanBuilder buildSpan(String operation) {
+ public SpanBuilder buildSpan(final String operation) {
return new AgentSpanBuilder(tracer.buildSpan(operation));
}
@Override
- public <C> SpanContext extract(Format<C> format, C carrier) {
+ public <C> SpanContext extract(final Format<C> format, final C carrier) {
return tracer.extract(format, carrier);
}
@Override
- public <C> void inject(SpanContext ctx, Format<C> format, C carrier) {
+ public <C> void inject(final SpanContext ctx, final Format<C> format, final C carrier) {
tracer.inject(ctx, format, carrier);
}
@@ -211,21 +211,21 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public ActiveSpan makeActive(Span span) {
+ public ActiveSpan makeActive(final Span span) {
return tracer.makeActive(span);
}
}
public static class AgentSpanBuilder implements SpanBuilder {
- private SpanBuilder spanBuilder;
+ private final SpanBuilder spanBuilder;
- public AgentSpanBuilder(SpanBuilder spanBuilder) {
+ public AgentSpanBuilder(final SpanBuilder spanBuilder) {
this.spanBuilder = spanBuilder;
}
@Override
- public SpanBuilder addReference(String type, SpanContext ctx) {
+ public SpanBuilder addReference(final String type, final SpanContext ctx) {
if (ctx != null) {
spanBuilder.addReference(type, ctx);
}
@@ -233,7 +233,7 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder asChildOf(SpanContext ctx) {
+ public SpanBuilder asChildOf(final SpanContext ctx) {
if (ctx != null) {
spanBuilder.asChildOf(ctx);
}
@@ -241,7 +241,7 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder asChildOf(BaseSpan<?> span) {
+ public SpanBuilder asChildOf(final BaseSpan<?> span) {
if (span != null) {
spanBuilder.asChildOf(span);
}
@@ -254,25 +254,25 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder withStartTimestamp(long ts) {
+ public SpanBuilder withStartTimestamp(final long ts) {
spanBuilder.withStartTimestamp(ts);
return this;
}
@Override
- public SpanBuilder withTag(String name, String value) {
+ public SpanBuilder withTag(final String name, final String value) {
spanBuilder.withTag(name, value);
return this;
}
@Override
- public SpanBuilder withTag(String name, boolean value) {
+ public SpanBuilder withTag(final String name, final boolean value) {
spanBuilder.withTag(name, value);
return this;
}
@Override
- public SpanBuilder withTag(String name, Number value) {
+ public SpanBuilder withTag(final String name, final Number value) {
spanBuilder.withTag(name, value);
return this;
}

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/AgentRulesManager.java
dd-java-agent/src/main/java/com/datadoghq/agent/AgentRulesManager.java
@@ -34,7 +34,7 @@ public class AgentRulesManager {
protected final InstrumentationRulesManager instrumentationRulesManager;
protected final TraceAnnotationsManager traceAnnotationsManager;
- public AgentRulesManager(Retransformer trans, TracingAgentConfig config) {
+ public AgentRulesManager(final Retransformer trans, final TracingAgentConfig config) {
transformer = trans;
agentTracerConfig = config;
traceAnnotationsManager = new TraceAnnotationsManager(trans, config);
@@ -49,7 +49,7 @@ public class AgentRulesManager {
public static void initialize(final Retransformer trans) {
log.debug("Initializing {}", AgentRulesManager.class.getSimpleName());
- TracingAgentConfig config =
+ final TracingAgentConfig config =
FactoryUtils.loadConfigFromFilePropertyOrResource(
DDTracerFactory.SYSTEM_PROPERTY_CONFIG_PATH,
DDTracerFactory.CONFIG_PATH,
@@ -57,7 +57,7 @@ public class AgentRulesManager {
log.debug("Configuration: {}", config.toString());
- AgentRulesManager manager = new AgentRulesManager(trans, config);
+ final AgentRulesManager manager = new AgentRulesManager(trans, config);
INSTANCE = manager;
@@ -71,7 +71,7 @@ public class AgentRulesManager {
*
* @param classLoader The classloader
*/
- protected List<String> loadRules(String rulesFileName, final ClassLoader classLoader) {
+ protected List<String> loadRules(final String rulesFileName, final ClassLoader classLoader) {
final List<String> scripts = new ArrayList<>();
if (transformer == null) {
log.warn(

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/ClassLoaderIntegrationInjector.java
dd-java-agent/src/main/java/com/datadoghq/agent/ClassLoaderIntegrationInjector.java
@@ -12,25 +12,25 @@ public class ClassLoaderIntegrationInjector {
private final Map<ZipEntry, byte[]> entries;
private final Map<ClassLoader, Method> invocationPoints = Maps.newConcurrentMap();
- public ClassLoaderIntegrationInjector(Map<ZipEntry, byte[]> entries) {
+ public ClassLoaderIntegrationInjector(final Map<ZipEntry, byte[]> entries) {
this.entries = entries;
}
- public void inject(ClassLoader cl) {
+ public void inject(final ClassLoader cl) {
try {
- Method inovcationPoint = getInovcationPoint(cl);
- Map<ZipEntry, byte[]> toInject = Maps.newHashMap(entries);
- Map<ZipEntry, byte[]> injectedEntries = Maps.newHashMap();
+ final Method inovcationPoint = getInovcationPoint(cl);
+ final Map<ZipEntry, byte[]> toInject = Maps.newHashMap(entries);
+ final Map<ZipEntry, byte[]> injectedEntries = Maps.newHashMap();
boolean successfulyAdded = true;
while (!toInject.isEmpty() && successfulyAdded) {
log.debug("Attempting to inject {} entries into {}", toInject.size(), cl);
successfulyAdded = false;
- for (Map.Entry<ZipEntry, byte[]> entry : toInject.entrySet()) {
- String name = entry.getKey().getName();
+ for (final Map.Entry<ZipEntry, byte[]> entry : toInject.entrySet()) {
+ final String name = entry.getKey().getName();
if (!name.endsWith(".class")) {
continue;
}
- byte[] bytes = entry.getValue();
+ final byte[] bytes = entry.getValue();
try {
inovcationPoint.invoke(cl, bytes, 0, bytes.length);
injectedEntries.put(entry.getKey(), entry.getValue());
@@ -47,14 +47,14 @@ public class ClassLoaderIntegrationInjector {
toInject.keySet().removeAll(injectedEntries.keySet());
}
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
log.error("Error getting 'defineClass' method from {}", cl);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
log.error("Error accessing 'defineClass' method on {}", cl);
}
}
- private Method getInovcationPoint(ClassLoader cl) throws NoSuchMethodException {
+ private Method getInovcationPoint(final ClassLoader cl) throws NoSuchMethodException {
if (invocationPoints.containsKey(invocationPoints)) {
return invocationPoints.get(invocationPoints);
}
@@ -63,12 +63,12 @@ public class ClassLoaderIntegrationInjector {
while (clazz != null) {
try {
// defineClass is protected so we may need to check up the class hierarchy.
- Method invocationPoint =
+ final Method invocationPoint =
clazz.getDeclaredMethod("defineClass", byte[].class, int.class, int.class);
invocationPoint.setAccessible(true);
invocationPoints.put(cl, invocationPoint);
return invocationPoint;
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
if (firstException == null) {
firstException = e;
}

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/DDJavaAgentInfo.java
dd-java-agent/src/main/java/com/datadoghq/agent/DDJavaAgentInfo.java
@@ -28,7 +28,7 @@ public class DDJavaAgentInfo {
log.info("dd-java-agent - version: {}", v);
}
- public static void main(String... args) {
+ public static void main(final String... args) {
System.out.println(VERSION);
}
}

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/InstrumentationChecker.java
dd-java-agent/src/main/java/com/datadoghq/agent/InstrumentationChecker.java
@@ -34,7 +34,7 @@ public class InstrumentationChecker {
CONFIG_FILE, new TypeReference<Map<String, List<ArtifactSupport>>>() {});
}
- public List<String> getUnsupportedRules(ClassLoader classLoader) {
+ public List<String> getUnsupportedRules(final ClassLoader classLoader) {
log.debug("Checking rule compatibility on classloader {}", classLoader);
final List<String> unsupportedRules = new ArrayList<>();
@@ -58,13 +58,13 @@ public class InstrumentationChecker {
log.debug(
"Instrumentation {} not applied due to missing class {}.", rule, identifier);
} else {
- String identifyingMethod = identifier.getValue();
+ final String identifyingMethod = identifier.getValue();
if (identifyingMethod != null && !identifyingMethod.isEmpty()) {
- Class clazz = getClassIfPresent(identifier.getKey(), classLoader);
+ final Class clazz = getClassIfPresent(identifier.getKey(), classLoader);
// already confirmed above the class is there.
- Method[] declaredMethods = clazz.getDeclaredMethods();
+ final Method[] declaredMethods = clazz.getDeclaredMethods();
boolean methodFound = false;
- for (Method m : declaredMethods) {
+ for (final Method m : declaredMethods) {
if (m.getName().equals(identifyingMethod)) {
methodFound = true;
break;
@@ -111,11 +111,13 @@ public class InstrumentationChecker {
return unsupportedRules;
}
- static boolean isClassPresent(final String identifyingPresentClass, ClassLoader classLoader) {
+ static boolean isClassPresent(
+ final String identifyingPresentClass, final ClassLoader classLoader) {
return getClassIfPresent(identifyingPresentClass, classLoader) != null;
}
- static Class getClassIfPresent(final String identifyingPresentClass, ClassLoader classLoader) {
+ static Class getClassIfPresent(
+ final String identifyingPresentClass, final ClassLoader classLoader) {
try {
return Class.forName(identifyingPresentClass, false, classLoader);
} catch (final Exception e) {

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/InstrumentationRulesManager.java
dd-java-agent/src/main/java/com/datadoghq/agent/InstrumentationRulesManager.java
@@ -38,13 +38,15 @@ public class InstrumentationRulesManager {
private final Set<ClassLoader> initializedClassloaders = Sets.newConcurrentHashSet();
public InstrumentationRulesManager(
- Retransformer trans, TracingAgentConfig config, AgentRulesManager agentRulesManager) {
+ final Retransformer trans,
+ final TracingAgentConfig config,
+ final AgentRulesManager agentRulesManager) {
this.transformer = trans;
this.config = config;
this.agentRulesManager = agentRulesManager;
- InputStream helpersStream = this.getClass().getResourceAsStream(HELPERS_NAME);
- ZipInputStream stream = new ZipInputStream(helpersStream);
- Map<ZipEntry, byte[]> helperEntries = Maps.newHashMap();
+ final InputStream helpersStream = this.getClass().getResourceAsStream(HELPERS_NAME);
+ final ZipInputStream stream = new ZipInputStream(helpersStream);
+ final Map<ZipEntry, byte[]> helperEntries = Maps.newHashMap();
try {
ZipEntry entry = stream.getNextEntry();
while (entry != null) {
@@ -53,17 +55,17 @@ public class InstrumentationRulesManager {
continue;
}
// this is a buffer, so the long->int truncation is not an issue.
- ByteArrayOutputStream os = new ByteArrayOutputStream((int) entry.getSize());
+ final ByteArrayOutputStream os = new ByteArrayOutputStream((int) entry.getSize());
int n;
- byte[] buf = new byte[1024];
+ final byte[] buf = new byte[1024];
while ((n = stream.read(buf, 0, 1024)) > -1) {
os.write(buf, 0, n);
}
helperEntries.put(entry, os.toByteArray());
entry = stream.getNextEntry();
}
- } catch (IOException e) {
+ } catch (final IOException e) {
log.error("Error extracting helpers", e);
}
injector = new ClassLoaderIntegrationInjector(helperEntries);
@@ -74,8 +76,8 @@ public class InstrumentationRulesManager {
registerClassLoad(Thread.currentThread().getContextClassLoader());
}
- public static void registerClassLoad(Object obj) {
- ClassLoader cl;
+ public static void registerClassLoad(final Object obj) {
+ final ClassLoader cl;
if (obj instanceof ClassLoader) {
cl = (ClassLoader) obj;
log.info("Calling initialize with {}", cl);
@@ -93,7 +95,7 @@ public class InstrumentationRulesManager {
*
* @param classLoader
*/
- public void initialize(ClassLoader classLoader) {
+ public void initialize(final ClassLoader classLoader) {
synchronized (classLoader) {
if (initializedClassloaders.contains(classLoader)) {
return;
@@ -117,7 +119,7 @@ public class InstrumentationRulesManager {
try {
uninstallScripts(loadedScripts, uninstallScripts);
- } catch (Exception e) {
+ } catch (final Exception e) {
log.warn("Error uninstalling scripts", e);
}
}

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/OpenTracingHelper.java
dd-java-agent/src/main/java/com/datadoghq/agent/OpenTracingHelper.java
@@ -51,7 +51,7 @@ public class OpenTracingHelper extends Helper {
private static final Object SYNC = new Object();
- public OpenTracingHelper(Rule rule) {
+ public OpenTracingHelper(final Rule rule) {
super(rule);
}
@@ -73,11 +73,11 @@ public class OpenTracingHelper extends Helper {
if (tracer == null) {
if (!GlobalTracer.isRegistered()) {
// Try to obtain a tracer using the TracerResolver
- Tracer resolved = TracerResolver.resolveTracer();
+ final Tracer resolved = TracerResolver.resolveTracer();
if (resolved != null) {
try {
GlobalTracer.register(resolved);
- } catch (RuntimeException re) {
+ } catch (final RuntimeException re) {
log.log(Level.WARNING, "Failed to register tracer '" + resolved + "'", re);
}
}
@@ -97,7 +97,7 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object to be associated with the span
* @param span The span
*/
- public void associateSpan(Object obj, Span span) {
+ public void associateSpan(final Object obj, final Span span) {
spanAssociations.put(obj, span);
}
@@ -107,17 +107,17 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @return The span, or null if no associated span exists
*/
- public Span retrieveSpan(Object obj) {
+ public Span retrieveSpan(final Object obj) {
return spanAssociations.get(obj);
}
/** ******************************************* */
/** Needs to be replaced by span.isFinished() */
- public void finishedSpan(Object key, Span span) {
+ public void finishedSpan(final Object key, final Span span) {
finished.put(key, span);
}
- public boolean isFinished(Object key) {
+ public boolean isFinished(final Object key) {
return finished.containsKey(key);
}
/** ******************************************* */
@@ -134,7 +134,7 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @param value The state value
*/
- public void setState(Object obj, int value) {
+ public void setState(final Object obj, final int value) {
state.put(obj, new Integer(value));
}
@@ -145,8 +145,8 @@ public class OpenTracingHelper extends Helper {
* @param obj The application object
* @return The state, or 0 if no state currently exists
*/
- public int getState(Object obj) {
- Integer value = state.get(obj);
+ public int getState(final Object obj) {
+ final Integer value = state.get(obj);
return value == null ? 0 : value.intValue();
}
@@ -157,11 +157,11 @@ public class OpenTracingHelper extends Helper {
* @param obj The instrumentation target
* @return Whether the instrumentation point should be ignored
*/
- public boolean ignore(Object obj) {
+ public boolean ignore(final Object obj) {
boolean ignore = false;
if (obj instanceof HttpURLConnection) {
- String value = ((HttpURLConnection) obj).getRequestProperty("opentracing.ignore");
+ final String value = ((HttpURLConnection) obj).getRequestProperty("opentracing.ignore");
ignore = value != null && value.equalsIgnoreCase("true");
}
@@ -184,24 +184,24 @@ public class OpenTracingHelper extends Helper {
*/
public static class AgentTracer implements Tracer {
- private Tracer tracer;
+ private final Tracer tracer;
- public AgentTracer(Tracer tracer) {
+ public AgentTracer(final Tracer tracer) {
this.tracer = tracer;
}
@Override
- public SpanBuilder buildSpan(String operation) {
+ public SpanBuilder buildSpan(final String operation) {
return new AgentSpanBuilder(tracer.buildSpan(operation));
}
@Override
- public <C> SpanContext extract(Format<C> format, C carrier) {
+ public <C> SpanContext extract(final Format<C> format, final C carrier) {
return tracer.extract(format, carrier);
}
@Override
- public <C> void inject(SpanContext ctx, Format<C> format, C carrier) {
+ public <C> void inject(final SpanContext ctx, final Format<C> format, final C carrier) {
tracer.inject(ctx, format, carrier);
}
@@ -211,21 +211,21 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public ActiveSpan makeActive(Span span) {
+ public ActiveSpan makeActive(final Span span) {
return tracer.makeActive(span);
}
}
public static class AgentSpanBuilder implements SpanBuilder {
- private SpanBuilder spanBuilder;
+ private final SpanBuilder spanBuilder;
- public AgentSpanBuilder(SpanBuilder spanBuilder) {
+ public AgentSpanBuilder(final SpanBuilder spanBuilder) {
this.spanBuilder = spanBuilder;
}
@Override
- public SpanBuilder addReference(String type, SpanContext ctx) {
+ public SpanBuilder addReference(final String type, final SpanContext ctx) {
if (ctx != null) {
spanBuilder.addReference(type, ctx);
}
@@ -233,7 +233,7 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder asChildOf(SpanContext ctx) {
+ public SpanBuilder asChildOf(final SpanContext ctx) {
if (ctx != null) {
spanBuilder.asChildOf(ctx);
}
@@ -241,7 +241,7 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder asChildOf(BaseSpan<?> span) {
+ public SpanBuilder asChildOf(final BaseSpan<?> span) {
if (span != null) {
spanBuilder.asChildOf(span);
}
@@ -254,25 +254,25 @@ public class OpenTracingHelper extends Helper {
}
@Override
- public SpanBuilder withStartTimestamp(long ts) {
+ public SpanBuilder withStartTimestamp(final long ts) {
spanBuilder.withStartTimestamp(ts);
return this;
}
@Override
- public SpanBuilder withTag(String name, String value) {
+ public SpanBuilder withTag(final String name, final String value) {
spanBuilder.withTag(name, value);
return this;
}
@Override
- public SpanBuilder withTag(String name, boolean value) {
+ public SpanBuilder withTag(final String name, final boolean value) {
spanBuilder.withTag(name, value);
return this;
}
@Override
- public SpanBuilder withTag(String name, Number value) {
+ public SpanBuilder withTag(final String name, final Number value) {
spanBuilder.withTag(name, value);
return this;
}

MODIFY
dd-java-agent/src/main/java/com/datadoghq/agent/TracingAgentConfig.java
dd-java-agent/src/main/java/com/datadoghq/agent/TracingAgentConfig.java
@@ -7,7 +7,7 @@ import java.util.List;
/** Configuration POJO for the agent */
public class TracingAgentConfig extends TracerConfig {
- private List<String> disabledInstrumentations = new ArrayList<String>();
+ private List<String> disabledInstrumentations = new ArrayList<>();
private String[] enableCustomAnnotationTracingOver = {};
@@ -15,7 +15,8 @@ public class TracingAgentConfig extends TracerConfig {
return enableCustomAnnotationTracingOver;
}
- public void setEnableCustomAnnotationTracingOver(String[] enableCustomAnnotationTracingOver) {
+ public void setEnableCustomAnnotationTracingOver(
+ final String[] enableCustomAnnotationTracingOver) {
this.enableCustomAnnotationTracingOver = enableCustomAnnotationTracingOver;
}
@@ -23,7 +24,7 @@ public class TracingAgentConfig extends TracerConfig {
return disabledInstrumentations;
}
- public void setDisabledInstrumentations(List<String> uninstallContributions) {
+ public void setDisabledInstrumentations(final List<String> uninstallContributions) {
this.disabledInstrumentations = uninstallContributions;
}
}

MODIFY
dd-trace-examples/dropwizard-mongo-client/src/main/java/com/datadoghq/example/dropwizard/resources/SimpleCrudResource.java
dd-trace-examples/dropwizard-mongo-client/src/main/java/com/datadoghq/example/dropwizard/resources/SimpleCrudResource.java
@@ -37,7 +37,7 @@ public class SimpleCrudResource {
// For this example, start from a fresh DB
try {
client.dropDatabase(DATABASE);
- } catch (Exception e) {
+ } catch (final Exception e) {
// do nothing here
}
@@ -55,9 +55,9 @@ public class SimpleCrudResource {
@GET
@Path("/add")
public String addBook(
- @QueryParam("isbn") Optional<String> isbn,
- @QueryParam("title") Optional<String> title,
- @QueryParam("page") Optional<Integer> page)
+ @QueryParam("isbn") final Optional<String> isbn,
+ @QueryParam("title") final Optional<String> title,
+ @QueryParam("page") final Optional<Integer> page)
throws InterruptedException {
// The methodDB is traced (see below), this will be produced a new child span
@@ -67,7 +67,7 @@ public class SimpleCrudResource {
throw new IllegalArgumentException("ISBN should not be null");
}
- Book book = new Book(isbn.get(), title.or("Missing title"), page.or(0));
+ final Book book = new Book(isbn.get(), title.or("Missing title"), page.or(0));
db.getCollection(COLLECTION).insertOne(book.toDocument());
return "Book saved!";
@@ -85,8 +85,8 @@ public class SimpleCrudResource {
// The methodDB is traced (see below), this will be produced a new childre span
beforeDB();
- List<Book> books = new ArrayList<>();
- try (MongoCursor<Document> cursor = db.getCollection(COLLECTION).find().iterator(); ) {
+ final List<Book> books = new ArrayList<>();
+ try (MongoCursor<Document> cursor = db.getCollection(COLLECTION).find().iterator()) {
while (cursor.hasNext()) {
books.add(new Book(cursor.next()));
}
@@ -100,7 +100,7 @@ public class SimpleCrudResource {
@GET
@Path("/async")
- public void async(@Suspended AsyncResponse response) {
+ public void async(@Suspended final AsyncResponse response) {
// not actually async, but useful for testing that codepath.
response.resume("Returned from async");
}
@@ -113,7 +113,7 @@ public class SimpleCrudResource {
*/
@Trace(operationName = "database.before")
public void beforeDB() throws InterruptedException {
- ActiveSpan currentSpan = GlobalTracer.get().activeSpan();
+ final ActiveSpan currentSpan = GlobalTracer.get().activeSpan();
if (currentSpan != null) {
currentSpan.setTag("status", "started");
Thread.sleep(10);
@@ -127,7 +127,7 @@ public class SimpleCrudResource {
*/
@Trace(operationName = "database.after")
public void afterDB() throws InterruptedException {
- ActiveSpan currentSpan = GlobalTracer.get().activeSpan();
+ final ActiveSpan currentSpan = GlobalTracer.get().activeSpan();
if (currentSpan != null) {
currentSpan.setTag("status", "started");
Thread.sleep(10);

MODIFY
dd-trace/src/main/java/com/datadoghq/trace/DDSpanContext.java
dd-trace/src/main/java/com/datadoghq/trace/DDSpanContext.java
@@ -4,7 +4,11 @@ import com.datadoghq.trace.integration.AbstractDecorator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Maps;
import io.opentracing.tag.Tags;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import lombok.extern.slf4j.Slf4j;

Fix aws version in readme, add finals and reformatting