diff --git a/opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py b/opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py index e67f28439b6..2148ca0050e 100644 --- a/opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py +++ b/opentelemetry-api/src/opentelemetry/_logs/_internal/__init__.py @@ -151,6 +151,9 @@ def get_logger( schema_url: Optional. Specifies the Schema URL of the emitted telemetry. """ + def force_flush(self) -> None: + pass + class NoOpLoggerProvider(LoggerProvider): """The default LoggerProvider used when no LoggerProvider implementation is available.""" diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index b6681b22d0d..cfa4d6cfa9b 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -543,10 +543,9 @@ def emit(self, record: logging.LogRecord) -> None: def flush(self) -> None: """ - Flushes the logging output. Skip flushing if logger is NoOp. + Flushes the logging output. """ - if not isinstance(self._logger, NoOpLogger): - self._logger_provider.force_flush() + self._logger_provider.force_flush() class Logger(APILogger):