Skip to content

Commit 2c0384f

Browse files
fix(span_links): revert regression in v04 encoding [backport 2.5] (#8101)
Backport 0bc99b1 from #8097 to 2.5. Partially Reverts: #8054 This regression is unreleased so a release note is not required [if we can get this fix on the 2.5, 2.4, and 2.3 release lines fast enough] ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [x] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [x] This PR doesn't touch any of that. Co-authored-by: Munir Abdinur <[email protected]>
1 parent 388520f commit 2c0384f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ddtrace/internal/_encoding.pyx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,10 @@ cdef class MsgpackEncoderV03(MsgpackEncoderBase):
571571
# SpanLink.to_dict() returns all serializable span link fields
572572
d = link.to_dict()
573573
# Encode 128 bit trace ids usings two 64bit integers
574-
d["trace_id_high"] = d["trace_id"][:16]
575-
d["trace_id"] = d["trace_id"][16:]
574+
d["trace_id_high"] = int(d["trace_id"][:16], 16)
575+
d["trace_id"] = int(d["trace_id"][16:], 16)
576+
# span id should be uint64 in v0.4 (it is hex in v0.5)
577+
d["span_id"] = int(d["span_id"], 16)
576578

577579
ret = msgpack_pack_map(&self.pk, len(d))
578580
if ret != 0:

tests/tracer/test_encoders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ def test_span_link_v04_encoding():
463463
assert b"span_links" in decoded_span
464464
assert decoded_span[b"span_links"] == [
465465
{
466-
b"trace_id": b"00000000000001c8",
467-
b"span_id": b"0000000000000002",
466+
b"trace_id": 456,
467+
b"span_id": 2,
468468
b"attributes": {
469469
b"moon": b"ears",
470470
b"link.name": b"link_name",
@@ -474,7 +474,7 @@ def test_span_link_v04_encoding():
474474
b"dropped_attributes_count": 1,
475475
b"tracestate": b"congo=t61rcWkgMzE",
476476
b"flags": 1,
477-
b"trace_id_high": b"000000000000007b",
477+
b"trace_id_high": 123,
478478
}
479479
]
480480

0 commit comments

Comments
 (0)