Skip to content

bugfix(auto-instrumentation): attach OTLPHandler to root logger #2450

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

Merged
merged 9 commits into from
Feb 10, 2022
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `opentelemetry-exporter-otlp-grpc` update SDK dependency to ~1.9.
([#2442](https://github.com/open-telemetry/opentelemetry-python/pull/2442))
- bugfix(auto-instrumentation): attach OTLPHandler to root logger
([#2450](https://github.com/open-telemetry/opentelemetry-python/pull/2450))

## [1.9.1-0.28b1](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.9.1-0.28b1) - 2022-01-29

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
OpenTelemetry SDK Configurator for Easy Instrumentation with Distros
"""

import logging
from abc import ABC, abstractmethod
from os import environ
from typing import Dict, Optional, Sequence, Tuple, Type
Expand All @@ -31,6 +32,7 @@
)
from opentelemetry.sdk._logs import (
LogEmitterProvider,
OTLPHandler,
set_log_emitter_provider,
)
from opentelemetry.sdk._logs.export import BatchLogProcessor, LogExporter
Expand Down Expand Up @@ -91,7 +93,7 @@ def _init_tracing(


def _init_logging(
exporters: Dict[str, Sequence[LogExporter]],
exporters: Dict[str, Type[LogExporter]],
auto_instrumentation_version: Optional[str] = None,
):
# if env var OTEL_RESOURCE_ATTRIBUTES is given, it will read the service_name
Expand All @@ -111,6 +113,11 @@ def _init_logging(
BatchLogProcessor(exporter_class(**exporter_args))
)

log_emitter = provider.get_log_emitter(__name__)
handler = OTLPHandler(level=logging.NOTSET, log_emitter=log_emitter)

logging.getLogger().addHandler(handler)


def _import_config_components(
selected_components, entry_point_name
Expand Down