-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 Tracing: instrument logs and ensure traces are propagated through asyncio.Queues
#6857
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
bisgaard-itis
merged 18 commits into
ITISFoundation:master
from
bisgaard-itis:6835-tracing-to-logs-prometheus-and-httpx
Dec 6, 2024
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ddf261b
add logging instrumentation
bisgaard-itis 25f90b6
add logging instrumentation dependency
bisgaard-itis 1720a3d
first attempt to properly propagate tracing through asyncio.Queue
bisgaard-itis 49a5ee2
start wrapping trace context handling
bisgaard-itis 8121506
propagate tracing context through asyncio.Queue
bisgaard-itis f98422d
add utility for instrument logging
bisgaard-itis 3b31ad9
instrument logging directly when logging is setup
bisgaard-itis 18b2091
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis 752fb4a
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis 2e16b38
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis d9db140
@sanderegg fix relative imports
bisgaard-itis d0487f0
use context manager @pcrespov @sanderegg
bisgaard-itis 87070e4
@pcrespov format log format
bisgaard-itis ae68ed9
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis ea638c7
@matusdrobuliak66 keep 'log_' prefix
bisgaard-itis d1b9380
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis 8f6b466
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis c4aa535
Merge branch 'master' into 6835-tracing-to-logs-prometheus-and-httpx
bisgaard-itis 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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| from contextlib import contextmanager | ||
| from typing import TypeAlias | ||
|
|
||
| from opentelemetry import context as otcontext | ||
| from opentelemetry import trace | ||
| from opentelemetry.instrumentation.logging import LoggingInstrumentor | ||
| from settings_library.tracing import TracingSettings | ||
|
|
||
| TracingContext: TypeAlias = otcontext.Context | None | ||
|
|
||
|
|
||
| def _is_tracing() -> bool: | ||
| return trace.get_current_span().is_recording() | ||
|
|
||
|
|
||
| def get_context() -> TracingContext: | ||
| if not _is_tracing(): | ||
| return None | ||
| return otcontext.get_current() | ||
|
|
||
|
|
||
| @contextmanager | ||
| def use_tracing_context(context: TracingContext): | ||
| if context is not None: | ||
| otcontext.attach(context) | ||
| try: | ||
| yield | ||
| finally: | ||
| if context is not None: | ||
| otcontext.detach(context) | ||
|
|
||
|
|
||
bisgaard-itis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def setup_log_tracing(tracing_settings: TracingSettings): | ||
| _ = tracing_settings | ||
bisgaard-itis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| LoggingInstrumentor().instrument(set_logging_format=False) | ||
bisgaard-itis 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
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
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
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
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
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.
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.