-
Notifications
You must be signed in to change notification settings - Fork 932
feat(sdk-logs): Add loggerConfigurator
#5991
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?
feat(sdk-logs): Add loggerConfigurator
#5991
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5991 +/- ##
==========================================
+ Coverage 95.22% 95.23% +0.01%
==========================================
Files 311 312 +1
Lines 8603 8655 +52
Branches 1801 1817 +16
==========================================
+ Hits 8192 8243 +51
- Misses 411 412 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JacksonWeber - please also mark all features that are marked as in-development in the spec as @experimental
in the TSdoc. This way we can avoid blocking https://github.com/open-telemetry/opentelemetry-js/milestone/19
Experimental features have been marked as such. Thanks for the feedback! |
Which problem is this PR solving?
Updates the logs SDK to support the logger configurator, minimum severity filtering and trace-based log filtering.
Short description of the changes
This pull request introduces a configurable logger filtering mechanism to the OpenTelemetry SDK logs package, allowing log records to be filtered based on severity and trace sampling, and enabling per-logger configuration through a new pattern-based API. The core changes add a
LoggerConfigurator
interface, implement pattern-based configuration, and apply these configurations during log record emission. This improves flexibility and compliance with logging specifications.Logger configuration and filtering enhancements
LoggerConfig
andLoggerConfigurator
types, allowing logger behavior (such as minimum severity and trace-based filtering) to be configured per logger. These are now part ofLoggerProviderConfig
and are used throughout the logger lifecycle. [1] [2]createLoggerConfigurator
utility inLoggerConfigurators.ts
to support pattern-based logger configuration, including wildcard matching for logger names.LoggerProviderSharedState
to cache and retrieve per-logger configuration using the new configurator function, ensuring efficient and correct config application. [1] [2]Log record filtering logic
Logger.emit
method to apply minimum severity and trace-based filtering according to the resolved logger configuration, dropping log records that do not meet the criteria. [1] [2]API and test updates
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
test-minimum-severity.js
test-trace-based-sampling.js
Checklist: