Skip to content

Commit

Permalink
fixing documentation and return value (open-telemetry#2399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten authored Jan 25, 2022
1 parent 1b7e161 commit a659966
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/examples/metrics/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
OTLPMetricExporter,
)
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import PeriodicExportingMetricReader

provider = MeterProvider()
exporter = OTLPMetricExporter(insecure=True)
# TODO: fill in details for metric reader
reader = PeriodicExportingMetricReader(exporter)
provider = MeterProvider(metric_readers=[reader])
set_meter_provider(provider)

meter = get_meter_provider().get_meter("getting-started")
counter = meter.create_counter("first_counter")
counter.add(1)
# TODO: fill in details for additional metrics
10 changes: 7 additions & 3 deletions docs/getting_started/metrics_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

from opentelemetry._metrics import get_meter_provider, set_meter_provider
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import ConsoleMetricExporter
from opentelemetry.sdk._metrics.export import (
ConsoleMetricExporter,
PeriodicExportingMetricReader,
)

provider = MeterProvider()
exporter = ConsoleMetricExporter()
# TODO: fill in details for metric reader
reader = PeriodicExportingMetricReader(exporter)
provider = MeterProvider(metric_readers=[reader])
set_meter_provider(provider)

meter = get_meter_provider().get_meter("getting-started")
counter = meter.create_counter("first_counter")
counter.add(1)
# TODO: fill in details for additional metrics
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def _ticker(self) -> None:
self.collect()

def _receive_metrics(self, metrics: Iterable[Metric]) -> None:
if metrics is None:
return
token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True))
try:
self._exporter.export(metrics)
Expand All @@ -172,4 +174,5 @@ def _shutdown():

self._shutdown_event.set()
self._daemon_thread.join()
return self._exporter.shutdown()
self._exporter.shutdown()
return True

0 comments on commit a659966

Please sign in to comment.