[Bug]: Plain OTLP path does not attach LoggingHandler when logger_name is omitted
Los mantenedores suelen responder en 1 día
@vincimech010233 ya está trabajando en esto.
Desde el 12/10/2026.
- #288 de @vincimech010233 — abierto
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- observability
Línea de trabajo
Lee la configuración básica de OTLP, donde se lee logger_name y la creación del handler está protegida por una condición; después, compárala con la ruta de Azure Monitor descrita en el issue. Reproduce el issue en un proceso de Python nuevo con el script proporcionado y comprueba si el logger raíz tiene un LoggingHandler. Se considera resuelto cuando los logs estándar de Python llegan a la canalización de OTLP configurada si se omite logger_name, y se mantiene la protección contra handlers duplicados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Component
Distro
Description
When use_microsoft_opentelemetry() is configured for plain OTLP export and logger_name is omitted, the distro creates the OTel LoggerProvider, log record processors, and exporter, but does not attach an OTel LoggingHandler to Python logging.
As a result:
- Direct OTel Logs API calls can be exported.
- Standard Python calls such as
logging.getLogger(__name__).info(...)are not exported.
The plain-OTLP setup currently uses an empty string as the default and guards handler creation with a truthiness check:
logger_name: str = otel_kwargs.get(LOGGER_NAME_ARG, "")
if logger_name:
logger = getLogger(logger_name)
# Attach LoggingHandler
This is inconsistent with Python logging semantics:
logging.getLogger("") is logging.getLogger("root")
An empty logger name validly resolves to the root logger, but the truthiness check prevents that resolution.
The behavior is also inconsistent with the Azure Monitor path, which resolves the empty logger name and attaches the handler to the root logger.
This affects callers such as azure-ai-agentserver-core, which configures resources, processors, and exporters but does not currently pass logger_name. Consequently, standard application logs are missing when it uses the plain-OTLP path, while the same logs work through the Azure Monitor path.
Expected Behavior
Plain OTLP and Azure Monitor setup should behave consistently.
When log export is configured and logger_name is omitted or defaults to "", standard Python logging should be connected to the configured OTel LoggerProvider, preferably by attaching one LoggingHandler to the root logger.
If an empty value is intentionally meant to disable Python logging collection, that behavior should be explicit and documented. The default one-call onboarding behavior should export standard Python logs consistently across exporter paths.
Steps to Reproduce
-
Install the latest release:
pip install microsoft-opentelemetry==1.4.0 -
Run the following in a fresh Python process:
import logging import os from microsoft.opentelemetry import use_microsoft_opentelemetry from opentelemetry.sdk._logs import LoggingHandler os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "http://localhost:4318" use_microsoft_opentelemetry() root = logging.getLogger() print( any( isinstance(handler, LoggingHandler) for handler in root.handlers ) ) logging.getLogger(__name__).warning("standard Python log") -
Observe that the printed result is
False. The standard Python log has no OTel logging handler and does not enter the OTLP logs pipeline. -
Change initialization to:
use_microsoft_opentelemetry(logger_name="root") -
Observe that an OTel
LoggingHandleris attached and the standard Python log enters the OTLP logs pipeline.
Environment
microsoft-opentelemetry: reproduced with1.4.0; originally observed with1.3.9- Export path: plain OTLP through
OTEL_EXPORTER_OTLP_ENDPOINT - Azure Monitor exporter: disabled
- Python logging API:
logging.getLogger(__name__) - Runtime: reproducible in a standalone Python process
Suggested Fix
Resolve the logger name even when it is empty, while retaining the existing duplicate-handler protection:
logger = getLogger(logger_name)
if not any(
isinstance(handler, LoggingHandler)
for handler in logger.handlers
):
handler = LoggingHandler(logger_provider=logger_provider)
if logging_formatter:
handler.setFormatter(logging_formatter)
logger.addHandler(handler)
Alternatively, default logger_name to "root".
Resolving the empty name is preferable because it preserves Python's existing empty-name-to-root semantics and aligns the plain-OTLP path with the Azure Monitor path.
- Lenguaje dominante
- Python
- Estrellas
- 1
- Forks
- 21
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 13
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/opentelemetry-distro-python
-
[Question]:Quizá libre de nuevo @nikhilNava la tomó hace 82 días y no hay ningún pull request abierto. AbiertoDistro question
microsoft/opentelemetry-distro-python#231 · 12 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/opentelemetry-distro-python
Issues similares
-
customer-reported question
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Azure/azure-sdk-for-python#49548 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
btclib-org/btclib-wallet#409 ·
Los mantenedores suelen responder en 1 día
-
Phase 2 PSA Capability & Career Profile
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
fastmachinelearning/hls4ml#1582 ·
Los mantenedores suelen responder en 3 días
-
Sort modelsAbiertoenhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día