Skip to content

Commit a63ca55

Browse files
committed
update comments
1 parent 2007cde commit a63ca55

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

docs/examples/multi-destination-exporting/multi_destination_logs.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from opentelemetry.exporter.otlp.proto.http._log_exporter import (
2828
OTLPLogExporter as HttpLogExporter,
2929
)
30+
from opentelemetry.instrumentation.logging.handler import LoggingHandler
3031
from opentelemetry.sdk._logs import LoggerProvider
3132
from opentelemetry.sdk._logs.export import (
3233
BatchLogRecordProcessor,
@@ -57,9 +58,12 @@
5758
BatchLogRecordProcessor(ConsoleLogRecordExporter())
5859
)
5960

60-
# Use Python's standard logging, bridged to OpenTelemetry
61+
# Bridge Python's logging to OpenTelemetry
62+
handler = LoggingHandler(level=logging.NOTSET, logger_provider=logger_provider)
63+
logging.getLogger().setLevel(logging.NOTSET)
64+
logging.getLogger().addHandler(handler)
65+
6166
logger = logging.getLogger("myapp")
62-
logger.setLevel(logging.INFO)
6367
logger.info("Logs are exported to all three destinations.")
6468
logger.warning("This warning also goes everywhere.")
6569

docs/examples/multi-destination-exporting/multi_destination_metrics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@
3131
PeriodicExportingMetricReader,
3232
)
3333

34-
# Each reader has its own export interval and exporter
34+
# Destination 1: OTLP over gRPC
3535
grpc_reader = PeriodicExportingMetricReader(
3636
GrpcMetricExporter(endpoint="http://localhost:4317", insecure=True)
3737
)
38+
39+
# Destination 2: OTLP over HTTP
3840
http_reader = PeriodicExportingMetricReader(
3941
HttpMetricExporter(endpoint="http://localhost:4318/v1/metrics")
4042
)
43+
44+
# Destination 3: Console (for debugging)
4145
console_reader = PeriodicExportingMetricReader(ConsoleMetricExporter())
4246

4347
# Pass all readers to the MeterProvider

0 commit comments

Comments
 (0)