Skip to content

Commit

Permalink
fix: for dynamically adding java agent we also nee to enable dynamic …
Browse files Browse the repository at this point in the history
…agent loading in Java
  • Loading branch information
testersen committed Jan 14, 2024
1 parent 2e76ec5 commit 264795f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sh.tnn.gradle.plugins.opentelemetry
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.logging.Logging
import org.gradle.process.JavaForkOptions
import sh.tnn.gradle.plugins.dotenv.DotEnvPlugin
import sh.tnn.gradle.plugins.java_environment.JavaEnvironmentPlugin

Expand Down Expand Up @@ -51,7 +52,12 @@ class OpenTelemetryPlugin : Plugin<Project> {
"OTEL_SERVICE_NAME" to resourceName,
"OTEL_RESOURCE_ATTRIBUTES_NODE_NAME" to nodeName
)
it.append("JAVA_TOOL_OPTIONS", " -javaagent:${openTelemetryJavaAgentFile.absolutePath}")
}

project.tasks.all {
if (it is JavaForkOptions) {
it.jvmArgs("-XX:+EnableDynamicAgentLoading", "-javaagent:${openTelemetryJavaAgentFile.absolutePath}")
}
}
}
}

0 comments on commit 264795f

Please sign in to comment.