Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log message on incompatibilities when dd-java-agent is used as javaagent #185

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,21 @@ private boolean reinitializeTracer(boolean force) {
traceBuildLogic = new DatadogTraceBuildLogic(ddTracer);
tracePipelineLogic = new DatadogTracePipelineLogic(ddTracer);
return true;
} catch (NoSuchMethodError err) {
// If the user is using the dd-java-agent as -javaagent in the Jenkins startup command
// the traces collection initialization will throw NoSuchMethodError, due to the dd-java-agent
// packages its classes with a package renaming (to avoid issues during auto-instrumentation).
// It’s not allowed to have the library that sends the traces manually
// (used by the Jenkins plugin, in this case) and the dd-java-agent (as -javaagent, for example)
// in the classpath together.
// E.g: java.lang.NoSuchMethodError: datadog.trace.api.IOLogger.<init>(Lorg/slf4j/Logger;)V
final String message = err.getMessage() != null ? err.getMessage() : "";
if(message.contains("datadog.trace")) {
DatadogUtilities.severe(logger, err, "Failed to reinitialize Datadog-Plugin Tracer, Cannot enable traces collection via plugin if the Datadog Java Tracer is being used as javaagent in the Jenkins startup command. This error will not affect your pipelines executions.");
} else {
DatadogUtilities.severe(logger, err, "Failed to reinitialize Datadog-Plugin Tracer due to unrecoverable error. Set logger level to FINER to know more details. This error will not affect your pipelines executions.");
}
return false;
} catch (Throwable e){
DatadogUtilities.severe(logger, e, "Failed to reinitialize Datadog-Plugin Tracer");
return false;
Expand Down