Skip to content

Commit

Permalink
Fix error adding twice _dd.p.appsec
Browse files Browse the repository at this point in the history
  • Loading branch information
estringana committed Nov 13, 2024
1 parent 297a13f commit 886121a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions appsec/src/extension/tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,18 @@ void dd_tags_add_tags(
zval true_zv;
ZVAL_STR_COPY(&true_zv, _true_zstr);

// tag _dd.p.appsec
bool res = dd_trace_span_add_tag(span, _dd_tag_p_appsec_zstr, &true_zv);
if (!res) {
mlog(dd_log_info, "Failed adding tag " DD_TAG_P_APPSEC " to root span");
return;
zval *meta = dd_trace_span_get_meta(span);
if (meta &&
zend_hash_find(Z_ARRVAL_P(meta), _dd_tag_p_appsec_zstr) == NULL) {
// tag _dd.p.appsec
if (!dd_trace_span_add_tag(span, _dd_tag_p_appsec_zstr, &true_zv)) {
mlog(dd_log_info,
"Failed adding tag " DD_TAG_P_APPSEC " to root span");
return;
}
} else {
mlog(dd_log_info,
"Skipping adding " DD_TAG_P_APPSEC " as it was already added");
}

zval _1_zval;
Expand All @@ -370,7 +377,7 @@ void dd_tags_add_tags(
ZVAL_STR(&tag_value_zv, tag_value);

// tag _dd.appsec.json
res = dd_trace_span_add_tag(span, _dd_tag_data_zstr, &tag_value_zv);
bool res = dd_trace_span_add_tag(span, _dd_tag_data_zstr, &tag_value_zv);
if (!res) {
mlog(dd_log_info, "Failed adding tag " DD_TAG_DATA " to root span");
return;
Expand Down

0 comments on commit 886121a

Please sign in to comment.