Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix meter provider configuration #2981

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions content/en/docs/instrumentation/python/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,6 @@ trace.set_tracer_provider(provider)
tracer = trace.get_tracer("my.tracer.name")
```

To start collecting metrics, you'll need to initialize a
[`MeterProvider`](/docs/specs/otel/metrics/api/#meterprovider) and optionally
set it as the global default.

```python
from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import (
ConsoleMetricExporter,
PeriodicExportingMetricReader,
)

metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter())
provider = MeterProvider(metric_readers=[metric_reader])

# Sets the global default meter provider
metrics.set_meter_provider(provider)

# Creates a meter from the global meter provider
meter = metrics.get_meter("my.meter.name")
```

### Creating spans

To create a [span](/docs/concepts/signals/traces/#spans), you'll typically want
Expand Down Expand Up @@ -325,6 +303,28 @@ Note that environment variables will override what's configured in code.

## Metrics

To start collecting metrics, you'll need to initialize a
[`MeterProvider`](/docs/specs/otel/metrics/api/#meterprovider) and optionally
set it as the global default.

```python
from opentelemetry import metrics
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import (
ConsoleMetricExporter,
PeriodicExportingMetricReader,
)

metric_reader = PeriodicExportingMetricReader(ConsoleMetricExporter())
provider = MeterProvider(metric_readers=[metric_reader])

# Sets the global default meter provider
metrics.set_meter_provider(provider)

# Creates a meter from the global meter provider
meter = metrics.get_meter("my.meter.name")
```

### Creating and using synchronous instruments

Instruments are used to make measurements of your application.
Expand Down