Record New Relic metrics through OpenTelemetry
ProprietaryRewrite 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.
org. openrewrite. golang. migration. MigrateNewRelicMetricRecordingmod run . --recipe= org. openrewrite. golang. migration. MigrateNewRelicMetricRecordingInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.