From 6aa19c74205ae87ad257d82cfa00259a9f851109 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 12 Feb 2025 20:05:08 +0100 Subject: [PATCH] Add track_error: false on ignored caught exceptions (#3074) Signed-off-by: Bob Weinand --- ext/serializer.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ext/serializer.c b/ext/serializer.c index 3cf9175f08..463756ee99 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1280,6 +1280,22 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv ddtrace_hash_find_ptr(Z_ARR_P(meta), ZEND_STRL("error.type")); if (error && !ignore_error) { add_assoc_long(el, "error", 1); + + if (Z_TYPE(span->property_exception) == IS_OBJECT) { + ddtrace_span_data *parent = span; + while (parent->parent) { + parent = SPANDATA(parent->parent); + if (Z_TYPE(parent->property_exception) == IS_OBJECT && Z_OBJ(parent->property_exception) == Z_OBJ(span->property_exception)) { + zval *zv; + if ((zv = zend_hash_str_find(ddtrace_property_array(&parent->property_meta), ZEND_STRL("error.ignored"))) && zval_is_true(zv)) { + add_assoc_string(el, "track_error", "false"); + break; + } + } else { + break; + } + } + } } if (span->root->trace_id.high && is_root_span) {