Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: profiling: properly format trace context strings #372

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased
- Upgraded Otel dependencies to 1.21.0 / 0.42b0
- Fix trace and span id formatting for profiling
[#372](https://github.com/signalfx/splunk-otel-python/pull/372)

## 1.15.0 - 2023-11-15

Expand Down
4 changes: 2 additions & 2 deletions splunk_otel/profiling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ def get_location(frame):

trace_id_label = profile_pb2.Label()
trace_id_label.key = trace_id_key
trace_id_label.str = str_table.index(f"{trace_id:#016x}")
trace_id_label.str = str_table.index(f"{trace_id:016x}")
labels.append(trace_id_label)

span_id_label = profile_pb2.Label()
span_id_label.key = span_id_key
span_id_label.str = str_table.index(f"{span_id:#08x}")
span_id_label.str = str_table.index(f"{span_id:08x}")
labels.append(span_id_label)

sample = profile_pb2.Sample()
Expand Down
10 changes: 6 additions & 4 deletions tests/unit/test_profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ def _assert_log_record(self, log_record):
self.assertGreater(len(file_name), 0)

if function_name == "do_work":
span_id = int(strings[find_label(sample, "span_id", strings).str], 16)
trace_id = int(
strings[find_label(sample, "trace_id", strings).str], 16
)
span_id_str = strings[find_label(sample, "span_id", strings).str]
trace_id_str = strings[find_label(sample, "trace_id", strings).str]
self.assertFalse(span_id_str.startswith("0x"))
self.assertFalse(trace_id_str.startswith("0x"))
span_id = int(span_id_str, 16)
trace_id = int(trace_id_str, 16)
self.assertEqual(span_id, self.span_id)
self.assertEqual(trace_id, self.trace_id)
return True
Expand Down
Loading