Skip to content

Commit 915356e

Browse files
authored
docs(metrics): reference PeriodicExportingMetricReader usage with push exporters (open-telemetry#4942)
* docs(metrics): reference PeriodicExportingMetricReader usage with push exporters * docs(metrics): reorder examples to match argument order
1 parent 1b7d55b commit 915356e

File tree

1 file changed

+14
-2
lines changed
  • opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal

1 file changed

+14
-2
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/metrics/_internal/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,25 @@ class MeterProvider(APIMeterProvider):
377377
metric_readers: Register metric readers to collect metrics from the SDK
378378
on demand. Each :class:`opentelemetry.sdk.metrics.export.MetricReader` is
379379
completely independent and will collect separate streams of
380-
metrics. TODO: reference ``PeriodicExportingMetricReader`` usage with push
381-
exporters here.
380+
metrics. For push-based export, use
381+
:class:`opentelemetry.sdk.metrics.export.PeriodicExportingMetricReader`.
382382
resource: The resource representing what the metrics emitted from the SDK pertain to.
383383
shutdown_on_exit: If true, registers an `atexit` handler to call
384384
`MeterProvider.shutdown`
385385
views: The views to configure the metric output the SDK
386386
387+
.. code-block:: python
388+
:caption: Push-based export with PeriodicExportingMetricReader
389+
390+
from opentelemetry.sdk.metrics import MeterProvider
391+
from opentelemetry.sdk.metrics.export import (
392+
ConsoleMetricExporter,
393+
PeriodicExportingMetricReader,
394+
)
395+
396+
reader = PeriodicExportingMetricReader(ConsoleMetricExporter())
397+
provider = MeterProvider(metric_readers=[reader])
398+
387399
By default, instruments which do not match any :class:`opentelemetry.sdk.metrics.view.View` (or if no :class:`opentelemetry.sdk.metrics.view.View`\ s
388400
are provided) will report metrics with the default aggregation for the
389401
instrument's kind. To disable instruments by default, configure a match-all

0 commit comments

Comments
 (0)