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

[PROF-6691] Send span id in profiles as number and not string #2476

Merged
merged 1 commit into from
Dec 7, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@ struct trace_identifiers {

bool valid;
ddog_CharSlice local_root_span_id;
ddog_CharSlice span_id;
uint64_t span_id;
char local_root_span_id_buffer[MAXIMUM_LENGTH_64_BIT_IDENTIFIER];
char span_id_buffer[MAXIMUM_LENGTH_64_BIT_IDENTIFIER];
VALUE trace_endpoint;
};

Expand Down Expand Up @@ -583,7 +582,7 @@ static void trigger_sample_for_thread(

if (trace_identifiers_result.valid) {
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("local root span id"), .str = trace_identifiers_result.local_root_span_id};
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("span id"), .str = trace_identifiers_result.span_id};
labels[label_pos++] = (ddog_Label) {.key = DDOG_CHARSLICE_C("span id"), .num = trace_identifiers_result.span_id};

if (trace_identifiers_result.trace_endpoint != Qnil) {
// The endpoint gets recorded in a different way because it is mutable in the tracer and can change during a
Expand Down Expand Up @@ -870,19 +869,13 @@ static void trace_identifiers_for(struct cpu_and_wall_time_collector_state *stat
if (numeric_local_root_span_id == Qnil || numeric_span_id == Qnil) return;

unsigned long long local_root_span_id = NUM2ULL(numeric_local_root_span_id);
unsigned long long span_id = NUM2ULL(numeric_span_id);

snprintf(trace_identifiers_result->local_root_span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", local_root_span_id);
snprintf(trace_identifiers_result->span_id_buffer, MAXIMUM_LENGTH_64_BIT_IDENTIFIER, "%llu", span_id);

trace_identifiers_result->local_root_span_id = (ddog_CharSlice) {
.ptr = trace_identifiers_result->local_root_span_id_buffer,
.len = strlen(trace_identifiers_result->local_root_span_id_buffer)
};
trace_identifiers_result->span_id = (ddog_CharSlice) {
.ptr = trace_identifiers_result->span_id_buffer,
.len = strlen(trace_identifiers_result->span_id_buffer)
};
trace_identifiers_result->span_id = NUM2ULL(numeric_span_id);

trace_identifiers_result->valid = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def stats

expect(t1_sample.fetch(:labels)).to include(
:'local root span id' => @t1_local_root_span_id.to_s,
:'span id' => @t1_span_id.to_s,
:'span id' => @t1_span_id.to_i,
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/profiling/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def samples_from_pprof(pprof_data)
labels: sample.label.map do |it|
[
string_table[it.key].to_sym,
it.num == 0 ? string_table[it.str] : raise('Unexpected: label encoded as number instead of string'),
it.num == 0 ? string_table[it.str] : it.num,
]
end.to_h,
}
Expand Down