-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add request settings: request_timeout and trace_id
- Loading branch information
Roman Tretiak
committed
Oct 31, 2024
1 parent
3ff29ac
commit 06f35f9
Showing
5 changed files
with
157 additions
and
55 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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import importlib.util | ||
from typing import Optional | ||
|
||
|
||
def maybe_get_current_trace_id() -> Optional[str]: | ||
# Check if OpenTelemetry is available | ||
if importlib.util.find_spec("opentelemetry"): | ||
from opentelemetry import trace | ||
|
||
current_span = trace.get_current_span() | ||
|
||
if current_span.get_span_context().is_valid: | ||
return format(current_span.get_span_context().trace_id, "032x") | ||
|
||
# Return None if OpenTelemetry is not available or trace ID is invalid | ||
return None |
Oops, something went wrong.