Skip to main content
A Meter is the entry point for creating instruments that record measurements in your application. Meters should be scoped to a single library or application component.

MeterProvider

The MeterProvider trait provides access to named Meter instances:

Creating a Meter

There are two ways to create a meter:

Simple Meter Creation

The simplest way is to use a static name:

Meter with Full Scope

For libraries and crates, you should include version and schema information:

Meter Naming Guidelines

The meter name should:
  • Be unique within your application
  • Represent the instrumentation scope (typically the library or module name)
  • Not collide with other applications or libraries
  • Be stable across versions
Use your crate name as the meter name. For applications, use the application name. For libraries, use env!("CARGO_PKG_NAME") to automatically use your crate name.

Global Meter Provider

OpenTelemetry provides a global meter provider that can be accessed from anywhere in your application:

Creating Instruments

Once you have a Meter, you can create instruments to record measurements. All instruments are created using a builder pattern:

Available Instrument Builders

The Meter provides builders for all instrument types:

Synchronous Instruments

Asynchronous Instruments

Instrument Configuration

All instrument builders support common configuration options:
Unit names are case-sensitive. Use standard units like “ms” for milliseconds, “s” for seconds, “By” for bytes, etc.

Instrument Reuse

Instruments can be cloned to create multiple handles to the same underlying metric:
Clone instruments rather than creating duplicates. Creating multiple instruments with the same name can lower SDK performance.

Shutting Down

When your application terminates, shut down the meter provider to flush any pending metrics:
This ensures all metrics are exported before the application exits.

Next Steps

Instruments

Learn about the different instrument types

Counter

Record monotonically increasing values

Histogram

Record value distributions

Observable Instruments

Use callbacks to report measurements