Skip to content
Open
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
8 changes: 8 additions & 0 deletions dd-java-agent/agent-jmxfetch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ dependencies {
api libs.slf4j
api project(':internal-api')
api project(':dd-java-agent:agent-bootstrap')

// The opentelemetry-api compileOnly is only for io.opentelemetry.api.common.Attributes /
// AttributeKey used to label the recorded measurements; everything else comes from otel-bootstrap.
compileOnly group: 'io.opentelemetry', name: 'opentelemetry-api', version: '1.47.0'
// JvmOtlpRuntimeMetrics registers JVM runtime instruments directly against the
// bootstrap-level OTel metric registry. otel-bootstrap vendors and repackages the
// OTel API at build time so this won't conflict with anything in the customer app.
compileOnly project(':dd-java-agent:agent-otel:otel-bootstrap')
}

tasks.named("shadowJar", ShadowJar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import datadog.metrics.api.statsd.StatsDClientManager;
import datadog.trace.api.Config;
import datadog.trace.api.GlobalTracer;
import datadog.trace.api.InstrumenterConfig;
import datadog.trace.api.flare.TracerFlare;
import datadog.trace.api.telemetry.LogCollector;
import de.thetaphi.forbiddenapis.SuppressForbidden;
Expand Down Expand Up @@ -93,9 +94,16 @@ private static void run(final StatsDClientManager statsDClientManager, final Con
final StatsDClient statsd = statsDClientManager.statsDClient(host, port, namedPipe, null, null);
final AgentStatsdReporter reporter = new AgentStatsdReporter(statsd);

// When the OTLP exporter is collecting JVM runtime metrics, skip the default JMXFetch
// JVM config to avoid double-reporting.
final boolean otlpRuntimeMetricsEnabled =
InstrumenterConfig.get().isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled();

TracerFlare.addReporter(reporter);
final List<String> defaultConfigs = new ArrayList<>();
defaultConfigs.add(DEFAULT_CONFIG);
if (!otlpRuntimeMetricsEnabled) {
defaultConfigs.add(DEFAULT_CONFIG);
}
if (config.isJmxFetchIntegrationEnabled(Collections.singletonList("websphere"), false)) {
defaultConfigs.add(WEBSPHERE_CONFIG);
}
Expand Down Expand Up @@ -167,6 +175,14 @@ public void run() {
}
});
thread.setContextClassLoader(JMXFetch.class.getClassLoader());

// Register JVM runtime metric callbacks against the OtelMeterProvider so the OTLP
// exporter started by CoreTracer collects them. Started here so it rides the same
// delayed-start path as JMXFetch itself.
if (otlpRuntimeMetricsEnabled) {
JvmOtlpRuntimeMetrics.start();
}

thread.start();
}

Expand Down
Loading