The OpenTelemetry logging API describes the classes used to generate logs and events.
The LoggerProvider
provides users access to the Logger
.
This module provides abstract (i.e. unimplemented) classes required for logging, and a concrete no-op implementation NoOpLogger
that allows applications to use the API package alone without a supporting implementation.
To get a logger, you need to provide the package name from which you are calling the logging APIs to OpenTelemetry by calling LoggerProvider.get_logger with the calling module name and the version of your package.
The following code shows how to obtain a logger using the global LoggerProvider
:
from opentelemetry._logs import get_logger logger = get_logger("example-logger")
New in version 1.15.0.
Bases: ABC
Handles emitting events and logs via LogRecord.
Bases: ABC
LoggerProvider is the entry point of the API. It provides access to Logger instances.
Returns a Logger for use by the given instrumentation library.
For any two calls with identical parameters, it is undefined whether the same or different Logger instances are returned.
This function may return different Logger types (e.g. a no-op logger vs. a functional logger).
name (str
) –
The name of the instrumenting module, package or class. This should not be the name of the module, package or class that is instrumented but the name of the code doing the instrumentation. E.g., instead of "requests"
, use "opentelemetry.instrumentation.requests"
.
For log sources which define a logger name (e.g. logging.Logger.name) the Logger Name should be recorded as the instrumentation scope name.
version (Optional
[str
]) – Optional. The version string of the instrumenting library. Usually this should be the same as importlib.metadata.version(instrumenting_library_name)
.
schema_url (Optional
[str
]) – Optional. Specifies the Schema URL of the emitted telemetry.
attributes (Optional
[Mapping
[str
, Union
[str
, bool
, int
, float
, bytes
, Sequence
[AnyValue], Mapping
[str
, AnyValue], None
]]]) – Optional. Specifies the instrumentation scope attributes to associate with emitted telemetry.
Bases: ABC
A LogRecord instance represents an event being logged.
LogRecord instances are created and emitted via Logger every time something is logged. They contain all the information pertinent to the event being logged.
Bases: Logger
The default Logger used when no Logger implementation is available.
All operations are no-op.
Bases: LoggerProvider
The default LoggerProvider used when no LoggerProvider implementation is available.
Returns a NoOpLogger.
Returns a Logger for use within a python process.
This function is a convenience wrapper for opentelemetry.sdk._logs.LoggerProvider.get_logger.
If logger_provider param is omitted the current configured one is used.
Gets the current global LoggerProvider
object.
Sets the current global LoggerProvider
object.
This can only be done once, a warning will be logged if any further attempt is made.
Bases: Enum
Numerical value of severity.
Smaller numerical values correspond to less severe events (such as debug events), larger numerical values correspond to more severe events (such as errors and critical events).
See the Log Data Model spec for more info and how to map the severity from source format to OTLP Model.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4