-
Notifications
You must be signed in to change notification settings - Fork 799
Improved logging instrumentor #2718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…-logging # Conflicts: # CHANGELOG.md
.../opentelemetry-instrumentation-logging/src/opentelemetry/instrumentation/logging/__init__.py
Outdated
Show resolved
Hide resolved
|
Would you be able to add a more informative description to the change that this pr pertains? A sample showing it in action and the expected output would be great as well. |
Updated PR description |
# Conflicts: # CHANGELOG.md # instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py
@lzchen, is it enough or should I explain something else? Feel free to comment in code |
Description
Logging fields customization
Having connected this tool, I was surprised that the names of the logging fields were hard-coded. The naming convention for such fields in my company is different, so I couldn't use this module as it is. I decided that I could easily inherit and replace the fields with my own, but when I opened the code, I was surprised that all the action of the instrumentator is in one function and it will not be possible to change the behavior with a little modification.
As a result, I decided to add the ability to specify my field names to the instrumentator, while not changing the standard behavior (for those who already use this instrumentator as is).
As I added in the documentation, it is now possible to specify any convenient names for the fields:
Performance
LogRecordFactory without
log_hookNow, for cases when a
log_hookis not passed to the instrumentator, a factory is passed to logging, which does not check the possibility of usinglog_hookevery log record.Single
service_namecallNow we don't calculate
service_nameon log record, get it once - on instrumentation.Typehints
Added type hints for every function signature and class variable
Code readability
Code style before change was like this:

Now it's used early log record return for every case, when you can't get trace or span:

Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.