Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Other source files (Groovy, Scala, etc) should ideally be formatted by Intellij
Suggested plugins and settings:

* Editor > Code Style > Java/Groovy > Imports
* Class count to use import with '*': `50` (some number sufficiently large that is unlikely to matter)
* Names count to use static import with '*': `50`
* Class count to use import with '*': `9999` (some number sufficiently large that is unlikely to matter)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating this.

* Names count to use static import with '*': `9999`
* With java use the following import layout (groovy should still use the default) to ensure consistency with google-java-format:
![import layout](https://user-images.githubusercontent.com/734411/43430811-28442636-94ae-11e8-86f1-f270ddcba023.png)
* [Google Java Format](https://plugins.jetbrains.com/plugin/8527-google-java-format)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@ public void execute() {
private static synchronized void startDatadogAgent(
final Instrumentation inst, final URL bootstrapURL) {
if (AGENT_CLASSLOADER == null) {
final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
try {
final ClassLoader agentClassLoader =
createDatadogClassLoader("agent-tooling-and-instrumentation.isolated", bootstrapURL);
Thread.currentThread().setContextClassLoader(agentClassLoader);
final Class<?> agentInstallerClass =
agentClassLoader.loadClass("datadog.trace.agent.tooling.AgentInstaller");
final Method agentInstallerMethod =
Expand All @@ -176,8 +174,6 @@ private static synchronized void startDatadogAgent(
AGENT_CLASSLOADER = agentClassLoader;
} catch (final Throwable ex) {
log.error("Throwable thrown while installing the Datadog Agent", ex);
} finally {
Thread.currentThread().setContextClassLoader(contextLoader);
}
}
}
Expand All @@ -186,11 +182,9 @@ private static synchronized void installDatadogTracer() {
if (AGENT_CLASSLOADER == null) {
throw new IllegalStateException("Datadog agent should have been started already");
}
final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
// TracerInstaller.installGlobalTracer can be called multiple times without any problem
// so there is no need to have a 'datadogTracerInstalled' flag here.
try {
Thread.currentThread().setContextClassLoader(AGENT_CLASSLOADER);
// install global tracer
final Class<?> tracerInstallerClass =
AGENT_CLASSLOADER.loadClass("datadog.trace.agent.tooling.TracerInstaller");
Expand All @@ -200,8 +194,6 @@ private static synchronized void installDatadogTracer() {
logVersionInfoMethod.invoke(null);
} catch (final Throwable ex) {
log.error("Throwable thrown while installing the Datadog Tracer", ex);
} finally {
Thread.currentThread().setContextClassLoader(contextLoader);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public static ResettableClassFileTransformer installBytebuddyAgent(
agentBuilder = agentBuilder.with(listener);
}
int numInstrumenters = 0;
for (final Instrumenter instrumenter : ServiceLoader.load(Instrumenter.class)) {
for (final Instrumenter instrumenter :
ServiceLoader.load(Instrumenter.class, AgentInstaller.class.getClassLoader())) {
log.debug("Loading instrumentation {}", instrumenter.getClass().getName());

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,15 @@ protected boolean shouldTransformClass(final String className, final ClassLoader
}

@BeforeClass
public static synchronized void agentSetup() throws Exception {
public static synchronized void agentSetup() {
if (null != activeTransformer) {
throw new IllegalStateException("transformer already in place: " + activeTransformer);
}

final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(AgentTestRunner.class.getClassLoader());
assert ServiceLoader.load(Instrumenter.class).iterator().hasNext()
: "No instrumentation found";
activeTransformer = AgentInstaller.installBytebuddyAgent(INSTRUMENTATION, TEST_LISTENER);
} finally {
Thread.currentThread().setContextClassLoader(contextLoader);
}
assert ServiceLoader.load(Instrumenter.class, AgentTestRunner.class.getClassLoader())
.iterator()
.hasNext()
: "No instrumentation found";
activeTransformer = AgentInstaller.installBytebuddyAgent(INSTRUMENTATION, TEST_LISTENER);

INSTRUMENTATION_ERROR_COUNT.set(0);
}
Expand Down