From c639ba3c22c88434d60fca8a11be095aa2bbe498 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Thu, 6 Jul 2023 11:25:45 -0700 Subject: [PATCH] fix meter provider configuration It was previously under the Traces header. Signed-off-by: Alex Boten --- .../en/docs/instrumentation/python/manual.md | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/content/en/docs/instrumentation/python/manual.md b/content/en/docs/instrumentation/python/manual.md index 50b9eaa4028b..74467c2037a9 100644 --- a/content/en/docs/instrumentation/python/manual.md +++ b/content/en/docs/instrumentation/python/manual.md @@ -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 @@ -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.