Correlate database queries with Java traces

Skip step 1 if you've already instrumented your Java application.
  1. If your Java application is uninstrumented, instrument it to send spans to Splunk APM.
  2. Configure the Java agent as needed.

    This configuration must include the environment variable OTEL_INSTRUMENTATION_SPLUNK_JDBC_ENABLED set to true.

    • Example of setting the environment variable at the command line:

      export OTEL_INSTRUMENTATION_SPLUNK_JDBC_ENABLED=true
    • Example Kubernetes deployment snippet:

      apiVersion: apps/v1
      kind: Deployment
      spec:
        selector:
          matchLabels:
            app: your-application
        template:
          spec:
            containers:
              - name: myapp
                env:
                  - ...
                  - name: OTEL_INSTRUMENTATION_SPLUNK_JDBC_ENABLED
                    value: "true"
      
  3. Run the Java agent with the appended -javaagent option to enable instrumentation.
    java -javaagent:/usr/lib/splunk-instrumentation/splunk-otel-javaagent.jar -jar data-ecosystem-java-app-1.0-SNAPSHOT.jar

You can now view database query correlation with APM traces from the APM trace view or the Query details pane in the Database Monitoring Overview.