diff --git a/CHANGELOG.md b/CHANGELOG.md index c8012c656bf..5533d07f33f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Added + +- The `Meter` function is added back to the `go.opentelemetry.io/otel/metric/global` package. + This function is a convenience function equivalent to calling `global.MeterProvider().Meter(...)`. (#2750) + ### Changed - Upgrade `go.opentelemetry.io/proto/otlp` in `go.opentelemetry.io/otel/exporters/otlp/otlpmetric` from `v0.12.1` to `v0.15.0`. diff --git a/metric/global/global.go b/metric/global/global.go index 8578c99ae5a..25071bb88ed 100644 --- a/metric/global/global.go +++ b/metric/global/global.go @@ -19,6 +19,17 @@ import ( "go.opentelemetry.io/otel/metric/internal/global" ) +// Meter returns a Meter from the global MeterProvider. The +// instrumentationName must be the name of the library providing +// instrumentation. This name may be the same as the instrumented code only if +// that code provides built-in instrumentation. If the instrumentationName is +// empty, then a implementation defined default name will be used instead. +// +// This is short for MeterProvider().Meter(name) +func Meter(instrumentationName string, opts ...metric.MeterOption) metric.Meter { + return MeterProvider().Meter(instrumentationName, opts...) +} + // MeterProvider returns the registered global trace provider. // If none is registered then a No-op MeterProvider is returned. func MeterProvider() metric.MeterProvider {