|
8 | 8 |
|
9 | 9 | from ddtrace._trace._span_link import SpanLink |
10 | 10 | from ddtrace._trace._span_link import SpanLinkKind |
| 11 | +from ddtrace._trace.telemetry import record_span_pointer_calculation_issue |
11 | 12 | from ddtrace.internal.logger import get_logger |
12 | 13 |
|
13 | 14 |
|
@@ -67,20 +68,28 @@ def __post_init__(self): |
67 | 68 | def _standard_hashing_function(*elements: bytes) -> str: |
68 | 69 | try: |
69 | 70 | if not elements: |
70 | | - raise ValueError("elements must not be empty") |
| 71 | + return _standard_hashing_function_failure("elements must not be empty") |
71 | 72 |
|
72 | 73 | # Please see the tests for more details about this logic. |
73 | 74 | return sha256(b"|".join(elements)).hexdigest()[:32] |
74 | 75 |
|
75 | 76 | except Exception as e: |
76 | | - log.warning( |
77 | | - "failed to generate standard hash for span pointer: %s", |
78 | | - str(e), |
79 | | - ) |
80 | | - return _add_random_suffix( |
81 | | - prefix=_STANDARD_HASHING_FUNCTION_FAILURE_PREFIX, |
82 | | - minimum_length=32, |
83 | | - ) |
| 77 | + return _standard_hashing_function_failure(str(e)) |
| 78 | + |
| 79 | + |
| 80 | +def _standard_hashing_function_failure(reason: str) -> str: |
| 81 | + log.debug( |
| 82 | + "failed to generate standard hash for span pointer: %s", |
| 83 | + reason, |
| 84 | + ) |
| 85 | + record_span_pointer_calculation_issue( |
| 86 | + context="standard_hashing_function", |
| 87 | + ) |
| 88 | + |
| 89 | + return _add_random_suffix( |
| 90 | + prefix=_STANDARD_HASHING_FUNCTION_FAILURE_PREFIX, |
| 91 | + minimum_length=32, |
| 92 | + ) |
84 | 93 |
|
85 | 94 |
|
86 | 95 | def _add_random_suffix(*, prefix: str, minimum_length: int) -> str: |
|
0 commit comments