← All recipes
Moderne licensed

Record New Relic metrics through OpenTelemetry

Recipe IDorg.openrewrite.golang.migration.MigrateNewRelicMetricRecordingArtifactgithub.com/moderneinc/recipes-go

Rewrite harvester.RecordMetric(telemetry.Count{…}) and telemetry.Gauge{…} as an OpenTelemetry Float64Counter.Add / Float64Gauge.Record on a meter from the global provider. The instrument is created at the call site inside a scoping block, which keeps one statement replacing one; hoist it to a package-level instrument when reviewing. Timestamp and Interval are dropped, since OpenTelemetry stamps a measurement when it is collected. A call site is left alone when its attribute values are not all string, bool, int, int64 or float64, when the enclosing function has no context.Context in scope, or when the harvester is a local variable the rewrite would leave unused.

Single recipeProprietary

Usage

This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.

mod run . --recipe org.openrewrite.golang.migration.MigrateNewRelicMetricRecording

If the recipe isn’t available locally, install it with:

mod config recipes go install github.com/moderneinc/recipes-go