-
Notifications
You must be signed in to change notification settings - Fork 735
Open
Labels
loggingpriority:p1Issues that should be resolved in the upcoming release (except for zero-day hotfix release)Issues that should be resolved in the upcoming release (except for zero-day hotfix release)
Description
Let's assume I'm building a logging bridge for one of many python non-standard loggers (e.g. structlog).
I should be able to create a library using logging (bridge) API alone.
So I should write a code like:
from opentelemetry._logs import get_logger_provider
from opentelemetry._logs import LogRecord as APILogRecord
logger = get_logger_provider().get_logger(__name__)
logger.emit(APILogRecord(body="Hello, World!", attributes={"foo": "bar"}))
It'd fail with
opentelemetry\sdk\_logs\_internal\export\__init__.py", line 97, in <lambda>
formatter: Callable[[LogRecord], str] = lambda record: record.to_json()
^^^^^^^^^^^^^^
AttributeError: 'LogRecord' object has no attribute 'to_json'
Probably related to #3552
The recommendation
- Make it possible to (properly) use Logs API alone without touching SDK types
- Add example and tests that use vanilla logs API
(with note that it's for logging bridges, not end users)(update - this is not necessary anymore, logs API is now for everyone to use) - Call API and SDK log records differently to minimize confusion. E.g. SDK one could be
ReadWriteLogRecord
and should probably replaceLogData
(see Logs SDK: consider removingLogData
and extending SDKLogRecord
to have instrumentation scope #4313) - Consider using a pattern similar to tracing when users don't need to instantiate a new span. Instead they could call
logger.emit(....)
with parameters and the SDK implementation of logger will create SDK implementation ofLogRecord
Part of open-telemetry/community#1751
aabmass, luccabb, jhodnett2, lzchen, vytas7 and 1 more
Metadata
Metadata
Assignees
Labels
loggingpriority:p1Issues that should be resolved in the upcoming release (except for zero-day hotfix release)Issues that should be resolved in the upcoming release (except for zero-day hotfix release)
Type
Projects
Status
In Progress