forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start wrapping trace context handling
- Loading branch information
1 parent
1720a3d
commit 49a5ee2
Showing
2 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,31 @@ | ||
from typing import Final | ||
|
||
from opentelemetry import context as otcontext | ||
from opentelemetry.instrumentation.logging import LoggingInstrumentor | ||
from settings_library.tracing import TracingSettings | ||
|
||
_tracing_settings: Final[TracingSettings] = TracingSettings.create_from_envs() | ||
|
||
|
||
LoggingInstrumentor().instrument(set_logging_format=False) | ||
|
||
|
||
def _is_tracing() -> bool: | ||
# TODO get this value by inspecting settings | ||
return True | ||
|
||
|
||
def get_current() -> otcontext.Context | None: | ||
if not _is_tracing(): | ||
return None | ||
return otcontext.get_current() | ||
|
||
|
||
def attach(context: otcontext.Context | None) -> None: | ||
if context is not None: | ||
otcontext.attach(context) | ||
|
||
|
||
def detach(context: otcontext.Context | None) -> None: | ||
if context is not None: | ||
otcontext.detach(context) |