Use APM Tracer in Micronaut

To use APM Tracer with Micronaut, do the following:

  1. Confirm version: APM Tracer in Micronaut is supported with APM Agent version 1.7 or higher.
  2. Add the APM Tracer to Maven project. For details, see Add APM Tracer to Maven Project.
  3. Add the following dependency in pom.xml:
    <dependency>
        <groupId>com.oracle.apm.agent.java</groupId>
        <artifactId>apm-java-agent-micronaut</artifactId>
        <version>[1.7.2976,)</version>
    </dependency>
  4. Micronaut’s tracing integration registers an io.opentracing.tracer bean which exposes the Open Tracing API. The above dependency will be used to configure the APM Tracer as the default (global) tracer.
  5. Tracing configuration for Micronaut.

    APM Tracer uses the following properties in the application.yml file from Micronaut:

    Property Default Required Description

    enabled

    false Yes Property for enabling APM tracer. Default value is false. This cannot be null.

    data-upload-key

      Yes APM data upload key required for Oracle APM service cloud communication.
    data-upload-endpoint   Yes APM data upload endpoint required for Oracle APM service cloud communication.
    collect-metrics true No

    Collects server metrics and report to OCI APM service cloud.

    Default is true.

    User can access all collected server metrics from OCI Telemetry.
    collect-resources true No

    Collects server resources and report to OCI APM service cloud.

    All collected resources are used as dimension for data query.
    log-directory apm-tracer-log in JVM working directory No Full path of log directory where all APM Tracer logs are written to. If this is not set then the default log directory (apm-tracer-log) is created in the working directory of JVM.
    tags   No Static tags to be included in all tracing spans.
    properties   No

    Additional APM tracer properties. This allows properties be set programmatically at APM Tracer startup time.

    Properties are ignored if either key or value is null.

    The following configuration needs to get added as child node(oracleapm) of tracing section of the application.yml file:
    micronaut:
      server:
      application:
        name: micronaut_trace_demo
    tracing:
      oracleapm:
        …
    Example:
    • You need to specify it in YAML format. The default file name is application.yml. See the following example:
      
      tracing:
        oracleapm:
          enabled: true
          data-upload-key: <data upload endpoint of your OCI domain>
          data-upload-endpoint: <privatedata key of your OCI domain>
          collect-resources: true
          collect-metrics: true
          log-directory: "/user/apm/log "
          tags:
            tag1: false
            tag2: 123
            tag3: "stringWithQuotes"
            tag4: 1e4
            tag5: 0.32
            tag6: stringWoQuotes
          properties:
            com.oracle.apm.agent.logging.level : DEBUG
            com.oracle.apm.agent.key1 : value1
  6. Thread Snapshots: OracleApm tracer supports thread snapshots feature.

    Thread snapshots allow thread stack snapshots collection which can be used for deep dive analysis. For more information about thread snapshots, see Configure Thread Snapshots in APM Tracer.

    To configure thread snapshots for Micronaut, do the following:
    • Open the application.yml configuration file, go to the tracing section and add the following:
      collect-deepdive-trace-snapshots:true
    • Add the new deep-dive-properties section with the thread snapshots properties under tracing:

      deep-dive-properties:     
              com.oracle.apm.agent.deepdive.maxPercentTraceExportToCollectorPerMinute: 100     
              com.oracle.apm.agent.deepdive.maxTraceExportToCollectorPerMinute: 200     
              com.oracle.apm.agent.deepdive.snapshotCollectionIntervalInMS: 250     
              com.oracle.apm.agent.deepdive.maxSnapshotsPerTrace: 16     
              com.oracle.apm.agent.deepdive.maxStackTraceDepthPerSnapshot: 256
              com.oracle.apm.agent.deepdive.logLevel: INFO     
              com.oracle.apm.agent.deepdive.maxProcessCpuUsagePercent: 90     
              com.oracle.apm.agent.deepdive.deepDiveCpuUsagePercent.minThreshold: 3     
              com.oracle.apm.agent.deepdive.deepDiveCpuUsagePercent.maxThreshold: 5     
              com.oracle.apm.agent.deepdive.traceLifeInMS.minThreshold: 50     
              com.oracle.apm.agent.deepdive.traceLifeInMS.maxThreshold: 60000

    Example:

    micronaut:
      server:
      application:
        name: micronaut_trace_demo
    tracing:
      oracleapm:
        enabled: true
        data-upload-key: <data upload endpoint of your OCI domain>
        data-upload-endpoint: <privatedata key of your OCI domain>
        collect-resources: true
        collect-metrics: true
        log-directory: "/user/apm/log "
        collect-deep-dive-trace-snapshot: true
        deep-dive-properties:         
          com.oracle.apm.agent.deepdive.maxPercentTraceExportToCollectorPerMinute: 100         
          com.oracle.apm.agent.deepdive.maxTraceExportToCollectorPerMinute: 200         
          com.oracle.apm.agent.deepdive.snapshotCollectionIntervalInMS: 250         
          com.oracle.apm.agent.deepdive.maxSnapshotsPerTrace: 16         
          com.oracle.apm.agent.deepdive.maxStackTraceDepthPerSnapshot: 256         
          com.oracle.apm.agent.deepdive.logLevel: INFO         
          com.oracle.apm.agent.deepdive.maxProcessCpuUsagePercent: 90         
          com.oracle.apm.agent.deepdive.deepDiveCpuUsagePercent.minThreshold: 3         
          com.oracle.apm.agent.deepdive.deepDiveCpuUsagePercent.maxThreshold: 5         
          com.oracle.apm.agent.deepdive.traceLifeInMS.minThreshold: 50         
          com.oracle.apm.agent.deepdive.traceLifeInMS.maxThreshold: 60000