Download apps/core/infrastructure/tracing.py from jun2024/fc: direct link, hf CLI and curl.
- Browser
- Download file 638 Bytes
-
https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/core/infrastructure/tracing.py
- Command line
-
hf download hf://spaces/jun2024/fc/apps/core/infrastructure/tracing.py
-
curl -L -o tracing.py https://huggingface.co/spaces/jun2024/fc/resolve/main/apps/core/infrastructure/tracing.py
638 Bytes
| """Module for tracing.""" | |
| from __future__ import annotations | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| def get_current_trace_ids() -> tuple[str | None, str | None]: | |
| try: | |
| from opentelemetry import trace | |
| span = trace.get_current_span() | |
| context = span.get_span_context() | |
| if context is None or not context.is_valid: | |
| return None, None | |
| return f"{context.trace_id:032x}", f"{context.span_id:016x}" | |
| except ModuleNotFoundError: | |
| return None, None | |
| except (AttributeError, ValueError): | |
| logger.warning("获取 trace ID 失败") | |
| return None, None | |