-
Notifications
You must be signed in to change notification settings - Fork 921
Move logger handlers to opentelemetry-instrumentation-logging #4210
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
Merged
xrmx
merged 25 commits into
open-telemetry:main
from
xrmx:move-logger-handlers-to-autoinstrumentation
Mar 3, 2026
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
334c31f
Move logging integrations into auto-instrumentation
xrmx ea08d8d
opentelemetry-instrumentation-logging: move the sdk logging handler here
xrmx d6e887d
Add header and future annotations import
xrmx b610fd1
Rename entry point group to opentelemetry_logging_integrations
xrmx 842449e
Consider setting up the LoggingHandler as a normal instrumentation
xrmx 575154d
Fix typo
xrmx 5e8b347
Add missing import
xrmx 2375a02
Copy handler tests from core
xrmx 11a1463
More work towards green tests
xrmx 9696c9c
Cleanup properly after loggingHandler tests
xrmx 2244124
Quite hard to expect a mock to setup the handler
xrmx 228d2b5
Call removehandler also on local loggers
xrmx 7bc424b
Fix wrong noop test
xrmx 5cbe3a3
Move to our own env var for controlling autoinstrumentation
xrmx 5b3dc1d
Copy handler benchmark from sdk
xrmx 37f49b9
Document the new environment variables
xrmx 610b92f
Add changelog
xrmx d289951
Please pylint
xrmx 7563d7c
Added warning about coexistence with sdk code
xrmx e97c49d
Reword a bit
xrmx 6cd17f7
Assert that the LoggingHandler has not been setup in uninstrumented test
xrmx 223f3a3
Add manual handling of auto instrumentation and code attributes logging
xrmx bbefd78
Update instrumentation/opentelemetry-instrumentation-logging/src/open…
xrmx 576c451
Apply suggestions from code review
xrmx 5f95328
Apply more Pablo feedback
xrmx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
instrumentation/opentelemetry-instrumentation-logging/benchmark-requirements.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| pytest-benchmark==4.0.0 |
53 changes: 53 additions & 0 deletions
53
...tation/opentelemetry-instrumentation-logging/benchmarks/test_benchmark_logging_handler.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Copyright The OpenTelemetry Authors | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import logging | ||
|
|
||
| import pytest | ||
|
|
||
| from opentelemetry.instrumentation.logging.handler import LoggingHandler | ||
| from opentelemetry.sdk._logs import LoggerProvider | ||
| from opentelemetry.sdk._logs.export import ( | ||
| InMemoryLogRecordExporter, | ||
| SimpleLogRecordProcessor, | ||
| ) | ||
|
|
||
|
|
||
| def _set_up_logging_handler(level): | ||
| logger_provider = LoggerProvider() | ||
| exporter = InMemoryLogRecordExporter() | ||
| processor = SimpleLogRecordProcessor(exporter=exporter) | ||
| logger_provider.add_log_record_processor(processor) | ||
| handler = LoggingHandler(level=level, logger_provider=logger_provider) | ||
| return handler | ||
|
|
||
|
|
||
| def _create_logger(handler, name): | ||
| logger = logging.getLogger(name) | ||
| logger.addHandler(handler) | ||
| return logger | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("num_loggers", [1, 10, 100, 1000]) | ||
| def test_simple_get_logger_different_names(benchmark, num_loggers): | ||
| handler = _set_up_logging_handler(level=logging.DEBUG) | ||
| loggers = [ | ||
| _create_logger(handler, str(f"logger_{i}")) for i in range(num_loggers) | ||
| ] | ||
|
|
||
| def benchmark_get_logger(): | ||
| for index in range(1000): | ||
| loggers[index % num_loggers].warning("test message") | ||
|
|
||
| benchmark(benchmark_get_logger) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tammy-baylis-swi marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.