diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cab9302a0..53cb313e4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v1.13.0...HEAD) +- Update log symbol names + ([#2943](https://github.com/open-telemetry/opentelemetry-python/pull/2943)) - Update explicit histogram bucket boundaries ([#2947](https://github.com/open-telemetry/opentelemetry-python/pull/2947)) - `exporter-otlp-proto-http`: add user agent string @@ -17,7 +19,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.13.0-0.34b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.13.0) - 2022-09-26 - - Add a configurable max_export_batch_size to the gRPC metrics exporter ([#2809](https://github.com/open-telemetry/opentelemetry-python/pull/2809)) - Remove support for 3.6 diff --git a/docs/examples/logs/example.py b/docs/examples/logs/example.py index ff05251212..b2b1593262 100644 --- a/docs/examples/logs/example.py +++ b/docs/examples/logs/example.py @@ -5,11 +5,11 @@ OTLPLogExporter, ) from opentelemetry.sdk._logs import ( - LogEmitterProvider, + LoggerProvider, LoggingHandler, - set_log_emitter_provider, + set_logger_provider, ) -from opentelemetry.sdk._logs.export import BatchLogProcessor +from opentelemetry.sdk._logs.export import BatchLogRecordProcessor from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ( @@ -22,7 +22,7 @@ BatchSpanProcessor(ConsoleSpanExporter()) ) -log_emitter_provider = LogEmitterProvider( +logger_provider = LoggerProvider( resource=Resource.create( { "service.name": "shoppingcart", @@ -30,13 +30,11 @@ } ), ) -set_log_emitter_provider(log_emitter_provider) +set_logger_provider(logger_provider) exporter = OTLPLogExporter(insecure=True) -log_emitter_provider.add_log_processor(BatchLogProcessor(exporter)) -handler = LoggingHandler( - level=logging.NOTSET, log_emitter_provider=log_emitter_provider -) +logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter)) +handler = LoggingHandler(level=logging.NOTSET, logger_provider=logger_provider) # Attach OTLP handler to root logger logging.getLogger().addHandler(handler) @@ -60,4 +58,4 @@ # Do something logger2.error("Hyderabad, we have a major problem.") -log_emitter_provider.shutdown() +logger_provider.shutdown() diff --git a/opentelemetry-sdk/pyproject.toml b/opentelemetry-sdk/pyproject.toml index 9b106b83f8..e076a6a40e 100644 --- a/opentelemetry-sdk/pyproject.toml +++ b/opentelemetry-sdk/pyproject.toml @@ -40,8 +40,8 @@ sdk = "opentelemetry.sdk.environment_variables" [project.entry-points.opentelemetry_id_generator] random = "opentelemetry.sdk.trace.id_generator:RandomIdGenerator" -[project.entry-points.opentelemetry_log_emitter_provider] -sdk_log_emitter_provider = "opentelemetry.sdk._logs:LogEmitterProvider" +[project.entry-points.opentelemetry_logger_provider] +sdk_logger_provider = "opentelemetry.sdk._logs:LoggerProvider" [project.entry-points.opentelemetry_logs_exporter] console = "opentelemetry.sdk._logs.export:ConsoleLogExporter" diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py index 159d471900..fa057f785c 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py @@ -34,11 +34,11 @@ ) from opentelemetry.metrics import set_meter_provider from opentelemetry.sdk._logs import ( - LogEmitterProvider, + LoggerProvider, LoggingHandler, - set_log_emitter_provider, + set_logger_provider, ) -from opentelemetry.sdk._logs.export import BatchLogProcessor, LogExporter +from opentelemetry.sdk._logs.export import BatchLogRecordProcessor, LogExporter from opentelemetry.sdk.environment_variables import ( _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, OTEL_EXPORTER_OTLP_LOGS_PROTOCOL, @@ -212,18 +212,16 @@ def _init_logging( auto_resource[ ResourceAttributes.TELEMETRY_AUTO_VERSION ] = auto_instrumentation_version - provider = LogEmitterProvider(resource=Resource.create(auto_resource)) - set_log_emitter_provider(provider) + provider = LoggerProvider(resource=Resource.create(auto_resource)) + set_logger_provider(provider) for _, exporter_class in exporters.items(): exporter_args = {} - provider.add_log_processor( - BatchLogProcessor(exporter_class(**exporter_args)) + provider.add_log_record_processor( + BatchLogRecordProcessor(exporter_class(**exporter_args)) ) - handler = LoggingHandler( - level=logging.NOTSET, log_emitter_provider=provider - ) + handler = LoggingHandler(level=logging.NOTSET, logger_provider=provider) logging.getLogger().addHandler(handler) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py index 1a617ed3f0..1ca3aa48b0 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/__init__.py @@ -25,7 +25,7 @@ from opentelemetry.sdk._logs.severity import SeverityNumber, std_to_otlp from opentelemetry.sdk.environment_variables import ( - _OTEL_PYTHON_LOG_EMITTER_PROVIDER, + _OTEL_PYTHON_LOGGER_PROVIDER, ) from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.util import ns_to_iso_str @@ -46,7 +46,7 @@ class LogRecord: """A LogRecord instance represents an event being logged. - LogRecord instances are created and emitted via `LogEmitter` + LogRecord instances are created and emitted via `Logger` every time something is logged. They contain all the information pertinent to the event being logged. """ @@ -113,11 +113,11 @@ def __init__( self.instrumentation_scope = instrumentation_scope -class LogProcessor(abc.ABC): +class LogRecordProcessor(abc.ABC): """Interface to hook the log record emitting action. Log processors can be registered directly using - :func:`LogEmitterProvider.add_log_processor` and they are invoked + :func:`LoggerProvider.add_log_record_processor` and they are invoked in the same order as they were registered. """ @@ -127,7 +127,7 @@ def emit(self, log_data: LogData): @abc.abstractmethod def shutdown(self): - """Called when a :class:`opentelemetry.sdk._logs.LogEmitter` is shutdown""" + """Called when a :class:`opentelemetry.sdk._logs.Logger` is shutdown""" @abc.abstractmethod def force_flush(self, timeout_millis: int = 30000): @@ -145,8 +145,8 @@ def force_flush(self, timeout_millis: int = 30000): # Temporary fix until https://github.com/PyCQA/pylint/issues/4098 is resolved # pylint:disable=no-member -class SynchronousMultiLogProcessor(LogProcessor): - """Implementation of class:`LogProcessor` that forwards all received +class SynchronousMultiLogRecordProcessor(LogRecordProcessor): + """Implementation of class:`LogRecordProcessor` that forwards all received events to a list of log processors sequentially. The underlying log processors are called in sequential order as they were @@ -156,21 +156,23 @@ class SynchronousMultiLogProcessor(LogProcessor): def __init__(self): # use a tuple to avoid race conditions when adding a new log and # iterating through it on "emit". - self._log_processors = () # type: Tuple[LogProcessor, ...] + self._log_record_processors = () # type: Tuple[LogRecordProcessor, ...] self._lock = threading.Lock() - def add_log_processor(self, log_processor: LogProcessor) -> None: + def add_log_record_processor( + self, log_record_processor: LogRecordProcessor + ) -> None: """Adds a Logprocessor to the list of log processors handled by this instance""" with self._lock: - self._log_processors += (log_processor,) + self._log_record_processors += (log_record_processor,) def emit(self, log_data: LogData) -> None: - for lp in self._log_processors: + for lp in self._log_record_processors: lp.emit(log_data) def shutdown(self) -> None: """Shutdown the log processors one by one""" - for lp in self._log_processors: + for lp in self._log_record_processors: lp.shutdown() def force_flush(self, timeout_millis: int = 30000) -> bool: @@ -186,7 +188,7 @@ def force_flush(self, timeout_millis: int = 30000) -> bool: False otherwise. """ deadline_ns = time_ns() + timeout_millis * 1000000 - for lp in self._log_processors: + for lp in self._log_record_processors: current_ts = time_ns() if current_ts >= deadline_ns: return False @@ -197,8 +199,8 @@ def force_flush(self, timeout_millis: int = 30000) -> bool: return True -class ConcurrentMultiLogProcessor(LogProcessor): - """Implementation of :class:`LogProcessor` that forwards all received +class ConcurrentMultiLogRecordProcessor(LogRecordProcessor): + """Implementation of :class:`LogRecordProcessor` that forwards all received events to a list of log processors in parallel. Calls to the underlying log processors are forwarded in parallel by @@ -213,24 +215,26 @@ class ConcurrentMultiLogProcessor(LogProcessor): def __init__(self, max_workers: int = 2): # use a tuple to avoid race conditions when adding a new log and # iterating through it on "emit". - self._log_processors = () # type: Tuple[LogProcessor, ...] + self._log_record_processors = () # type: Tuple[LogRecordProcessor, ...] self._lock = threading.Lock() self._executor = concurrent.futures.ThreadPoolExecutor( max_workers=max_workers ) - def add_log_processor(self, log_processor: LogProcessor): + def add_log_record_processor( + self, log_record_processor: LogRecordProcessor + ): with self._lock: - self._log_processors += (log_processor,) + self._log_record_processors += (log_record_processor,) def _submit_and_wait( self, - func: Callable[[LogProcessor], Callable[..., None]], + func: Callable[[LogRecordProcessor], Callable[..., None]], *args: Any, **kwargs: Any, ): futures = [] - for lp in self._log_processors: + for lp in self._log_record_processors: future = self._executor.submit(func(lp), *args, **kwargs) futures.append(future) for future in futures: @@ -254,7 +258,7 @@ def force_flush(self, timeout_millis: int = 30000) -> bool: False otherwise. """ futures = [] - for lp in self._log_processors: + for lp in self._log_record_processors: future = self._executor.submit(lp.force_flush, timeout_millis) futures.append(future) @@ -311,14 +315,12 @@ class LoggingHandler(logging.Handler): def __init__( self, level=logging.NOTSET, - log_emitter_provider=None, + logger_provider=None, ) -> None: super().__init__(level=level) - self._log_emitter_provider = ( - log_emitter_provider or get_log_emitter_provider() - ) - self._log_emitter = get_log_emitter( - __name__, log_emitter_provider=self._log_emitter_provider + self._logger_provider = logger_provider or get_logger_provider() + self._logger = get_logger( + __name__, logger_provider=self._logger_provider ) @staticmethod @@ -358,7 +360,7 @@ def _translate(self, record: logging.LogRecord) -> LogRecord: severity_text=record.levelname, severity_number=severity_number, body=record.getMessage(), - resource=self._log_emitter.resource, + resource=self._logger.resource, attributes=attributes, ) @@ -368,26 +370,27 @@ def emit(self, record: logging.LogRecord) -> None: The record is translated to OTLP format, and then sent across the pipeline. """ - self._log_emitter.emit(self._translate(record)) + self._logger.emit(self._translate(record)) def flush(self) -> None: """ Flushes the logging output. """ - self._log_emitter_provider.force_flush() + self._logger_provider.force_flush() -class LogEmitter: +class Logger: def __init__( self, resource: Resource, - multi_log_processor: Union[ - SynchronousMultiLogProcessor, ConcurrentMultiLogProcessor + multi_log_record_processor: Union[ + SynchronousMultiLogRecordProcessor, + ConcurrentMultiLogRecordProcessor, ], instrumentation_scope: InstrumentationScope, ): self._resource = resource - self._multi_log_processor = multi_log_processor + self._multi_log_record_processor = multi_log_record_processor self._instrumentation_scope = instrumentation_scope @property @@ -399,21 +402,22 @@ def emit(self, record: LogRecord): and instrumentation info. """ log_data = LogData(record, self._instrumentation_scope) - self._multi_log_processor.emit(log_data) + self._multi_log_record_processor.emit(log_data) -class LogEmitterProvider: +class LoggerProvider: def __init__( self, resource: Resource = Resource.create(), shutdown_on_exit: bool = True, - multi_log_processor: Union[ - SynchronousMultiLogProcessor, ConcurrentMultiLogProcessor + multi_log_record_processor: Union[ + SynchronousMultiLogRecordProcessor, + ConcurrentMultiLogRecordProcessor, ] = None, ): self._resource = resource - self._multi_log_processor = ( - multi_log_processor or SynchronousMultiLogProcessor() + self._multi_log_record_processor = ( + multi_log_record_processor or SynchronousMultiLogRecordProcessor() ) self._at_exit_handler = None if shutdown_on_exit: @@ -423,29 +427,33 @@ def __init__( def resource(self): return self._resource - def get_log_emitter( + def get_logger( self, instrumenting_module_name: str, instrumenting_module_version: str = "", - ) -> LogEmitter: - return LogEmitter( + ) -> Logger: + return Logger( self._resource, - self._multi_log_processor, + self._multi_log_record_processor, InstrumentationScope( instrumenting_module_name, instrumenting_module_version ), ) - def add_log_processor(self, log_processor: LogProcessor): - """Registers a new :class:`LogProcessor` for this `LogEmitterProvider` instance. + def add_log_record_processor( + self, log_record_processor: LogRecordProcessor + ): + """Registers a new :class:`LogRecordProcessor` for this `LoggerProvider` instance. The log processors are invoked in the same order they are registered. """ - self._multi_log_processor.add_log_processor(log_processor) + self._multi_log_record_processor.add_log_record_processor( + log_record_processor + ) def shutdown(self): """Shuts down the log processors.""" - self._multi_log_processor.shutdown() + self._multi_log_record_processor.shutdown() if self._at_exit_handler is not None: atexit.unregister(self._at_exit_handler) self._at_exit_handler = None @@ -461,61 +469,57 @@ def force_flush(self, timeout_millis: int = 30000) -> bool: True if all the log processors flushes the logs within timeout, False otherwise. """ - return self._multi_log_processor.force_flush(timeout_millis) + return self._multi_log_record_processor.force_flush(timeout_millis) -_LOG_EMITTER_PROVIDER = None +_LOGGER_PROVIDER = None -def get_log_emitter_provider() -> LogEmitterProvider: - """Gets the current global :class:`~.LogEmitterProvider` object.""" - global _LOG_EMITTER_PROVIDER # pylint: disable=global-statement - if _LOG_EMITTER_PROVIDER is None: - if _OTEL_PYTHON_LOG_EMITTER_PROVIDER not in os.environ: - _LOG_EMITTER_PROVIDER = LogEmitterProvider() - return _LOG_EMITTER_PROVIDER +def get_logger_provider() -> LoggerProvider: + """Gets the current global :class:`~.LoggerProvider` object.""" + global _LOGGER_PROVIDER # pylint: disable=global-statement + if _LOGGER_PROVIDER is None: + if _OTEL_PYTHON_LOGGER_PROVIDER not in os.environ: + _LOGGER_PROVIDER = LoggerProvider() + return _LOGGER_PROVIDER - _LOG_EMITTER_PROVIDER = cast( - "LogEmitterProvider", - _load_provider( - _OTEL_PYTHON_LOG_EMITTER_PROVIDER, "log_emitter_provider" - ), + _LOGGER_PROVIDER = cast( + "LoggerProvider", + _load_provider(_OTEL_PYTHON_LOGGER_PROVIDER, "logger_provider"), ) - return _LOG_EMITTER_PROVIDER + return _LOGGER_PROVIDER -def set_log_emitter_provider(log_emitter_provider: LogEmitterProvider) -> None: - """Sets the current global :class:`~.LogEmitterProvider` object. +def set_logger_provider(logger_provider: LoggerProvider) -> None: + """Sets the current global :class:`~.LoggerProvider` object. This can only be done once, a warning will be logged if any further attempt is made. """ - global _LOG_EMITTER_PROVIDER # pylint: disable=global-statement + global _LOGGER_PROVIDER # pylint: disable=global-statement - if _LOG_EMITTER_PROVIDER is not None: - _logger.warning( - "Overriding of current LogEmitterProvider is not allowed" - ) + if _LOGGER_PROVIDER is not None: + _logger.warning("Overriding of current LoggerProvider is not allowed") return - _LOG_EMITTER_PROVIDER = log_emitter_provider + _LOGGER_PROVIDER = logger_provider -def get_log_emitter( +def get_logger( instrumenting_module_name: str, instrumenting_library_version: str = "", - log_emitter_provider: Optional[LogEmitterProvider] = None, -) -> LogEmitter: - """Returns a `LogEmitter` for use within a python process. + logger_provider: Optional[LoggerProvider] = None, +) -> Logger: + """Returns a `Logger` for use within a python process. This function is a convenience wrapper for - opentelemetry.sdk._logs.LogEmitterProvider.get_log_emitter. + opentelemetry.sdk._logs.LoggerProvider.get_logger. - If log_emitter_provider param is omitted the current configured one is used. + If logger_provider param is omitted the current configured one is used. """ - if log_emitter_provider is None: - log_emitter_provider = get_log_emitter_provider() - return log_emitter_provider.get_log_emitter( + if logger_provider is None: + logger_provider = get_logger_provider() + return logger_provider.get_logger( instrumenting_module_name, instrumenting_library_version ) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py index af0221d991..3f19b79e10 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/export/__init__.py @@ -24,7 +24,7 @@ from typing import IO, Callable, Deque, List, Optional, Sequence from opentelemetry.context import attach, detach, set_value -from opentelemetry.sdk._logs import LogData, LogProcessor, LogRecord +from opentelemetry.sdk._logs import LogData, LogRecord, LogRecordProcessor from opentelemetry.util._once import Once _logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ class LogExporter(abc.ABC): Interface to be implemented by services that want to export logs received in their own format. - To export data this MUST be registered to the :class`opentelemetry.sdk._logs.LogEmitter` using a + To export data this MUST be registered to the :class`opentelemetry.sdk._logs.Logger` using a log processor. """ @@ -91,8 +91,8 @@ def shutdown(self): pass -class SimpleLogProcessor(LogProcessor): - """This is an implementation of LogProcessor which passes +class SimpleLogRecordProcessor(LogRecordProcessor): + """This is an implementation of LogRecordProcessor which passes received logs in the export-friendly LogData representation to the configured LogExporter, as soon as they are emitted. """ @@ -133,8 +133,8 @@ def __init__(self): _BSP_RESET_ONCE = Once() -class BatchLogProcessor(LogProcessor): - """This is an implementation of LogProcessor which creates batches of +class BatchLogRecordProcessor(LogRecordProcessor): + """This is an implementation of LogRecordProcessor which creates batches of received logs in the export-friendly LogData representation and send to the configured LogExporter, as soon as they are emitted. """ @@ -152,7 +152,7 @@ def __init__( self._export_timeout_millis = export_timeout_millis self._queue = collections.deque() # type: Deque[LogData] self._worker_thread = threading.Thread( - name="OtelBatchLogProcessor", + name="OtelBatchLogRecordProcessor", target=self.worker, daemon=True, ) @@ -174,7 +174,7 @@ def _at_fork_reinit(self): self._condition = threading.Condition(threading.Lock()) self._queue.clear() self._worker_thread = threading.Thread( - name="OtelBatchLogProcessor", + name="OtelBatchLogRecordProcessor", target=self.worker, daemon=True, ) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py index ad635e89d5..d469c24478 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/environment_variables.py @@ -412,13 +412,13 @@ If both are set, :envvar:`OTEL_SERVICE_NAME` takes precedence. """ -_OTEL_PYTHON_LOG_EMITTER_PROVIDER = "OTEL_PYTHON_LOG_EMITTER_PROVIDER" +_OTEL_PYTHON_LOGGER_PROVIDER = "OTEL_PYTHON_LOGGER_PROVIDER" """ -.. envvar:: OTEL_PYTHON_LOG_EMITTER_PROVIDER +.. envvar:: OTEL_PYTHON_LOGGER_PROVIDER -The :envvar:`OTEL_PYTHON_LOG_EMITTER_PROVIDER` environment variable allows users to +The :envvar:`OTEL_PYTHON_LOGGER_PROVIDER` environment variable allows users to provide the entry point for loading the log emitter provider. If not specified, SDK -LogEmitterProvider is used. +LoggerProvider is used. """ _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED = ( diff --git a/opentelemetry-sdk/tests/logs/test_export.py b/opentelemetry-sdk/tests/logs/test_export.py index 3c55415d52..e65fc04a42 100644 --- a/opentelemetry-sdk/tests/logs/test_export.py +++ b/opentelemetry-sdk/tests/logs/test_export.py @@ -24,14 +24,14 @@ from opentelemetry.sdk import trace from opentelemetry.sdk._logs import ( LogData, - LogEmitterProvider, + LoggerProvider, LoggingHandler, LogRecord, ) from opentelemetry.sdk._logs.export import ( - BatchLogProcessor, + BatchLogRecordProcessor, ConsoleLogExporter, - SimpleLogProcessor, + SimpleLogRecordProcessor, ) from opentelemetry.sdk._logs.export.in_memory_log_exporter import ( InMemoryLogExporter, @@ -44,17 +44,17 @@ from opentelemetry.trace.span import INVALID_SPAN_CONTEXT -class TestSimpleLogProcessor(unittest.TestCase): - def test_simple_log_processor_default_level(self): +class TestSimpleLogRecordProcessor(unittest.TestCase): + def test_simple_log_record_processor_default_level(self): exporter = InMemoryLogExporter() - log_emitter_provider = LogEmitterProvider() + logger_provider = LoggerProvider() - log_emitter_provider.add_log_processor(SimpleLogProcessor(exporter)) + logger_provider.add_log_record_processor( + SimpleLogRecordProcessor(exporter) + ) logger = logging.getLogger("default_level") - logger.addHandler( - LoggingHandler(log_emitter_provider=log_emitter_provider) - ) + logger.addHandler(LoggingHandler(logger_provider=logger_provider)) logger.warning("Something is wrong") finished_logs = exporter.get_finished_logs() @@ -66,17 +66,17 @@ def test_simple_log_processor_default_level(self): warning_log_record.severity_number, SeverityNumber.WARN ) - def test_simple_log_processor_custom_level(self): + def test_simple_log_record_processor_custom_level(self): exporter = InMemoryLogExporter() - log_emitter_provider = LogEmitterProvider() + logger_provider = LoggerProvider() - log_emitter_provider.add_log_processor(SimpleLogProcessor(exporter)) + logger_provider.add_log_record_processor( + SimpleLogRecordProcessor(exporter) + ) logger = logging.getLogger("custom_level") logger.setLevel(logging.ERROR) - logger.addHandler( - LoggingHandler(log_emitter_provider=log_emitter_provider) - ) + logger.addHandler(LoggingHandler(logger_provider=logger_provider)) logger.warning("Warning message") logger.debug("Debug message") @@ -98,16 +98,16 @@ def test_simple_log_processor_custom_level(self): fatal_log_record.severity_number, SeverityNumber.FATAL ) - def test_simple_log_processor_trace_correlation(self): + def test_simple_log_record_processor_trace_correlation(self): exporter = InMemoryLogExporter() - log_emitter_provider = LogEmitterProvider() + logger_provider = LoggerProvider() - log_emitter_provider.add_log_processor(SimpleLogProcessor(exporter)) + logger_provider.add_log_record_processor( + SimpleLogRecordProcessor(exporter) + ) logger = logging.getLogger("trace_correlation") - logger.addHandler( - LoggingHandler(log_emitter_provider=log_emitter_provider) - ) + logger.addHandler(LoggingHandler(logger_provider=logger_provider)) logger.warning("Warning message") finished_logs = exporter.get_finished_logs() @@ -137,16 +137,16 @@ def test_simple_log_processor_trace_correlation(self): self.assertEqual(log_record.span_id, span_context.span_id) self.assertEqual(log_record.trace_flags, span_context.trace_flags) - def test_simple_log_processor_shutdown(self): + def test_simple_log_record_processor_shutdown(self): exporter = InMemoryLogExporter() - log_emitter_provider = LogEmitterProvider() + logger_provider = LoggerProvider() - log_emitter_provider.add_log_processor(SimpleLogProcessor(exporter)) + logger_provider.add_log_record_processor( + SimpleLogRecordProcessor(exporter) + ) logger = logging.getLogger("shutdown") - logger.addHandler( - LoggingHandler(log_emitter_provider=log_emitter_provider) - ) + logger.addHandler(LoggingHandler(logger_provider=logger_provider)) logger.warning("Something is wrong") finished_logs = exporter.get_finished_logs() @@ -158,40 +158,40 @@ def test_simple_log_processor_shutdown(self): warning_log_record.severity_number, SeverityNumber.WARN ) exporter.clear() - log_emitter_provider.shutdown() + logger_provider.shutdown() logger.warning("Log after shutdown") finished_logs = exporter.get_finished_logs() self.assertEqual(len(finished_logs), 0) -class TestBatchLogProcessor(ConcurrencyTestBase): +class TestBatchLogRecordProcessor(ConcurrencyTestBase): def test_emit_call_log_record(self): exporter = InMemoryLogExporter() - log_processor = Mock(wraps=BatchLogProcessor(exporter)) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + log_record_processor = Mock(wraps=BatchLogRecordProcessor(exporter)) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("emit_call") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) logger.error("error") - self.assertEqual(log_processor.emit.call_count, 1) + self.assertEqual(log_record_processor.emit.call_count, 1) def test_shutdown(self): exporter = InMemoryLogExporter() - log_processor = BatchLogProcessor(exporter) + log_record_processor = BatchLogRecordProcessor(exporter) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("shutdown") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) logger.warning("warning message: %s", "possible upcoming heatwave") logger.error("Very high rise in temperatures across the globe") logger.critical("Temperature hits high 420 C in Hyderabad") - log_processor.shutdown() + log_record_processor.shutdown() self.assertTrue(exporter._stopped) finished_logs = exporter.get_finished_logs() @@ -211,53 +211,53 @@ def test_shutdown(self): def test_force_flush(self): exporter = InMemoryLogExporter() - log_processor = BatchLogProcessor(exporter) + log_record_processor = BatchLogRecordProcessor(exporter) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("force_flush") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) logger.critical("Earth is burning") - log_processor.force_flush() + log_record_processor.force_flush() finished_logs = exporter.get_finished_logs() self.assertEqual(len(finished_logs), 1) log_record = finished_logs[0].log_record self.assertEqual(log_record.body, "Earth is burning") self.assertEqual(log_record.severity_number, SeverityNumber.FATAL) - def test_log_processor_too_many_logs(self): + def test_log_record_processor_too_many_logs(self): exporter = InMemoryLogExporter() - log_processor = BatchLogProcessor(exporter) + log_record_processor = BatchLogRecordProcessor(exporter) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("many_logs") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) for log_no in range(1000): logger.critical("Log no: %s", log_no) - self.assertTrue(log_processor.force_flush()) + self.assertTrue(log_record_processor.force_flush()) finised_logs = exporter.get_finished_logs() self.assertEqual(len(finised_logs), 1000) def test_with_multiple_threads(self): exporter = InMemoryLogExporter() - log_processor = BatchLogProcessor(exporter) + log_record_processor = BatchLogRecordProcessor(exporter) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("threads") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) def bulk_log_and_flush(num_logs): for _ in range(num_logs): logger.critical("Critical message") - self.assertTrue(log_processor.force_flush()) + self.assertTrue(log_record_processor.force_flush()) with ThreadPoolExecutor(max_workers=69) as executor: futures = [] @@ -274,24 +274,24 @@ def bulk_log_and_flush(num_logs): hasattr(os, "fork"), "needs *nix", ) - def test_batch_log_processor_fork(self): + def test_batch_log_record_processor_fork(self): # pylint: disable=invalid-name exporter = InMemoryLogExporter() - log_processor = BatchLogProcessor( + log_record_processor = BatchLogRecordProcessor( exporter, max_export_batch_size=64, schedule_delay_millis=10, ) - provider = LogEmitterProvider() - provider.add_log_processor(log_processor) + provider = LoggerProvider() + provider.add_log_record_processor(log_record_processor) logger = logging.getLogger("test-fork") - logger.addHandler(LoggingHandler(log_emitter_provider=provider)) + logger.addHandler(LoggingHandler(logger_provider=provider)) logger.critical("yolo") time.sleep(0.5) # give some time for the exporter to upload - self.assertTrue(log_processor.force_flush()) + self.assertTrue(log_record_processor.force_flush()) self.assertEqual(len(exporter.get_finished_logs()), 1) exporter.clear() @@ -315,7 +315,7 @@ def _target(): self.assertTrue(parent_conn.recv()) p.join() - log_processor.shutdown() + log_record_processor.shutdown() class TestConsoleLogExporter(unittest.TestCase): diff --git a/opentelemetry-sdk/tests/logs/test_global_provider.py b/opentelemetry-sdk/tests/logs/test_global_provider.py index 7a249defcf..d888789898 100644 --- a/opentelemetry-sdk/tests/logs/test_global_provider.py +++ b/opentelemetry-sdk/tests/logs/test_global_provider.py @@ -20,12 +20,12 @@ from opentelemetry.sdk import _logs from opentelemetry.sdk._logs import ( - LogEmitterProvider, - get_log_emitter_provider, - set_log_emitter_provider, + LoggerProvider, + get_logger_provider, + set_logger_provider, ) from opentelemetry.sdk.environment_variables import ( - _OTEL_PYTHON_LOG_EMITTER_PROVIDER, + _OTEL_PYTHON_LOGGER_PROVIDER, ) @@ -34,26 +34,26 @@ def tearDown(self): reload(_logs) def check_override_not_allowed(self): - """set_log_emitter_provider should throw a warning when overridden""" - provider = get_log_emitter_provider() + """set_logger_provider should throw a warning when overridden""" + provider = get_logger_provider() with self.assertLogs(level=WARNING) as test: - set_log_emitter_provider(LogEmitterProvider()) + set_logger_provider(LoggerProvider()) self.assertEqual( test.output, [ ( "WARNING:opentelemetry.sdk._logs:Overriding of current " - "LogEmitterProvider is not allowed" + "LoggerProvider is not allowed" ) ], ) - self.assertIs(provider, get_log_emitter_provider()) + self.assertIs(provider, get_logger_provider()) def test_set_tracer_provider(self): reload(_logs) - provider = LogEmitterProvider() - set_log_emitter_provider(provider) - retrieved_provider = get_log_emitter_provider() + provider = LoggerProvider() + set_logger_provider(provider) + retrieved_provider = get_logger_provider() self.assertEqual(provider, retrieved_provider) def test_tracer_provider_override_warning(self): @@ -62,14 +62,14 @@ def test_tracer_provider_override_warning(self): @patch.dict( "os.environ", - {_OTEL_PYTHON_LOG_EMITTER_PROVIDER: "sdk_log_emitter_provider"}, + {_OTEL_PYTHON_LOGGER_PROVIDER: "sdk_logger_provider"}, ) - def test_sdk_log_emitter_provider(self): + def test_sdk_logger_provider(self): reload(_logs) self.check_override_not_allowed() - @patch.dict("os.environ", {_OTEL_PYTHON_LOG_EMITTER_PROVIDER: "unknown"}) - def test_unknown_log_emitter_provider(self): + @patch.dict("os.environ", {_OTEL_PYTHON_LOGGER_PROVIDER: "unknown"}) + def test_unknown_logger_provider(self): reload(_logs) with self.assertRaises(Exception): - get_log_emitter_provider() + get_logger_provider() diff --git a/opentelemetry-sdk/tests/logs/test_handler.py b/opentelemetry-sdk/tests/logs/test_handler.py index 19fa891dea..771179c3d2 100644 --- a/opentelemetry-sdk/tests/logs/test_handler.py +++ b/opentelemetry-sdk/tests/logs/test_handler.py @@ -16,32 +16,27 @@ from unittest.mock import Mock from opentelemetry.sdk import trace -from opentelemetry.sdk._logs import ( - LogEmitterProvider, - LoggingHandler, - get_log_emitter, -) +from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler +from opentelemetry.sdk._logs import get_logger as sdk_get_logger from opentelemetry.sdk._logs.severity import SeverityNumber from opentelemetry.semconv.trace import SpanAttributes from opentelemetry.trace import INVALID_SPAN_CONTEXT -def get_logger(level=logging.NOTSET, log_emitter_provider=None): +def get_logger(level=logging.NOTSET, logger_provider=None): logger = logging.getLogger(__name__) - handler = LoggingHandler( - level=level, log_emitter_provider=log_emitter_provider - ) + handler = LoggingHandler(level=level, logger_provider=logger_provider) logger.addHandler(handler) return logger class TestLoggingHandler(unittest.TestCase): def test_handler_default_log_level(self): - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) # Make sure debug messages are ignored by default logger.debug("Debug message") self.assertEqual(emitter_mock.emit.call_count, 0) @@ -50,12 +45,12 @@ def test_handler_default_log_level(self): self.assertEqual(emitter_mock.emit.call_count, 1) def test_handler_custom_log_level(self): - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) logger = get_logger( - level=logging.ERROR, log_emitter_provider=emitter_provider_mock + level=logging.ERROR, logger_provider=emitter_provider_mock ) logger.warning("Warning message test custom log level") # Make sure any log with level < ERROR is ignored @@ -65,11 +60,11 @@ def test_handler_custom_log_level(self): self.assertEqual(emitter_mock.emit.call_count, 2) def test_log_record_no_span_context(self): - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) # Assert emit gets called for warning message logger.warning("Warning message") args, _ = emitter_mock.emit.call_args_list[0] @@ -84,11 +79,11 @@ def test_log_record_no_span_context(self): def test_log_record_user_attributes(self): """Attributes can be injected into logs by adding them to the LogRecord""" - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) # Assert emit gets called for warning message logger.warning("Warning message", extra={"http.status_code": 200}) args, _ = emitter_mock.emit.call_args_list[0] @@ -99,11 +94,11 @@ def test_log_record_user_attributes(self): def test_log_record_exception(self): """Exception information will be included in attributes""" - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) try: raise ZeroDivisionError("division by zero") except ZeroDivisionError: @@ -132,11 +127,11 @@ def test_log_record_exception(self): def test_log_exc_info_false(self): """Exception information will be included in attributes""" - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) try: raise ZeroDivisionError("division by zero") except ZeroDivisionError: @@ -155,11 +150,11 @@ def test_log_exc_info_false(self): ) def test_log_record_trace_correlation(self): - emitter_provider_mock = Mock(spec=LogEmitterProvider) - emitter_mock = get_log_emitter( - __name__, log_emitter_provider=emitter_provider_mock + emitter_provider_mock = Mock(spec=LoggerProvider) + emitter_mock = sdk_get_logger( + __name__, logger_provider=emitter_provider_mock ) - logger = get_logger(log_emitter_provider=emitter_provider_mock) + logger = get_logger(logger_provider=emitter_provider_mock) tracer = trace.TracerProvider().get_tracer(__name__) with tracer.start_as_current_span("test") as span: diff --git a/opentelemetry-sdk/tests/logs/test_multi_log_prcessor.py b/opentelemetry-sdk/tests/logs/test_multi_log_prcessor.py index c87b8ba409..004bc296be 100644 --- a/opentelemetry-sdk/tests/logs/test_multi_log_prcessor.py +++ b/opentelemetry-sdk/tests/logs/test_multi_log_prcessor.py @@ -22,17 +22,17 @@ from unittest.mock import Mock from opentelemetry.sdk._logs import ( - ConcurrentMultiLogProcessor, - LogEmitterProvider, + ConcurrentMultiLogRecordProcessor, + LoggerProvider, LoggingHandler, - LogProcessor, LogRecord, - SynchronousMultiLogProcessor, + LogRecordProcessor, + SynchronousMultiLogRecordProcessor, ) from opentelemetry.sdk._logs.severity import SeverityNumber -class AnotherLogProcessor(LogProcessor): +class AnotherLogRecordProcessor(LogRecordProcessor): def __init__(self, exporter, logs_list): self._exporter = exporter self._log_list = logs_list @@ -54,15 +54,15 @@ def force_flush(self, timeout_millis=30000): return True -class TestLogProcessor(unittest.TestCase): - def test_log_processor(self): - provider = LogEmitterProvider() - handler = LoggingHandler(log_emitter_provider=provider) +class TestLogRecordProcessor(unittest.TestCase): + def test_log_record_processor(self): + provider = LoggerProvider() + handler = LoggingHandler(logger_provider=provider) logs_list_1 = [] - processor1 = AnotherLogProcessor(Mock(), logs_list_1) + processor1 = AnotherLogRecordProcessor(Mock(), logs_list_1) logs_list_2 = [] - processor2 = AnotherLogProcessor(Mock(), logs_list_2) + processor2 = AnotherLogRecordProcessor(Mock(), logs_list_2) logger = logging.getLogger("test.span.processor") logger.addHandler(handler) @@ -74,7 +74,7 @@ def test_log_processor(self): self.assertEqual(len(logs_list_2), 0) # Add one processor - provider.add_log_processor(processor1) + provider.add_log_record_processor(processor1) logger.warning("Brace yourself") logger.error("Some error message") @@ -85,7 +85,7 @@ def test_log_processor(self): self.assertEqual(logs_list_1, expected_list_1) # Add another processor - provider.add_log_processor(processor2) + provider.add_log_record_processor(processor2) logger.critical("Something disastrous") expected_list_1.append(("Something disastrous", "CRITICAL")) @@ -95,9 +95,9 @@ def test_log_processor(self): self.assertEqual(logs_list_2, expected_list_2) -class MultiLogProcessorTestBase(ABC): +class MultiLogRecordProcessorTestBase(ABC): @abstractmethod - def _get_multi_log_processor(self): + def _get_multi_log_record_processor(self): pass def make_record(self): @@ -109,85 +109,85 @@ def make_record(self): ) def test_on_emit(self): - multi_log_processor = self._get_multi_log_processor() - mocks = [Mock(spec=LogProcessor) for _ in range(5)] + multi_log_record_processor = self._get_multi_log_record_processor() + mocks = [Mock(spec=LogRecordProcessor) for _ in range(5)] for mock in mocks: - multi_log_processor.add_log_processor(mock) + multi_log_record_processor.add_log_record_processor(mock) record = self.make_record() - multi_log_processor.emit(record) + multi_log_record_processor.emit(record) for mock in mocks: mock.emit.assert_called_with(record) - multi_log_processor.shutdown() + multi_log_record_processor.shutdown() def test_on_shutdown(self): - multi_log_processor = self._get_multi_log_processor() - mocks = [Mock(spec=LogProcessor) for _ in range(5)] + multi_log_record_processor = self._get_multi_log_record_processor() + mocks = [Mock(spec=LogRecordProcessor) for _ in range(5)] for mock in mocks: - multi_log_processor.add_log_processor(mock) - multi_log_processor.shutdown() + multi_log_record_processor.add_log_record_processor(mock) + multi_log_record_processor.shutdown() for mock in mocks: mock.shutdown.assert_called_once_with() def test_on_force_flush(self): - multi_log_processor = self._get_multi_log_processor() - mocks = [Mock(spec=LogProcessor) for _ in range(5)] + multi_log_record_processor = self._get_multi_log_record_processor() + mocks = [Mock(spec=LogRecordProcessor) for _ in range(5)] for mock in mocks: - multi_log_processor.add_log_processor(mock) - ret_value = multi_log_processor.force_flush(100) + multi_log_record_processor.add_log_record_processor(mock) + ret_value = multi_log_record_processor.force_flush(100) self.assertTrue(ret_value) for mock_processor in mocks: self.assertEqual(1, mock_processor.force_flush.call_count) -class TestSynchronousMultiLogProcessor( - MultiLogProcessorTestBase, unittest.TestCase +class TestSynchronousMultiLogRecordProcessor( + MultiLogRecordProcessorTestBase, unittest.TestCase ): - def _get_multi_log_processor(self): - return SynchronousMultiLogProcessor() + def _get_multi_log_record_processor(self): + return SynchronousMultiLogRecordProcessor() def test_force_flush_delayed(self): - multi_log_processor = SynchronousMultiLogProcessor() + multi_log_record_processor = SynchronousMultiLogRecordProcessor() def delay(_): time.sleep(0.09) - mock_processor1 = Mock(spec=LogProcessor) + mock_processor1 = Mock(spec=LogRecordProcessor) mock_processor1.force_flush = Mock(side_effect=delay) - multi_log_processor.add_log_processor(mock_processor1) - mock_processor2 = Mock(spec=LogProcessor) - multi_log_processor.add_log_processor(mock_processor2) + multi_log_record_processor.add_log_record_processor(mock_processor1) + mock_processor2 = Mock(spec=LogRecordProcessor) + multi_log_record_processor.add_log_record_processor(mock_processor2) - ret_value = multi_log_processor.force_flush(50) + ret_value = multi_log_record_processor.force_flush(50) self.assertFalse(ret_value) self.assertEqual(mock_processor1.force_flush.call_count, 1) self.assertEqual(mock_processor2.force_flush.call_count, 0) -class TestConcurrentMultiLogProcessor( - MultiLogProcessorTestBase, unittest.TestCase +class TestConcurrentMultiLogRecordProcessor( + MultiLogRecordProcessorTestBase, unittest.TestCase ): - def _get_multi_log_processor(self): - return ConcurrentMultiLogProcessor() + def _get_multi_log_record_processor(self): + return ConcurrentMultiLogRecordProcessor() def test_force_flush_delayed(self): - multi_log_processor = ConcurrentMultiLogProcessor() + multi_log_record_processor = ConcurrentMultiLogRecordProcessor() wait_event = threading.Event() def delay(_): wait_event.wait() - mock1 = Mock(spec=LogProcessor) + mock1 = Mock(spec=LogRecordProcessor) mock1.force_flush = Mock(side_effect=delay) - mocks = [Mock(LogProcessor) for _ in range(5)] + mocks = [Mock(LogRecordProcessor) for _ in range(5)] mocks = [mock1] + mocks for mock_processor in mocks: - multi_log_processor.add_log_processor(mock_processor) + multi_log_record_processor.add_log_record_processor(mock_processor) - ret_value = multi_log_processor.force_flush(50) + ret_value = multi_log_record_processor.force_flush(50) wait_event.set() self.assertFalse(ret_value) for mock in mocks: self.assertEqual(1, mock.force_flush.call_count) - multi_log_processor.shutdown() + multi_log_record_processor.shutdown() diff --git a/opentelemetry-sdk/tests/test_configurator.py b/opentelemetry-sdk/tests/test_configurator.py index 4aae8aa53b..cf1b8253dd 100644 --- a/opentelemetry-sdk/tests/test_configurator.py +++ b/opentelemetry-sdk/tests/test_configurator.py @@ -61,16 +61,16 @@ def add_span_processor(self, processor): self.processor = processor -class DummyLogEmitterProvider: +class DummyLoggerProvider: def __init__(self, resource=None): self.resource = resource - self.processor = DummyLogProcessor(DummyOTLPLogExporter()) + self.processor = DummyLogRecordProcessor(DummyOTLPLogExporter()) - def add_log_processor(self, processor): + def add_log_record_processor(self, processor): self.processor = processor - def get_log_emitter(self, name, *args, **kwargs): - return DummyLogEmitter(name, self.resource, self.processor) + def get_logger(self, name, *args, **kwargs): + return DummyLogger(name, self.resource, self.processor) def force_flush(self, *args, **kwargs): pass @@ -80,7 +80,7 @@ class DummyMeterProvider(MeterProvider): pass -class DummyLogEmitter: +class DummyLogger: def __init__(self, name, resource, processor): self.name = name self.resource = resource @@ -90,7 +90,7 @@ def emit(self, record): self.processor.emit(record) -class DummyLogProcessor: +class DummyLogRecordProcessor: def __init__(self, exporter): self.exporter = exporter @@ -274,15 +274,15 @@ def test_trace_init_custom_id_generator(self, mock_iter_entry_points): class TestLoggingInit(TestCase): def setUp(self): self.processor_patch = patch( - "opentelemetry.sdk._configuration.BatchLogProcessor", - DummyLogProcessor, + "opentelemetry.sdk._configuration.BatchLogRecordProcessor", + DummyLogRecordProcessor, ) self.provider_patch = patch( - "opentelemetry.sdk._configuration.LogEmitterProvider", - DummyLogEmitterProvider, + "opentelemetry.sdk._configuration.LoggerProvider", + DummyLoggerProvider, ) self.set_provider_patch = patch( - "opentelemetry.sdk._configuration.set_log_emitter_provider" + "opentelemetry.sdk._configuration.set_logger_provider" ) self.processor_mock = self.processor_patch.start() @@ -304,7 +304,7 @@ def test_logging_init_empty(self): _init_logging({}, "auto-version") self.assertEqual(self.set_provider_mock.call_count, 1) provider = self.set_provider_mock.call_args[0][0] - self.assertIsInstance(provider, DummyLogEmitterProvider) + self.assertIsInstance(provider, DummyLoggerProvider) self.assertIsInstance(provider.resource, Resource) self.assertEqual( provider.resource.attributes.get("telemetry.auto.version"), @@ -319,13 +319,13 @@ def test_logging_init_exporter(self): _init_logging({"otlp": DummyOTLPLogExporter}) self.assertEqual(self.set_provider_mock.call_count, 1) provider = self.set_provider_mock.call_args[0][0] - self.assertIsInstance(provider, DummyLogEmitterProvider) + self.assertIsInstance(provider, DummyLoggerProvider) self.assertIsInstance(provider.resource, Resource) self.assertEqual( provider.resource.attributes.get("service.name"), "otlp-service", ) - self.assertIsInstance(provider.processor, DummyLogProcessor) + self.assertIsInstance(provider.processor, DummyLogRecordProcessor) self.assertIsInstance( provider.processor.exporter, DummyOTLPLogExporter )