Skip to content

Commit 3b1c46e

Browse files
link04mhliddmccullsdevflow.devflow-routing-intake
authored
Support OTLP runtime metrics with OTel-native naming (#11318)
Adding configs and metrics creation Adding test file to check metrics are collected Doing clean up after testing Merge branch 'master' into maximo/otlp-runtime-metrics Merge branch 'master' into maximo/otlp-runtime-metrics move JvmOtlpRuntimeMetrics.java to agent-jmxfetch prevent JMXFetch from emitting jvm metrics when otlp is enabled; migrate from depending on otel-shim to otel-bootstrap update JMXFetch to only emit either OTLP or JMX runtime metrics Merge branch 'master' into maximo/otlp-runtime-metrics send otlp_jmx_config when otlp runtime metrics enabled update test to assert on guarantees instead of dependent on GC collection Merge branch 'master' into maximo/otlp-runtime-metrics adding exception handling for callback Merge remote-tracking branch 'origin/master' into maximo/otlp-runtime-metrics Minor fixes to use correct storage for observable counters Cleanup Merge branch 'master' into maximo/otlp-runtime-metrics Co-authored-by: mhlidd <matthew.li@datadoghq.com> Co-authored-by: mcculls <stuart.mcculloch@datadoghq.com> Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent c7ae94b commit 3b1c46e

8 files changed

Lines changed: 642 additions & 1 deletion

File tree

dd-java-agent/agent-jmxfetch/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ dependencies {
2525
api libs.slf4j
2626
api project(':internal-api')
2727
api project(':dd-java-agent:agent-bootstrap')
28+
29+
// JvmOtlpRuntimeMetrics registers JVM runtime instruments directly against the
30+
// bootstrap-level OTel metric registry. otel-bootstrap vendors and repackages the
31+
// OTel API at build time so this won't conflict with anything in the customer app.
32+
compileOnly project(path: ':dd-java-agent:agent-otel:otel-bootstrap', configuration: 'shadow')
2833
}
2934

3035
tasks.named("shadowJar", ShadowJar) {

dd-java-agent/agent-jmxfetch/src/main/java/datadog/trace/agent/jmxfetch/JMXFetch.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import datadog.metrics.api.statsd.StatsDClientManager;
1010
import datadog.trace.api.Config;
1111
import datadog.trace.api.GlobalTracer;
12+
import datadog.trace.api.InstrumenterConfig;
1213
import datadog.trace.api.flare.TracerFlare;
1314
import datadog.trace.api.telemetry.LogCollector;
1415
import de.thetaphi.forbiddenapis.SuppressForbidden;
@@ -32,6 +33,7 @@ public class JMXFetch {
3233
private static final Logger log = LoggerFactory.getLogger(JMXFetch.class);
3334

3435
private static final String DEFAULT_CONFIG = "jmxfetch-config.yaml";
36+
private static final String OTLP_JMX_CONFIG = "jmxfetch-config-no-jvm-defaults.yaml";
3537
private static final String WEBSPHERE_CONFIG = "jmxfetch-websphere-config.yaml";
3638

3739
private static final int DELAY_BETWEEN_RUN_ATTEMPTS = 5000;
@@ -93,9 +95,22 @@ private static void run(final StatsDClientManager statsDClientManager, final Con
9395
final StatsDClient statsd = statsDClientManager.statsDClient(host, port, namedPipe, null, null);
9496
final AgentStatsdReporter reporter = new AgentStatsdReporter(statsd);
9597

98+
final boolean otlpRuntimeMetricsEnabled =
99+
InstrumenterConfig.get().isMetricsOtelEnabled() && config.isMetricsOtlpExporterEnabled();
100+
96101
TracerFlare.addReporter(reporter);
97102
final List<String> defaultConfigs = new ArrayList<>();
98-
defaultConfigs.add(DEFAULT_CONFIG);
103+
if (otlpRuntimeMetricsEnabled) {
104+
// Register JVM runtime metric callbacks against the OtelMeterProvider so the OTLP
105+
// exporter started by CoreTracer collects them. Started here so it rides the same
106+
// delayed-start path as JMXFetch itself.
107+
JvmOtlpRuntimeMetrics.start();
108+
// When the OTLP exporter is collecting JVM runtime metrics, skip the default JMXFetch
109+
// JVM config to avoid double-reporting.
110+
defaultConfigs.add(OTLP_JMX_CONFIG);
111+
} else {
112+
defaultConfigs.add(DEFAULT_CONFIG);
113+
}
99114
if (config.isJmxFetchIntegrationEnabled(Collections.singletonList("websphere"), false)) {
100115
defaultConfigs.add(WEBSPHERE_CONFIG);
101116
}

0 commit comments

Comments
 (0)