Skip to content

Commit 67e08df

Browse files
committed
Move process tags assign
Signed-off-by: Bob Weinand <[email protected]>
1 parent de48e39 commit 67e08df

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

ext/serializer.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <SAPI.h>
2323
#include <exceptions/exceptions.h>
2424
#include <json/json.h>
25+
26+
#include "process_tags.h"
2527
#ifndef _WIN32
2628
#include <stdatomic.h>
2729
#else
@@ -1544,6 +1546,7 @@ void transfer_metrics_data(ddog_SpanBytes *source, ddog_SpanBytes *destination,
15441546
}
15451547

15461548
ddog_SpanBytes *ddtrace_serialize_span_to_rust_span(ddtrace_span_data *span, ddog_TraceBytes *trace) {
1549+
bool is_first_span = ddog_get_trace_size(trace) == 0;
15471550
ddog_SpanBytes *rust_span = ddog_trace_new_span(trace);
15481551

15491552
bool is_root_span = span->std.ce == ddtrace_ce_root_span_data;
@@ -1608,6 +1611,13 @@ ddog_SpanBytes *ddtrace_serialize_span_to_rust_span(ddtrace_span_data *span, ddo
16081611
zend_hash_str_del(metrics, ZEND_STRL("http.status_code"));
16091612
}
16101613

1614+
if (is_first_span) {
1615+
zend_string *process_tags = ddtrace_process_tags_get_serialized();
1616+
if (process_tags) {
1617+
ddog_add_str_span_meta_zstr(rust_span, "_dd.process_tags", process_tags);
1618+
}
1619+
}
1620+
16111621
// SpanData::$name defaults to fully qualified called name (set at span close)
16121622
zval *operation_name = zend_hash_str_find(meta, ZEND_STRL("operation.name"));
16131623
zval *prop_name = &span->property_name;

ext/span.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "standalone_limiter.h"
2626
#include "code_origins.h"
2727
#include "endpoint_guessing.h"
28-
#include "process_tags.h"
2928

3029
#define USE_REALTIME_CLOCK 0
3130
#define USE_MONOTONIC_CLOCK 1
@@ -1114,14 +1113,7 @@ void ddtrace_serialize_closed_spans(ddog_TracesBytes *traces, bool fast_shutdown
11141113
do {
11151114
ddtrace_span_data *tmp = span;
11161115
span = tmp->next;
1117-
bool is_first_span = (ddog_get_trace_size(trace) == 0);
1118-
ddog_SpanBytes *rust_span = ddtrace_serialize_span_to_rust_span(tmp, trace);
1119-
if (is_first_span) {
1120-
zend_string *process_tags = ddtrace_process_tags_get_serialized();
1121-
if (process_tags) {
1122-
ddog_add_str_span_meta_zstr(rust_span, "_dd.process_tags", process_tags);
1123-
}
1124-
}
1116+
ddtrace_serialize_span_to_rust_span(tmp, trace);
11251117
#if PHP_VERSION_ID < 70400
11261118
// remove the artificially increased RC while closing again
11271119
GC_SET_REFCOUNT(&tmp->std, GC_REFCOUNT(&tmp->std) - DD_RC_CLOSED_MARKER);

0 commit comments

Comments
 (0)