Docs » Supported integrations in Splunk Observability Cloud » Instrument back-end applications to send spans to Splunk APM » Instrument Java applications for Splunk Observability Cloud » Splunk Distribution of OpenTelemetry Java 1.x (Deprecated) » Manually instrument Java applications using the Java agent 1.x (Deprecated)

Caution

The Splunk Distribution of OpenTelemetry Java version 1.x is deprecated as of June 25, 2024 and will reach End of Support on June 30, 2025. Until then, only critical security fixes and bug fixes will be provided.

New customers should use the latest version of the Splunk Distribution of OpenTelemetry Java. Existing customers should consider migrating to version 2.5.0 or higher. To learn how to migrate, see Migration guide for OpenTelemetry Java 2.x metrics.

Manually instrument Java applications using the Java agent 1.x (Deprecated) 🔗

For instructions on how to manually instrument Java applications, see the Manual instrumentation docs in the OpenTelemetry Java Instrumentation repository at https://opentelemetry.io/docs/java/manual_instrumentation.

Note

Manual OTel instrumentation is fully compatible with Splunk automatic JVM instrumentation and is fully supported by Splunk.

Send custom Java application metrics (1.x) 🔗

The Splunk Distribution of OpenTelemetry Java agent detects if the instrumented application is using Micrometer and injects a special MeterRegistry implementation that lets the agent collect user-defined meters.

Follow these steps to activate custom application metrics:

Add the micrometer-core dependency 🔗

To export custom metrics through the Java agent, add a dependency on the micrometer-core library with version 1.5 and higher:

<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-core</artifactId>
  <version>1.7.5</version>
</dependency>

Register each custom meter 🔗

You must register each custom meter in the global Metrics.globalRegistry instance provided by the Micrometer library. You can use one of meter factory methods provided by the Metrics class, or use meter builders and reference the Metrics.globalRegistry directly, as in the following example:

class MyClass {
Counter myCounter = Metrics.counter("my_custom_counter");
  Timer myTimer = Timer.builder("my_custom_timer").register(Metrics.globalRegistry);

  int foo() {
    myCounter.increment();
    return myTimer.record(this::fooImpl);
  }

  private int fooImpl() {
     // ...
  }
}

For more information on the Micrometer API, see the Micrometer official documentation.

This page was last updated on Jun 25, 2024.