The best way to send Open Telemetry metrics using Micrometer and send them to New Relic

Krzysztof Kocel

November 29, 2023


Lately, I was tasked with transmitting Micrometer metrics via Open Telemetry and forwarding them to New Relic for analysis and monitoring.

I noticed that New Relic posted a recipe on how to do that using Open Telemetry SDK and Micrometer Shim, but I wondered if there is a better option.

It turns out there is! I was able to use a dedicated OTLP Registry provided by Micrometer.

The registry requires single dependency:

implementation("io.micrometer:micrometer-registry-otlp")

In my Spring Boot application I was able to define everything in the configuration with no need of manual bean registration:

management:
  otlp:
    metrics:
      export:
        url: https://otlp.nr-data.net:4318/v1/metrics
        aggregationTemporality: "delta"
        headers:
          api-key : <insert your licence here>
        resourceAttributes:
          instrumentation.provider: micrometer
          service.name: <insert your service name>

Conclusion

By using dedicated Micrometer registry in Spring Boot, I was able to minimize configuration, and use less dependencies. I even created a commit showing how OTLP registry can be used in NR. I cannot create a pull request hence repository is archived, unfortunately.