Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed May 24, 2024
1 parent f8ea918 commit 0f73fad
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions ext/distributed_tracing_headers.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,24 +397,19 @@ ddtrace_distributed_tracing_result ddtrace_read_distributed_tracing_ids(ddtrace_
result.tracestate_unknown_dd_keys = new_result.tracestate_unknown_dd_keys;
zend_hash_init(&new_result.tracestate_unknown_dd_keys, 0, NULL, NULL, 0);
if (result.parent_id != new_result.parent_id) {
result.parent_id = new_result.parent_id;
// set last datadog span_id tag
zval *lp_id = zend_hash_str_find(&new_result.propagated_tags, ZEND_STRL("_dd.parent_id"));
zval *default_lp_id;
ZVAL_STRING(default_lp_id, "0000000000000000");
if (lp_id && Z_TYPE_P(lp_id) == IS_STRING && strcmp(Z_STRVAL_P(lp_id), Z_STRVAL_P(default_lp_id)) != 0) {
if (lp_id && !zend_string_equals_literal(Z_STR_P(lp_id), "0000000000000000")) {
Z_TRY_ADDREF_P(lp_id);
zend_hash_str_update(&result.propagated_tags, ZEND_STRL("_dd.parent_id"), lp_id);
} else {
ddtrace_distributed_tracing_result result_dd = ddtrace_read_distributed_tracing_ids_datadog(read_header, data);
if (result_dd.parent_id != 0) {
char parent_id_hex[17];
sprintf(parent_id_hex, "%016lx", result_dd.parent_id);
zval parent_id_zval;
ZVAL_STRING(&parent_id_zval, parent_id_hex);
zend_hash_str_update(&result.propagated_tags, ZEND_STRL("_dd.parent_id"), &parent_id_zval);
}
} else if (result.parent_id != 0) {
zval parent_id_zval;
ZVAL_STR(&parent_id_zval, zend_string_alloc(16, 0));
sprintf(Z_STRVAL_P(&parent_id_zval), "%016" PRIu64, result.parent_id);
zend_hash_str_update(&result.propagated_tags, ZEND_STRL("_dd.parent_id"), &parent_id_zval);
}
}
result.parent_id = new_result.parent_id;
}
}
}

Expand Down

0 comments on commit 0f73fad

Please sign in to comment.