From f0c4bf26d4635a89cd107be52c2c978859cfaa4c Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Fri, 7 Feb 2025 11:23:19 +0100 Subject: [PATCH 01/46] Base Implementation --- ext/configuration.h | 1 + ext/ddtrace.c | 10 +- ext/handlers_curl.c | 2 +- ext/handlers_curl_php7.c | 2 +- ext/serializer.c | 49 +++++--- ext/serializer.h | 3 +- ext/span.c | 129 ++++++++++++++++--- ext/span.h | 9 +- tests/ext/inferred_proxy/basic_test.phpt | 150 +++++++++++++++++++++++ 9 files changed, 316 insertions(+), 39 deletions(-) create mode 100644 tests/ext/inferred_proxy/basic_test.phpt diff --git a/ext/configuration.h b/ext/configuration.h index 970b97f212..55ba9847b5 100644 --- a/ext/configuration.h +++ b/ext/configuration.h @@ -238,6 +238,7 @@ enum ddtrace_sampling_rules_format { CONFIG(SET, DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS, "", .ini_change = zai_config_system_ini_change) \ CONFIG(BOOL, DD_EXPERIMENTAL_APPSEC_STANDALONE_ENABLED, "false") \ CONFIG(SET, DD_DYNAMIC_INSTRUMENTATION_REDACTED_TYPES, "", .ini_change = zai_config_system_ini_change) \ + CONFIG(BOOL, DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED, "false") \ DD_INTEGRATIONS #ifndef _WIN32 diff --git a/ext/ddtrace.c b/ext/ddtrace.c index e256d1aeae..37e224e8f7 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -1612,6 +1612,10 @@ static void dd_initialize_request(void) { ddtrace_distributed_tracing_result distributed_result = ddtrace_read_distributed_tracing_ids(ddtrace_read_zai_header, NULL); ddtrace_apply_distributed_tracing_result(&distributed_result, NULL); + if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + ddtrace_infer_proxy_services(); + } + if (get_DD_TRACE_GENERATE_ROOT_SPAN()) { ddtrace_push_root_span(); } @@ -2693,6 +2697,10 @@ PHP_FUNCTION(DDTrace_root_span) { } dd_ensure_root_span(); ddtrace_root_span_data *span = DDTRACE_G(active_stack)->root_span; + if (span && span->is_inferred_span) { + span = span->child_root; + } + if (span) { RETURN_OBJ_COPY(&span->std); } @@ -2709,7 +2717,7 @@ static inline void dd_start_span(INTERNAL_FUNCTION_PARAMETERS) { ddtrace_span_data *span; if (get_DD_TRACE_ENABLED()) { - span = ddtrace_open_span(DDTRACE_USER_SPAN); + span = ddtrace_open_span(DDTRACE_USER_SPAN, false); } else { span = ddtrace_init_dummy_span(); } diff --git a/ext/handlers_curl.c b/ext/handlers_curl.c index 366011f905..716847cea7 100644 --- a/ext/handlers_curl.c +++ b/ext/handlers_curl.c @@ -136,7 +136,7 @@ static void dd_multi_inject_headers(zend_object *mh) { zend_object *ch; ZEND_HASH_FOREACH_PTR(handles, ch) { if (DDTRACE_G(curl_multi_injecting_spans) && Z_TYPE(DDTRACE_G(curl_multi_injecting_spans)->val) == IS_ARRAY) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); dd_inject_distributed_tracing_headers(ch); ddtrace_close_span(span); span->duration = 1; diff --git a/ext/handlers_curl_php7.c b/ext/handlers_curl_php7.c index bb2d9dcc71..8af6a433fc 100644 --- a/ext/handlers_curl_php7.c +++ b/ext/handlers_curl_php7.c @@ -159,7 +159,7 @@ static int dd_inject_distributed_tracing_headers(zval *ch) { static int dd_inject_distributed_tracing_headers_multi(zval *ch) { if (DDTRACE_G(curl_multi_injecting_spans) && Z_TYPE(DDTRACE_G(curl_multi_injecting_spans)->val) == IS_ARRAY) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); int ret = dd_inject_distributed_tracing_headers(ch); ddtrace_close_span(span); span->duration = 1; diff --git a/ext/serializer.c b/ext/serializer.c index 3cf9175f08..0fdbdfa9e1 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -737,7 +737,25 @@ zend_string *ddtrace_active_service_name(void) { return ddtrace_default_service_name(); } -void ddtrace_set_root_span_properties(ddtrace_root_span_data *span) { +void dd_set_entrypoint_root_span_props_from_globals(ddtrace_root_span_data *span) { + struct superglob_equiv data = {0}; + { + zval *_server_zv = &PG(http_globals)[TRACK_VARS_SERVER]; + if (Z_TYPE_P(_server_zv) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) { + data.server = Z_ARRVAL_P(_server_zv); + } + } + { + zval *_post_zv = &PG(http_globals)[TRACK_VARS_POST]; + if (Z_TYPE_P(_post_zv) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_POST"))) { + data.post = Z_ARRVAL_P(_post_zv); + } + } + + dd_set_entrypoint_root_span_props(&data, span); +} + +void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_inferred) { ddtrace_update_root_id_properties(span); span->sampling_rule.rule = INT32_MAX; @@ -759,22 +777,8 @@ void ddtrace_set_root_span_properties(ddtrace_root_span_data *span) { ZVAL_STR(&zv, encoded_id); zend_hash_str_add_new(meta, ZEND_STRL("runtime-id"), &zv); - if (ddtrace_span_is_entrypoint_root(&span->span)) { - struct superglob_equiv data = {0}; - { - zval *_server_zv = &PG(http_globals)[TRACK_VARS_SERVER]; - if (Z_TYPE_P(_server_zv) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_SERVER"))) { - data.server = Z_ARRVAL_P(_server_zv); - } - } - { - zval *_post_zv = &PG(http_globals)[TRACK_VARS_POST]; - if (Z_TYPE_P(_post_zv) == IS_ARRAY || zend_is_auto_global_str(ZEND_STRL("_POST"))) { - data.post = Z_ARRVAL_P(_post_zv); - } - } - - dd_set_entrypoint_root_span_props(&data, span); + if (ddtrace_span_is_entrypoint_root(&span->span) && !is_inferred) { + dd_set_entrypoint_root_span_props_from_globals(span); } if (get_DD_TRACE_REPORT_HOSTNAME()) { @@ -1180,6 +1184,17 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv exception_type = Z_PROP_FLAG_P(exception_zv) == 2 ? DD_EXCEPTION_CAUGHT : DD_EXCEPTION_UNCAUGHT; } ddtrace_exception_to_meta(Z_OBJ_P(exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); + } else if (span->std.ce == ddtrace_ce_root_span_data) { + ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); + if (root->is_inferred_span) { + zval *child_exception_zv = &root->child_root->span.property_exception; + has_exception = Z_TYPE_P(child_exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(child_exception_zv), zend_ce_throwable); + if (has_exception) { + ignore_error = false; + enum dd_exception exception_type = Z_PROP_FLAG_P(child_exception_zv) == 2 ? DD_EXCEPTION_CAUGHT : DD_EXCEPTION_UNCAUGHT; + ddtrace_exception_to_meta(Z_OBJ_P(child_exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); + } + } } zend_array *span_links = ddtrace_property_array(&span->property_links); diff --git a/ext/serializer.h b/ext/serializer.h index 3c5f3cb87b..29697e123a 100644 --- a/ext/serializer.h +++ b/ext/serializer.h @@ -11,7 +11,8 @@ void ddtrace_serialize_span_to_array(ddtrace_span_data *span, zval *array); void ddtrace_save_active_error_to_metadata(void); void ddtrace_set_global_span_properties(ddtrace_span_data *span); -void ddtrace_set_root_span_properties(ddtrace_root_span_data *span); +void dd_set_entrypoint_root_span_props_from_globals(ddtrace_root_span_data *span); +void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_inferred); void ddtrace_update_root_id_properties(ddtrace_root_span_data *span); void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data *parent); zend_string *ddtrace_default_service_name(void); diff --git a/ext/span.c b/ext/span.c index 0ea3b2457a..2f5e819f56 100644 --- a/ext/span.c +++ b/ext/span.c @@ -44,9 +44,9 @@ static void dd_drop_span_nodestroy(ddtrace_span_data *span, bool silent) { if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(SPAN_TRACE, "Dropping root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); + LOG(DEBUG, "Dropping root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); } else { - LOG(SPAN_TRACE, "Dropping span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(DEBUG, "Dropping span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); } } @@ -150,7 +150,7 @@ uint64_t ddtrace_nanoseconds_realtime(void) { return ts.tv_sec * ZEND_NANO_IN_SEC + ts.tv_nsec; } -ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { +ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inferred) { ddtrace_span_stack *stack = DDTRACE_G(active_stack); // The primary stack is ancestor to all stacks, which signifies that any root spans created on top of it will inherit the distributed tracing context bool primary_stack = stack->parent_stack == NULL; @@ -165,8 +165,11 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { // ensure dtor can be called again GC_DEL_FLAGS(&stack->std, IS_OBJ_DESTRUCTOR_CALLED); + bool child_of_inferred_span = DDTRACE_G(active_stack)->root_span != NULL + && DDTRACE_G(active_stack)->root_span->is_inferred_span + && DDTRACE_G(active_stack)->root_span->child_root == NULL; bool root_span = DDTRACE_G(active_stack)->root_span == NULL; - ddtrace_span_data *span = ddtrace_init_span(type, root_span ? ddtrace_ce_root_span_data : ddtrace_ce_span_data); + ddtrace_span_data *span = ddtrace_init_span(type, (root_span || child_of_inferred_span) ? ddtrace_ce_root_span_data : ddtrace_ce_span_data); // All open spans hold a ref to their stack ZVAL_OBJ_COPY(&span->property_stack, &stack->std); @@ -203,7 +206,25 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { ZVAL_NULL(&span->property_parent); span->parent = NULL; - ddtrace_set_root_span_properties(root); + ddtrace_set_root_span_properties(root, is_inferred); + } else if (child_of_inferred_span) { + span->is_child_of_inferred_span = true; + ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); + DDTRACE_G(active_stack)->root_span->child_root = root; + + root->trace_id = DDTRACE_G(active_stack)->root_span->trace_id; + root->parent_id = DDTRACE_G(active_stack)->root_span->span.span_id; + ZVAL_OBJ(&span->property_parent, &DDTRACE_G(active_stack)->root_span->span.std); + ddtrace_inherit_span_properties(span, &DDTRACE_G(active_stack)->root_span->span); + dd_set_entrypoint_root_span_props_from_globals(root); + + zval *prop_name = &span->property_name; + zval_ptr_dtor(prop_name); + ZVAL_STR(prop_name, ddtrace_default_service_name()); + + zval *prop_service = &span->property_service; + zval_ptr_dtor(prop_service); + ZVAL_STR_COPY(prop_service, ZSTR_LEN(get_DD_SERVICE()) ? get_DD_SERVICE() : Z_STR_P(prop_name)); } else { // do not copy the parent, it was active span before, just transfer that reference ZVAL_OBJ(&span->property_parent, &parent_span->std); @@ -216,13 +237,13 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { if (root_span) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(SPAN_TRACE, "Starting new root span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d, parent_SpanStack=%d", Z_STRVAL(root->property_trace_id), span->span_id, root->parent_id, root->stack->std.handle, root->stack->parent_stack->std.handle); + LOG(DEBUG, "Starting new root span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d, parent_SpanStack=%d", Z_STRVAL(root->property_trace_id), span->span_id, root->parent_id, root->stack->std.handle, root->stack->parent_stack->std.handle); if (ddtrace_span_is_entrypoint_root(span)) { ddtrace_sidecar_submit_root_span_data(); } } else { - LOG(SPAN_TRACE, "Starting new span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d", Z_STRVAL(span->root->property_trace_id), span->span_id, SPANDATA(span->parent)->span_id, span->stack->std.handle); + LOG(DEBUG, "Starting new span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d", Z_STRVAL(span->root->property_trace_id), span->span_id, SPANDATA(span->parent)->span_id, span->stack->std.handle); } return span; @@ -236,7 +257,7 @@ ddtrace_span_data *ddtrace_alloc_execute_data_span(zend_ulong index, zend_execut span = Z_PTR_P(span_zv); Z_TYPE_INFO_P(span_zv) += 2; } else { - span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); + span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); // SpanData::$name defaults to fully qualified called name zval *prop_name = &span->property_name; @@ -314,9 +335,9 @@ void ddtrace_clear_execute_data_span(zend_ulong index, bool keep) { void ddtrace_switch_span_stack(ddtrace_span_stack *target_stack) { if (target_stack->active) { ddtrace_span_data *span = SPANDATA(target_stack->active); - LOG(SPAN_TRACE, "Switching to different SpanStack: %d, top of stack: trace_id=%s, span_id=%" PRIu64, target_stack->std.handle, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(DEBUG, "Switching to different SpanStack: %d, top of stack: trace_id=%s, span_id=%" PRIu64, target_stack->std.handle, Z_STRVAL(span->root->property_trace_id), span->span_id); } else { - LOG(SPAN_TRACE, "Switching to different SpanStack: %d", target_stack->std.handle); + LOG(DEBUG, "Switching to different SpanStack: %d", target_stack->std.handle); } GC_ADDREF(&target_stack->std); @@ -351,7 +372,7 @@ ddtrace_span_stack *ddtrace_init_root_span_stack(void) { span_stack->root_stack = span_stack; span_stack->root_span = NULL; - LOG(SPAN_TRACE, "Creating new root SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); + LOG(DEBUG, "Creating new root SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); return span_stack; } @@ -363,13 +384,19 @@ ddtrace_span_stack *ddtrace_init_span_stack(void) { span_stack->root_stack = DDTRACE_G(active_stack)->root_stack; span_stack->root_span = DDTRACE_G(active_stack)->root_span; - LOG(SPAN_TRACE, "Creating new SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); + LOG(DEBUG, "Creating new SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); return span_stack; } void ddtrace_push_root_span(void) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN, false); + // We opened the span, but are not going to hold a reference to it directly - the stack will manage it. + GC_DELREF(&span->std); +} + +void ddtrace_push_inferred_root_span(void) { + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN, true); // We opened the span, but are not going to hold a reference to it directly - the stack will manage it. GC_DELREF(&span->std); } @@ -555,6 +582,16 @@ void ddtrace_close_span(ddtrace_span_data *span) { ddtrace_close_stack_userland_spans_until(span); ddtrace_close_top_span_without_stack_swap(span); + + // Check if the span is a child of an inferred span and if so, close the parent span + /* + if (DDTRACE_G(active_stack)->root_span->is_inferred_span && &(DDTRACE_G(active_stack)->root_span->child_root->span) == span) + { + ddtrace_span_data inferred_span = DDTRACE_G(active_stack)->root_span->span; + dd_trace_stop_span_time(&inferred_span); + ddtrace_close_span(&inferred_span); + } + */ } void ddtrace_close_span_restore_stack(ddtrace_span_data *span) { @@ -612,9 +649,9 @@ void ddtrace_close_top_span_without_stack_swap(ddtrace_span_data *span) { if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(SPAN_TRACE, "Closing root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); + LOG(DEBUG, "Closing root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); } else { - LOG(SPAN_TRACE, "Closing span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(DEBUG, "Closing span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); } if (!stack->active || SPANDATA(stack->active)->stack != stack) { @@ -657,7 +694,7 @@ void ddtrace_close_all_open_spans(bool force_close_root_span) { ddtrace_span_data *span; while (stack->active && (span = SPANDATA(stack->active))->stack == stack) { - LOG(SPAN_TRACE, "Automatically finishing the next span (in shutdown or force flush requested)"); + LOG(DEBUG, "Automatically finishing the next span (in shutdown or force flush requested)"); if (get_DD_AUTOFINISH_SPANS() || (force_close_root_span && span->type == DDTRACE_AUTOROOT_SPAN)) { dd_trace_stop_span_time(span); ddtrace_close_span(span); @@ -796,3 +833,63 @@ zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id) { snprintf(ZSTR_VAL(str), 33, "%016" PRIx64 "%016" PRIx64, id.high, id.low); return str; } + +void ddtrace_infer_proxy_services(void) { + zend_array *server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); + zval *proxy_header_system = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY")); + zval *proxy_header_start_time_ms = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_REQUEST_TIME_MS")); + if (!proxy_header_system || Z_TYPE_P(proxy_header_system) != IS_STRING || Z_STRLEN_P(proxy_header_system) == 0 || !proxy_header_start_time_ms || Z_TYPE_P(proxy_header_start_time_ms) != IS_STRING || Z_STRLEN_P(proxy_header_start_time_ms) == 0) { + return; + } + + zval *proxy_header_path = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_PATH")); + zval *proxy_header_http_method = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_HTTPMETHOD")); + zval *proxy_header_domain = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_DOMAIN_NAME")); + zval *proxy_header_stage = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_STAGE")); + + + ddtrace_push_inferred_root_span(); + ddtrace_root_span_data *rsd = DDTRACE_G(active_stack)->root_span; + rsd->is_inferred_span = true; + + zval *prop_name = &rsd->span.property_name; + zval_ptr_dtor(prop_name); + ZVAL_STR_COPY(prop_name, Z_STR_P(proxy_header_system)); + + zval *prop_resource = &rsd->span.property_resource; + zval_ptr_dtor(prop_resource); + ZVAL_STR(prop_resource, strpprintf(0, "%s %s", Z_STRVAL_P(proxy_header_http_method), Z_STRVAL_P(proxy_header_path))); + + rsd->span.start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; + + if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { + zval *prop_service = &rsd->span.property_service; + zval_ptr_dtor(prop_service); + ZVAL_STR_COPY(prop_service, Z_STR_P(proxy_header_domain)); + } // Defaults to DD_SERVICE + + // Set meta component to aws-apigateway + zend_array *meta = ddtrace_property_array(&rsd->span.property_meta); + zval component; + ZVAL_STR(&component, zend_string_init("aws-apigateway", sizeof("aws-apigateway") - 1, 0)); + zend_hash_str_add_new(meta, ZEND_STRL("component"), &component); + + // Set meta "http.method" to value of x-dd-proxy-httpmethod + zval http_method; + ZVAL_STR_COPY(&http_method, Z_STR_P(proxy_header_http_method)); + zend_hash_str_add_new(meta, ZEND_STRL("http.method"), &http_method); + + // Set meta "http.url" to x-dd-proxy-domain-name + x-dd-proxy-path + zval http_url; + ZVAL_STR(&http_url, strpprintf(0, "%s%s", Z_STRVAL_P(proxy_header_domain), Z_STRVAL_P(proxy_header_path))); + zend_hash_str_add_new(meta, ZEND_STRL("http.url"), &http_url); + + // Set meta "stage" to x-dd-proxy-stage + if (proxy_header_stage && Z_TYPE_P(proxy_header_stage) == IS_STRING && Z_STRLEN_P(proxy_header_stage) > 0) { + zval stage; + ZVAL_STR_COPY(&stage, Z_STR_P(proxy_header_stage)); + zend_hash_str_add_new(meta, ZEND_STRL("stage"), &stage); + } + + LOG(DEBUG, "Inferred trace_id=%s, span_id=%" PRIu64 " from HTTP_X_DD_PROXY header", Z_STRVAL(rsd->property_trace_id), rsd->span.span_id); +} diff --git a/ext/span.h b/ext/span.h index c664ead825..1eff0a7608 100644 --- a/ext/span.h +++ b/ext/span.h @@ -86,6 +86,7 @@ struct ddtrace_span_data { bool notify_user_req_end; struct ddtrace_span_data *next; struct ddtrace_root_span_data *root; + bool is_child_of_inferred_span; union { ddtrace_span_properties; @@ -107,6 +108,8 @@ struct ddtrace_root_span_data { ddtrace_rule_result sampling_rule; bool explicit_sampling_priority; enum ddtrace_trace_limited trace_is_limited; + bool is_inferred_span; + struct ddtrace_root_span_data *child_root; // Only used when inferring proxy services union { ddtrace_span_data; @@ -206,11 +209,12 @@ void ddtrace_init_span_stacks(void); void ddtrace_free_span_stacks(bool silent); void ddtrace_switch_span_stack(ddtrace_span_stack *target_stack); -ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type); +ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inferred); ddtrace_span_data *ddtrace_init_dummy_span(void); ddtrace_span_stack *ddtrace_init_span_stack(void); ddtrace_span_stack *ddtrace_init_root_span_stack(void); void ddtrace_push_root_span(void); +void ddtrace_push_inferred_root_span(void); ddtrace_span_data *ddtrace_active_span(void); static inline ddtrace_span_properties *ddtrace_active_span_props(void) { @@ -241,6 +245,7 @@ zend_string *ddtrace_span_id_as_string(uint64_t id); zend_string *ddtrace_trace_id_as_string(ddtrace_trace_id id); zend_string *ddtrace_span_id_as_hex_string(uint64_t id); zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id); +void ddtrace_infer_proxy_services(void); bool ddtrace_span_alter_root_span_config(zval *old_value, zval *new_value, zend_string *new_str); @@ -250,7 +255,7 @@ static inline bool ddtrace_span_is_dropped(ddtrace_span_data *span) { static inline bool ddtrace_span_is_entrypoint_root(ddtrace_span_data *span) { // The parent stack of a true top-level stack does never have a parent stack itself - return span->std.ce == ddtrace_ce_root_span_data && (!span->stack->parent_stack || !span->stack->parent_stack->parent_stack); + return span->std.ce == ddtrace_ce_root_span_data && (!span->stack->parent_stack || !span->stack->parent_stack->parent_stack) && !span->is_child_of_inferred_span; } #endif // DD_SPAN_H diff --git a/tests/ext/inferred_proxy/basic_test.phpt b/tests/ext/inferred_proxy/basic_test.phpt new file mode 100644 index 0000000000..84271322d5 --- /dev/null +++ b/tests/ext/inferred_proxy/basic_test.phpt @@ -0,0 +1,150 @@ +--TEST-- +Should create parent and child spans for a 200 +--ENV-- +DD_TRACE_AUTO_FLUSH_ENABLED=0 +DD_TRACE_GENERATE_ROOT_SPAN=0 +DD_AUTOFINISH_SPANS=1 +DD_SERVICE=aws-server +DD_ENV=local-prod +DD_VERSION=1.0 + +DD_TRACE_DEBUG=0 + +DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 +HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 +HTTP_X_DD_PROXY_PATH=/test +HTTP_X_DD_PROXY_HTTPMETHOD=GET +HTTP_X_DD_PROXY_DOMAIN_NAME=example.com +HTTP_X_DD_PROXY_STAGE=aws-prod + +METHOD=GET +SERVER_NAME=localhost:8888 +SCRIPT_NAME=/foo.php +REQUEST_URI=/foo + +DD_AGENT_HOST=request-replayer +DD_TRACE_AGENT_PORT=80 +DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=1 +DD_TRACE_AGENT_FLUSH_INTERVAL=666 +DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 + +DD_TRACE_DEBUG_PRNG_SEED=42 +--GET-- +foo=bar +--FILE-- +name = "child"; + +\DDTrace\root_span()->meta['foo'] = 'bar'; // It MUST set it on $parent + +//\DDTrace\close_spans_until(null); + +/* +function oops() +{ + http_response_code(500); + throw new \Exception('An exception occurred'); +} + +\DDTrace\trace_function('oops', function($span) { + $span->name = 'request'; +}); + +try { + oops(); +} catch (\Exception $e) { + // +} +*/ + +dd_trace_close_all_spans_and_flush(); // Simulates end of request + +echo json_encode(json_decode($rr->waitForDataAndReplay()["body"]), JSON_PRETTY_PRINT); + +//$span = dd_trace_serialize_closed_spans(); + +//echo json_encode($span, JSON_PRETTY_PRINT); +?> +--EXPECTF-- +[ + [ + { + "trace_id": "13930160852258120406", + "span_id": "13930160852258120406", + "start": 100000000, + "duration": %d, + "name": "aws-apigateway", + "resource": "GET \/test", + "service": "example.com", + "type": "web", + "meta": { + "runtime-id": "%s", + "component": "aws-apigateway", + "http.method": "GET", + "http.url": "example.com\/test", + "stage": "aws-prod", + "_dd.p.dm": "-0", + "env": "local-prod", + "version": "1.0", + "http.status_code": "200", + "_dd.p.tid": "%s" + }, + "metrics": { + "process_id": %d, + "_dd.agent_psr": 1, + "_sampling_priority_v1": 1, + "php.compilation.total_time_ms": %f, + "php.memory.peak_usage_bytes": %d, + "php.memory.peak_real_usage_bytes": %d + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "11788048577503494824", + "parent_id": "13930160852258120406", + "start": 120000000, + "duration": %d, + "name": "web.request", + "resource": "GET \/foo", + "service": "aws-server", + "type": "web", + "meta": { + "http.url": "http:\/\/localhost:8888\/foo", + "http.method": "GET", + "foo": "bar", + "env": "local-prod", + "version": "1.0", + "_dd.p.tid": "%s", + "_dd.base_service": "example.com" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "13874630024467741450", + "parent_id": "11788048577503494824", + "start": 130000000, + "duration": %d, + "name": "child", + "resource": "child", + "service": "aws-server", + "type": "web", + "meta": { + "env": "local-prod", + "version": "1.0", + "_dd.base_service": "example.com" + } + } + ] +] \ No newline at end of file From 4d706fb217f1d000313a195cd2cd92013b2dde6f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 10:30:10 +0100 Subject: [PATCH 02/46] fix: segfault --- ext/serializer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/serializer.c b/ext/serializer.c index 0fdbdfa9e1..f078573765 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1186,7 +1186,7 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv ddtrace_exception_to_meta(Z_OBJ_P(exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); } else if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - if (root->is_inferred_span) { + if (root->is_inferred_span && root->child_root) { zval *child_exception_zv = &root->child_root->span.property_exception; has_exception = Z_TYPE_P(child_exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(child_exception_zv), zend_ce_throwable); if (has_exception) { From 39f9f2a2f2ba2e9a3b739f56dbb323ad6b25983f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 10:30:28 +0100 Subject: [PATCH 03/46] fix: duration --- ext/ddtrace.c | 1 + ext/span.c | 1 + 2 files changed, 2 insertions(+) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 37e224e8f7..703ea5817d 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -932,6 +932,7 @@ static zend_object *ddtrace_root_span_data_create(zend_class_entry *class_type) array_init(&span->property_propagated_tags); array_init(&span->property_tracestate_tags); #endif + span->child_root = NULL; return &span->std; } diff --git a/ext/span.c b/ext/span.c index 2f5e819f56..8cf2ce81c8 100644 --- a/ext/span.c +++ b/ext/span.c @@ -861,6 +861,7 @@ void ddtrace_infer_proxy_services(void) { ZVAL_STR(prop_resource, strpprintf(0, "%s %s", Z_STRVAL_P(proxy_header_http_method), Z_STRVAL_P(proxy_header_path))); rsd->span.start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; + rsd->span.duration_start = zend_htime() - rsd->span.start; if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { zval *prop_service = &rsd->span.property_service; From fccd91bdaef8b981362aebd5129da94a97844e54 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 10:53:00 +0100 Subject: [PATCH 04/46] fix: duration --- ext/span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/span.c b/ext/span.c index 8cf2ce81c8..ad648a67a3 100644 --- a/ext/span.c +++ b/ext/span.c @@ -861,7 +861,7 @@ void ddtrace_infer_proxy_services(void) { ZVAL_STR(prop_resource, strpprintf(0, "%s %s", Z_STRVAL_P(proxy_header_http_method), Z_STRVAL_P(proxy_header_path))); rsd->span.start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; - rsd->span.duration_start = zend_htime() - rsd->span.start; + rsd->span.duration_start = rsd->span.start; if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { zval *prop_service = &rsd->span.property_service; From 2bbf531d19956754eba10f552af5dd2bbee60c0a Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 12:58:11 +0100 Subject: [PATCH 05/46] error log start/duration/duration_start --- ext/serializer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/serializer.c b/ext/serializer.c index f078573765..c8a5f20628 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1786,14 +1786,17 @@ void ddtrace_serialize_span_to_array(ddtrace_span_data *span, zval *array) { smart_str_0(&metrics_str); } prop_name = zend_hash_str_find(Z_ARR_P(el), ZEND_STRL("name")); // refetch, array may have been rehashed - log("Encoding span %" PRIu64 ": trace_id=%s, name='%s', service='%s', resource: '%s', type '%s' with tags: %s; and metrics: %s", + log("Encoding span %" PRIu64 ": trace_id=%s, name='%s', service='%s', resource: '%s', type '%s' with tags: %s; metrics: %s; start: %ld; duration_start: %ld, and duration: %ld", span->span_id, Z_STRVAL(span->root->property_trace_id), prop_name && Z_TYPE_P(prop_name) == IS_STRING ? Z_STRVAL_P(prop_name) : "", Z_TYPE(prop_service_as_string) == IS_STRING ? Z_STRVAL(prop_service_as_string) : "", Z_TYPE(prop_resource_as_string) == IS_STRING ? Z_STRVAL(prop_resource_as_string) : "", Z_TYPE(prop_type_as_string) == IS_STRING ? Z_STRVAL(prop_type_as_string) : "", meta_str.s ? ZSTR_VAL(meta_str.s) : "-", - metrics_str.s ? ZSTR_VAL(metrics_str.s) : "-"); + metrics_str.s ? ZSTR_VAL(metrics_str.s) : "-", + span->start, + span->duration_start, + span->duration); smart_str_free(&meta_str); smart_str_free(&metrics_str); }) From 291f75bfa57561777fbdce5538d72a4cd2ce1281 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 15:58:50 +0100 Subject: [PATCH 06/46] fix: duration --- ext/span.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ext/span.c b/ext/span.c index ad648a67a3..0a583b3fda 100644 --- a/ext/span.c +++ b/ext/span.c @@ -850,27 +850,28 @@ void ddtrace_infer_proxy_services(void) { ddtrace_push_inferred_root_span(); ddtrace_root_span_data *rsd = DDTRACE_G(active_stack)->root_span; + ddtrace_span_data *span = &rsd->span; rsd->is_inferred_span = true; - zval *prop_name = &rsd->span.property_name; + zval *prop_name = &span->property_name; zval_ptr_dtor(prop_name); ZVAL_STR_COPY(prop_name, Z_STR_P(proxy_header_system)); - zval *prop_resource = &rsd->span.property_resource; + zval *prop_resource = &span->property_resource; zval_ptr_dtor(prop_resource); ZVAL_STR(prop_resource, strpprintf(0, "%s %s", Z_STRVAL_P(proxy_header_http_method), Z_STRVAL_P(proxy_header_path))); - rsd->span.start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; - rsd->span.duration_start = rsd->span.start; + span->start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; + span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); // // Now - offset if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { - zval *prop_service = &rsd->span.property_service; + zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, Z_STR_P(proxy_header_domain)); } // Defaults to DD_SERVICE // Set meta component to aws-apigateway - zend_array *meta = ddtrace_property_array(&rsd->span.property_meta); + zend_array *meta = ddtrace_property_array(&span->property_meta); zval component; ZVAL_STR(&component, zend_string_init("aws-apigateway", sizeof("aws-apigateway") - 1, 0)); zend_hash_str_add_new(meta, ZEND_STRL("component"), &component); From 6fc16327308d7f55f4f3697e8c5a8a65be03a855 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 10 Feb 2025 16:51:53 +0100 Subject: [PATCH 07/46] x-dd-proxy-domain-name add debug logs --- ext/span.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/span.c b/ext/span.c index 0a583b3fda..31fd15acb2 100644 --- a/ext/span.c +++ b/ext/span.c @@ -865,6 +865,7 @@ void ddtrace_infer_proxy_services(void) { span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); // // Now - offset if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { + LOG(DEBUG, "Inferred service=%s from HTTP_X_DD_PROXY header", Z_STRVAL_P(proxy_header_domain)); zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, Z_STR_P(proxy_header_domain)); From 162b382859b701846538954a480ead1ca0fcb7c6 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 11 Feb 2025 10:12:12 +0100 Subject: [PATCH 08/46] service debug logs --- ext/serializer.c | 2 ++ ext/span.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/serializer.c b/ext/serializer.c index c8a5f20628..62b9ff81d1 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -681,6 +681,7 @@ void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_COPY(prop_service, &parent->property_service); + LOG(DEBUG, "Inherited service name: %s", Z_STRVAL_P(prop_service)); zval *prop_type = &span->property_type; zval_ptr_dtor(prop_type); ZVAL_COPY(prop_type, &parent->property_type); @@ -819,6 +820,7 @@ void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_infe ZVAL_STR(prop_name, ddtrace_default_service_name()); zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, ZSTR_LEN(get_DD_SERVICE()) ? get_DD_SERVICE() : Z_STR_P(prop_name)); + LOG(DEBUG, "Service set to %s when setting root span properties", ZSTR_VAL(Z_STR_P(prop_service))); zend_string *version = get_DD_VERSION(); diff --git a/ext/span.c b/ext/span.c index 31fd15acb2..c4c2c38d8b 100644 --- a/ext/span.c +++ b/ext/span.c @@ -225,6 +225,8 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inf zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, ZSTR_LEN(get_DD_SERVICE()) ? get_DD_SERVICE() : Z_STR_P(prop_name)); + LOG(DEBUG, "Setting child of inferred span's service to: %s", ZSTR_VAL(Z_STR_P(prop_service))); + LOG(DEBUG, "Root span's service is: %s", ZSTR_VAL(Z_STR_P(&DDTRACE_G(active_stack)->root_span->span.property_service))); } else { // do not copy the parent, it was active span before, just transfer that reference ZVAL_OBJ(&span->property_parent, &parent_span->std); @@ -869,6 +871,7 @@ void ddtrace_infer_proxy_services(void) { zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, Z_STR_P(proxy_header_domain)); + LOG(DEBUG, "Verification: service=%s", Z_STRVAL_P(prop_service)); } // Defaults to DD_SERVICE // Set meta component to aws-apigateway @@ -893,6 +896,6 @@ void ddtrace_infer_proxy_services(void) { ZVAL_STR_COPY(&stage, Z_STR_P(proxy_header_stage)); zend_hash_str_add_new(meta, ZEND_STRL("stage"), &stage); } - + LOG(DEBUG, "Inferred trace_id=%s, span_id=%" PRIu64 " from HTTP_X_DD_PROXY header", Z_STRVAL(rsd->property_trace_id), rsd->span.span_id); } From 641811a9ae072ec9ec964564ef3d4a8a49f9577b Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 11 Feb 2025 10:12:29 +0100 Subject: [PATCH 09/46] tests: Laravel x InferredProxy --- .../Laravel/Latest/InferredProxyTest.php | 65 +++ ...ferred_proxy_test.test_inferred_proxy.json | 380 ++++++++++++++++++ ...xy_test.test_inferred_proxy_exception.json | 377 +++++++++++++++++ 3 files changed, 822 insertions(+) create mode 100644 tests/Integrations/Laravel/Latest/InferredProxyTest.php create mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json create mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json diff --git a/tests/Integrations/Laravel/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Latest/InferredProxyTest.php new file mode 100644 index 0000000000..c970b12dfd --- /dev/null +++ b/tests/Integrations/Laravel/Latest/InferredProxyTest.php @@ -0,0 +1,65 @@ + 'laravel_test_app', + 'DD_SERVICE' => 'my_service', + 'DD_ENV' => 'local-test', + 'DD_VERSION' => '1.0', + 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + ]); + } + + public function testInferredProxy() + { + $this->tracesFromWebRequestSnapshot(function () { + $this->call( + GetSpec::create( + 'A simple GET request returning a string', + '/simple?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); + } + + public function testInferredProxyException() + { + $this->tracesFromWebRequestSnapshot(function () { + $this->call( + GetSpec::create( + 'A GET throwing an exception', + '/error?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); + } +} \ No newline at end of file diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..54a927b9e3 --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,380 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 6378656277655726371, + "type": "web", + "meta": { + "_dd.p.dm": "-0", + "_dd.p.tid": "67ab0d3a00000000", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.status_code": "200", + "http.url": "example.com/test", + "runtime-id": "220ddebc-fe8e-4a05-8b4b-418773942fb6", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.request", + "service": "my_service", + "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67ab0d3a00000000", + "component": "laravel", + "env": "local-test", + "http.method": "GET", + "http.route": "simple", + "http.url": "http://localhost/simple?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", + "laravel.route.name": "simple_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.provider.load", + "service": "my_service", + "resource": "Illuminate\\Foundation\\ProviderRepository::load", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 15, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 16, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 17, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "my_service", + "resource": "simple", + "trace_id": 0, + "span_id": 18, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 19, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 20, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 21, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 22, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 23, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 24, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json new file mode 100644 index 0000000000..41ce03e68b --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json @@ -0,0 +1,377 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 8854955935653512842, + "type": "web", + "error": 1, + "meta": { + "_dd.p.dm": "-0", + "_dd.p.tid": "67ab0d9f00000000", + "component": "aws-apigateway", + "env": "local-test", + "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.status_code": "500", + "http.url": "example.com/test", + "runtime-id": "085568b6-4655-412a-b130-6cdeb6d74e9e", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.request", + "service": "my_service", + "resource": "App\\Http\\Controllers\\CommonSpecsController@error unnamed_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67ab0d9f00000000", + "component": "laravel", + "env": "local-test", + "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.route": "error", + "http.url": "http://localhost/error?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@error", + "laravel.route.name": "unnamed_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.provider.load", + "service": "my_service", + "resource": "Illuminate\\Foundation\\ProviderRepository::load", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 15, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 16, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 17, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "my_service", + "resource": "error", + "trace_id": 0, + "span_id": 18, + "parent_id": 2, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "error.message": "Thrown Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Log\\Events\\MessageLogged", + "trace_id": 0, + "span_id": 19, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 20, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 21, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 22, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 23, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] From 144de1838de1c138e5187a24eb692487d5ab4806 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 11 Feb 2025 11:19:24 +0100 Subject: [PATCH 10/46] fix: Specifically do not inherit service property --- ext/serializer.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ext/serializer.c b/ext/serializer.c index 62b9ff81d1..cdcdceb5c4 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -678,10 +678,16 @@ static void dd_set_entrypoint_root_span_props(struct superglob_equiv *data, ddtr } void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data *parent) { - zval *prop_service = &span->property_service; - zval_ptr_dtor(prop_service); - ZVAL_COPY(prop_service, &parent->property_service); - LOG(DEBUG, "Inherited service name: %s", Z_STRVAL_P(prop_service)); + ddtrace_root_span_data *root = span->stack->root_span; + if (&root->span != parent || !root->is_inferred_span) { + zval *prop_service = &span->property_service; + zval_ptr_dtor(prop_service); + ZVAL_COPY(prop_service, &parent->property_service); + LOG(DEBUG, "Inherited service name: %s", Z_STRVAL_P(prop_service)); + } else { + LOG(DEBUG, "Child of inferred span; not inheriting service name"); + } + zval *prop_type = &span->property_type; zval_ptr_dtor(prop_type); ZVAL_COPY(prop_type, &parent->property_type); From ba71c601684fab2188fbee7c968e9952650601c6 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 12 Feb 2025 10:02:46 +0100 Subject: [PATCH 11/46] more debug logs --- ext/ddtrace.c | 1 + ext/serializer.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 703ea5817d..69b9620611 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -387,6 +387,7 @@ static inline void dd_alter_prop(size_t prop_offset, zval *old_value, zval *new_ } bool ddtrace_alter_dd_service(zval *old_value, zval *new_value, zend_string *new_str) { + LOG(DEBUG, "Altering property service to %s", Z_STRVAL_P(new_value)); dd_alter_prop(XtOffsetOf(ddtrace_span_properties, property_service), old_value, new_value, new_str); if (DDTRACE_G(request_initialized)) { ddtrace_sidecar_submit_root_span_data_direct(NULL, new_str, get_DD_ENV(), get_DD_VERSION()); diff --git a/ext/serializer.c b/ext/serializer.c index cdcdceb5c4..667ae03dbc 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1318,13 +1318,16 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv zend_array *service_mappings = get_DD_SERVICE_MAPPING(); zval *new_root_name = zend_hash_find(service_mappings, Z_STR(prop_root_service_as_string)); if (new_root_name) { + LOG(DEBUG, "New root service name found: %s", Z_STRVAL_P(new_root_name)); zend_string_release(Z_STR(prop_root_service_as_string)); ZVAL_COPY(&prop_root_service_as_string, new_root_name); } if (!zend_string_equals_ci(Z_STR(prop_service_as_string), Z_STR(prop_root_service_as_string))) { + LOG(DEBUG, "Setting _dd.base_service to %s", Z_STRVAL(prop_root_service_as_string)); add_assoc_str(meta, "_dd.base_service", Z_STR(prop_root_service_as_string)); } else { + LOG(DEBUG, "Service name matches root service name; not adding _dd.base_service"); zend_string_release(Z_STR(prop_root_service_as_string)); } From 9fb4ab9a59ca626cc0feb678fcc9547312b7cf0f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 12 Feb 2025 14:41:34 +0100 Subject: [PATCH 12/46] fix: Don't overwrite inferred span's service. --- ext/ddtrace.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 69b9620611..11c93be669 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -383,6 +383,14 @@ static inline void dd_alter_prop(size_t prop_offset, zval *old_value, zval *new_ ZVAL_COPY(property, new_value); zval_ptr_dtor(&garbage); pspan = pspan->parent; + + ddtrace_span_data *span = SPANDATA(pspan); + if (span->type == DDTRACE_AUTOROOT_SPAN) { + ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); + if (root->is_inferred_span) { + pspan = pspan->parent; // It should be NULL, but just in case... + } + } } } From 7153541b823cfa3b65a92dcbe70f22ab9aca74b6 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 13 Feb 2025 09:37:47 +0100 Subject: [PATCH 13/46] style: refactor service alter skip --- ext/ddtrace.c | 35 +++++++++++++++++++++++++---------- ext/span.c | 10 ---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 11c93be669..98896837b7 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -374,29 +374,44 @@ bool ddtrace_alter_sampling_rules_file_config(zval *old_value, zval *new_value, return dd_save_sampling_rules_file_config(Z_STR_P(new_value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME); } -static inline void dd_alter_prop(size_t prop_offset, zval *old_value, zval *new_value, zend_string *new_str) { +static inline void dd_alter_prop_common(size_t prop_offset, zval *old_value, zval *new_value, zend_string *new_str, bool skip_inferred) { UNUSED(old_value, new_str); ddtrace_span_properties *pspan = ddtrace_active_span_props(); while (pspan) { + if (skip_inferred) { + ddtrace_span_data *span = SPANDATA(pspan); + if (span && span->type == DDTRACE_AUTOROOT_SPAN) { + ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); + if (root->is_inferred_span) { + pspan = pspan->parent; // It should be NULL, but just in case... + continue; + } + } + } + zval *property = (zval *) (prop_offset + (char *) pspan), garbage = *property; ZVAL_COPY(property, new_value); zval_ptr_dtor(&garbage); pspan = pspan->parent; - - ddtrace_span_data *span = SPANDATA(pspan); - if (span->type == DDTRACE_AUTOROOT_SPAN) { - ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - if (root->is_inferred_span) { - pspan = pspan->parent; // It should be NULL, but just in case... - } - } } } +static inline void dd_alter_prop(size_t prop_offset, zval *old_value, zval *new_value, zend_string *new_str) { + dd_alter_prop_common(prop_offset, old_value, new_value, new_str, false); +} + +static inline void dd_alter_prop_skip_inferred_span(size_t prop_offset, zval *old_value, zval *new_value, zend_string *new_str) { + dd_alter_prop_common(prop_offset, old_value, new_value, new_str, true); +} + bool ddtrace_alter_dd_service(zval *old_value, zval *new_value, zend_string *new_str) { LOG(DEBUG, "Altering property service to %s", Z_STRVAL_P(new_value)); - dd_alter_prop(XtOffsetOf(ddtrace_span_properties, property_service), old_value, new_value, new_str); + if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + dd_alter_prop_skip_inferred_span(XtOffsetOf(ddtrace_span_properties, property_service), old_value, new_value, new_str); + } else { + dd_alter_prop(XtOffsetOf(ddtrace_span_properties, property_service), old_value, new_value, new_str); + } if (DDTRACE_G(request_initialized)) { ddtrace_sidecar_submit_root_span_data_direct(NULL, new_str, get_DD_ENV(), get_DD_VERSION()); } diff --git a/ext/span.c b/ext/span.c index c4c2c38d8b..7b9e5dbaad 100644 --- a/ext/span.c +++ b/ext/span.c @@ -584,16 +584,6 @@ void ddtrace_close_span(ddtrace_span_data *span) { ddtrace_close_stack_userland_spans_until(span); ddtrace_close_top_span_without_stack_swap(span); - - // Check if the span is a child of an inferred span and if so, close the parent span - /* - if (DDTRACE_G(active_stack)->root_span->is_inferred_span && &(DDTRACE_G(active_stack)->root_span->child_root->span) == span) - { - ddtrace_span_data inferred_span = DDTRACE_G(active_stack)->root_span->span; - dd_trace_stop_span_time(&inferred_span); - ddtrace_close_span(&inferred_span); - } - */ } void ddtrace_close_span_restore_stack(ddtrace_span_data *span) { From 03c0569318fc3ae303946c26561781451a45c373 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Fri, 14 Feb 2025 10:37:25 +0100 Subject: [PATCH 14/46] feat: Octane Swoole support --- ext/ddtrace.c | 25 ++++++++- ext/ddtrace.stub.php | 6 ++ ext/ddtrace_arginfo.h | 8 ++- ext/span.c | 55 ++++++++++++++----- ext/span.h | 3 +- .../Integrations/Swoole/SwooleIntegration.php | 33 +++++++++-- 6 files changed, 107 insertions(+), 23 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 98896837b7..c070f113b5 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -1572,6 +1572,7 @@ static void dd_rinit_once(void) { static pthread_once_t dd_rinit_once_control = PTHREAD_ONCE_INIT; static void dd_initialize_request(void) { + LOG(DEBUG, "dd_initialize_request"); DDTRACE_G(distributed_trace_id) = (ddtrace_trace_id){0}; DDTRACE_G(distributed_parent_trace_id) = 0; DDTRACE_G(additional_global_tags) = zend_new_array(0); @@ -1638,10 +1639,12 @@ static void dd_initialize_request(void) { ddtrace_apply_distributed_tracing_result(&distributed_result, NULL); if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + LOG(DEBUG, "Inferred proxy services enabled"); ddtrace_infer_proxy_services(); } if (get_DD_TRACE_GENERATE_ROOT_SPAN()) { + LOG(DEBUG, "Root span generation enabled"); ddtrace_push_root_span(); } } @@ -1662,7 +1665,7 @@ static PHP_RINIT_FUNCTION(ddtrace) { ddtrace_autoload_rinit(); #endif } - + LOG(DEBUG, "RINIT"); if (get_DD_TRACE_ENABLED()) { dd_initialize_request(); } @@ -2769,6 +2772,26 @@ PHP_FUNCTION(DDTrace_start_trace_span) { dd_start_span(INTERNAL_FUNCTION_PARAM_PASSTHRU); } +/* {{{ proto RootSpanData|null DDTrace\start_inferred_span(array $headers) */ +PHP_FUNCTION(DDTrace_start_inferred_span) { + zval *headers_zv = NULL; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &headers_zv) != SUCCESS) { + RETURN_THROWS(); + } + zend_array *headers = Z_ARRVAL_P(headers_zv); + + if (!get_DD_TRACE_ENABLED() || !get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + RETURN_NULL(); + } + + LOG(DEBUG, "Starting inferred span"); + ddtrace_root_span_data *root_span = ddtrace_open_inferred_span(headers); + if (root_span) { + RETURN_OBJ_COPY(&root_span->std); + } + RETURN_NULL(); +} + static void dd_set_span_finish_time(ddtrace_span_data *span, double finish_time_seconds) { // we do not expose the monotonic time here, so do not use it as reference time to calculate difference uint64_t start_time = span->start; diff --git a/ext/ddtrace.stub.php b/ext/ddtrace.stub.php index 066b759dc5..5b0bb3fbb9 100644 --- a/ext/ddtrace.stub.php +++ b/ext/ddtrace.stub.php @@ -545,6 +545,12 @@ function update_span_duration(SpanData $span, float $finishTime = 0): false|null */ function start_trace_span(float $startTime = 0): SpanData {} + /** + * @internal + * @return RootSpanData|null The newly created inferred root span, or 'null' if headers extraction failed. + */ + function start_inferred_span(array $headers): RootSpanData|null {} + /** * Get the active stack * diff --git a/ext/ddtrace_arginfo.h b/ext/ddtrace_arginfo.h index d616d445e9..3ee782d054 100644 --- a/ext/ddtrace_arginfo.h +++ b/ext/ddtrace_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 5edec61a2b1ae22c8473ffbd3c509df6196abbae */ + * Stub hash: 2ef1574e246f5a5c696b74152169237fad040333 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_DDTrace_trace_method, 0, 3, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, className, IS_STRING, 0) @@ -65,6 +65,10 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_DDTrace_start_trace_span, 0, 0, D ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, startTime, IS_DOUBLE, 0, "0") ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_DDTrace_start_inferred_span, 0, 1, DDTrace\\RootSpanData, 1) + ZEND_ARG_TYPE_INFO(0, headers, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_DDTrace_active_stack, 0, 0, DDTrace\\SpanStack, 1) ZEND_END_ARG_INFO() @@ -318,6 +322,7 @@ ZEND_FUNCTION(DDTrace_start_span); ZEND_FUNCTION(DDTrace_close_span); ZEND_FUNCTION(DDTrace_update_span_duration); ZEND_FUNCTION(DDTrace_start_trace_span); +ZEND_FUNCTION(DDTrace_start_inferred_span); ZEND_FUNCTION(DDTrace_active_stack); ZEND_FUNCTION(DDTrace_create_stack); ZEND_FUNCTION(DDTrace_switch_stack); @@ -402,6 +407,7 @@ static const zend_function_entry ext_functions[] = { ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "close_span"), zif_DDTrace_close_span, arginfo_DDTrace_close_span, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "update_span_duration"), zif_DDTrace_update_span_duration, arginfo_DDTrace_update_span_duration, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "start_trace_span"), zif_DDTrace_start_trace_span, arginfo_DDTrace_start_trace_span, 0, NULL, NULL) + ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "start_inferred_span"), zif_DDTrace_start_inferred_span, arginfo_DDTrace_start_inferred_span, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "active_stack"), zif_DDTrace_active_stack, arginfo_DDTrace_active_stack, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "create_stack"), zif_DDTrace_create_stack, arginfo_DDTrace_create_stack, 0, NULL, NULL) ZEND_RAW_FENTRY(ZEND_NS_NAME("DDTrace", "switch_stack"), zif_DDTrace_switch_stack, arginfo_DDTrace_switch_stack, 0, NULL, NULL) diff --git a/ext/span.c b/ext/span.c index 7b9e5dbaad..fba6050189 100644 --- a/ext/span.c +++ b/ext/span.c @@ -397,10 +397,13 @@ void ddtrace_push_root_span(void) { GC_DELREF(&span->std); } -void ddtrace_push_inferred_root_span(void) { +ddtrace_span_data *ddtrace_push_inferred_root_span(void) { ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN, true); // We opened the span, but are not going to hold a reference to it directly - the stack will manage it. GC_DELREF(&span->std); + ddtrace_root_span_data *rsd = ROOTSPANDATA(&span->std); + rsd->is_inferred_span = true; + return span; } DDTRACE_PUBLIC zend_object *ddtrace_get_root_span() @@ -826,24 +829,38 @@ zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id) { return str; } -void ddtrace_infer_proxy_services(void) { - zend_array *server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); - zval *proxy_header_system = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY")); - zval *proxy_header_start_time_ms = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_REQUEST_TIME_MS")); - if (!proxy_header_system || Z_TYPE_P(proxy_header_system) != IS_STRING || Z_STRLEN_P(proxy_header_system) == 0 || !proxy_header_start_time_ms || Z_TYPE_P(proxy_header_start_time_ms) != IS_STRING || Z_STRLEN_P(proxy_header_start_time_ms) == 0) { - return; +ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { + zval *proxy_header_system = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY")); + if (!proxy_header_system) { + proxy_header_system = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy")); + } + zval *proxy_header_start_time_ms = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_REQUEST_TIME_MS")); + if (!proxy_header_start_time_ms) { + proxy_header_start_time_ms = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-request-time-ms")); } - zval *proxy_header_path = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_PATH")); - zval *proxy_header_http_method = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_HTTPMETHOD")); - zval *proxy_header_domain = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_DOMAIN_NAME")); - zval *proxy_header_stage = zend_hash_str_find(server, ZEND_STRL("HTTP_X_DD_PROXY_STAGE")); + if (!proxy_header_system || Z_TYPE_P(proxy_header_system) != IS_STRING || Z_STRLEN_P(proxy_header_system) == 0 || !proxy_header_start_time_ms || Z_TYPE_P(proxy_header_start_time_ms) != IS_STRING || Z_STRLEN_P(proxy_header_start_time_ms) == 0) { + return NULL; + } + zval *proxy_header_path = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_PATH")); + if (!proxy_header_path) { + proxy_header_path = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-path")); + } + zval *proxy_header_http_method = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_HTTPMETHOD")); + if (!proxy_header_http_method) { + proxy_header_http_method = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-httpmethod")); + } + zval *proxy_header_domain = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_DOMAIN_NAME")); + if (!proxy_header_domain) { + proxy_header_domain = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-domain-name")); + } + zval *proxy_header_stage = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_STAGE")); + if (!proxy_header_stage) { + proxy_header_stage = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-stage")); + } - ddtrace_push_inferred_root_span(); - ddtrace_root_span_data *rsd = DDTRACE_G(active_stack)->root_span; - ddtrace_span_data *span = &rsd->span; - rsd->is_inferred_span = true; + ddtrace_span_data *span = ddtrace_push_inferred_root_span(); zval *prop_name = &span->property_name; zval_ptr_dtor(prop_name); @@ -887,5 +904,13 @@ void ddtrace_infer_proxy_services(void) { zend_hash_str_add_new(meta, ZEND_STRL("stage"), &stage); } + ddtrace_root_span_data *rsd = ROOTSPANDATA(&span->std); LOG(DEBUG, "Inferred trace_id=%s, span_id=%" PRIu64 " from HTTP_X_DD_PROXY header", Z_STRVAL(rsd->property_trace_id), rsd->span.span_id); + + return rsd; +} + +void ddtrace_infer_proxy_services(void) { + zend_array *server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); + ddtrace_open_inferred_span(server); } diff --git a/ext/span.h b/ext/span.h index 1eff0a7608..a3e6101f41 100644 --- a/ext/span.h +++ b/ext/span.h @@ -214,7 +214,7 @@ ddtrace_span_data *ddtrace_init_dummy_span(void); ddtrace_span_stack *ddtrace_init_span_stack(void); ddtrace_span_stack *ddtrace_init_root_span_stack(void); void ddtrace_push_root_span(void); -void ddtrace_push_inferred_root_span(void); +ddtrace_span_data *ddtrace_push_inferred_root_span(void); ddtrace_span_data *ddtrace_active_span(void); static inline ddtrace_span_properties *ddtrace_active_span_props(void) { @@ -245,6 +245,7 @@ zend_string *ddtrace_span_id_as_string(uint64_t id); zend_string *ddtrace_trace_id_as_string(ddtrace_trace_id id); zend_string *ddtrace_span_id_as_hex_string(uint64_t id); zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id); +ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers); void ddtrace_infer_proxy_services(void); bool ddtrace_span_alter_root_span_config(zval *old_value, zval *new_value, zend_string *new_str); diff --git a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php index 06a01d2256..6af30f97a8 100644 --- a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php +++ b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php @@ -4,6 +4,7 @@ use DDTrace\HookData; use DDTrace\Integrations\Integration; +use DDTrace\Log\Logger; use DDTrace\SpanStack; use DDTrace\Tag; use DDTrace\Type; @@ -14,6 +15,7 @@ use function DDTrace\consume_distributed_tracing_headers; use function DDTrace\extract_ip_from_headers; use function DDTrace\Internal\handle_fork; +use function DDTrace\set_distributed_tracing_context; class SwooleIntegration extends Integration { @@ -34,7 +36,20 @@ public function instrumentRequestStart(callable $callback, SwooleIntegration $in \DDTrace\install_hook( $callback, function (HookData $hook) use ($integration, $server, $scheme) { - $rootSpan = $hook->span(new SpanStack()); + $args = $hook->args; + /** @var Request $request */ + $request = $args[0]; + + $inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED'); + $inferredSpan = null; + if ($inferredProxyServicesEnabled) { + $inferredSpan = \DDTrace\start_inferred_span($request->header); + Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no")); + } + $hook->data['inferredSpan'] = $inferredSpan; + + $rootSpan = $hook->span($inferredSpan ?: new SpanStack()); + Logger::get()->debug("Root span: " . var_export($rootSpan, true)); $rootSpan->name = "web.request"; $rootSpan->service = \ddtrace_config_app_name('swoole'); $rootSpan->type = Type::WEB_SERVLET; @@ -42,10 +57,6 @@ function (HookData $hook) use ($integration, $server, $scheme) { $rootSpan->meta[Tag::SPAN_KIND] = Tag::SPAN_KIND_VALUE_SERVER; $integration->addTraceAnalyticsIfEnabled($rootSpan); - $args = $hook->args; - /** @var Request $request */ - $request = $args[0]; - $headers = []; $allowedHeaders = \dd_trace_env_config('DD_TRACE_HEADER_TAGS'); foreach ($request->header as $name => $value) { @@ -102,6 +113,18 @@ function (HookData $hook) use ($integration, $server, $scheme) { $rootSpan->meta[Tag::HTTP_URL] = Normalizer::uriNormalizeincomingPath($url); unset($rootSpan->meta['closure.declaration']); + }, + function (HookData $hook) { + $inferredSpan = $hook->data['inferredSpan']; + if ($inferredSpan) { + Logger::get()->debug("Closing inferred span"); + $autofinishConfig = ini_get('datadog.autofinish_spans'); + ini_set('datadog.autofinish_spans', 'true'); + dd_trace_close_all_spans_and_flush(); + //dd_trace_synchronous_flush(1); + //set_distributed_tracing_context("0", "0"); + ini_set('datadog.autofinish_spans', $autofinishConfig); + } } ); } From cf65501ee114ff75645a135aaa7c637a509f8f3a Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 17 Feb 2025 09:57:04 +0100 Subject: [PATCH 15/46] style: Refactor using DDTRACE_INFERRED_SPAN type --- ext/ddtrace.c | 13 +++++-------- ext/handlers_curl.c | 2 +- ext/handlers_curl_php7.c | 2 +- ext/serializer.c | 8 ++++---- ext/serializer.h | 2 +- ext/span.c | 19 ++++++++----------- ext/span.h | 6 +++--- 7 files changed, 23 insertions(+), 29 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index c070f113b5..c38f65087d 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -381,12 +381,9 @@ static inline void dd_alter_prop_common(size_t prop_offset, zval *old_value, zva while (pspan) { if (skip_inferred) { ddtrace_span_data *span = SPANDATA(pspan); - if (span && span->type == DDTRACE_AUTOROOT_SPAN) { - ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - if (root->is_inferred_span) { - pspan = pspan->parent; // It should be NULL, but just in case... - continue; - } + if (span && span->type == DDTRACE_INFERRED_SPAN) { + pspan = pspan->parent; // It should be NULL, but just in case... + continue; } } @@ -2725,7 +2722,7 @@ PHP_FUNCTION(DDTrace_root_span) { } dd_ensure_root_span(); ddtrace_root_span_data *span = DDTRACE_G(active_stack)->root_span; - if (span && span->is_inferred_span) { + if (span && span->type == DDTRACE_INFERRED_SPAN) { span = span->child_root; } @@ -2745,7 +2742,7 @@ static inline void dd_start_span(INTERNAL_FUNCTION_PARAMETERS) { ddtrace_span_data *span; if (get_DD_TRACE_ENABLED()) { - span = ddtrace_open_span(DDTRACE_USER_SPAN, false); + span = ddtrace_open_span(DDTRACE_USER_SPAN); } else { span = ddtrace_init_dummy_span(); } diff --git a/ext/handlers_curl.c b/ext/handlers_curl.c index 716847cea7..366011f905 100644 --- a/ext/handlers_curl.c +++ b/ext/handlers_curl.c @@ -136,7 +136,7 @@ static void dd_multi_inject_headers(zend_object *mh) { zend_object *ch; ZEND_HASH_FOREACH_PTR(handles, ch) { if (DDTRACE_G(curl_multi_injecting_spans) && Z_TYPE(DDTRACE_G(curl_multi_injecting_spans)->val) == IS_ARRAY) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); dd_inject_distributed_tracing_headers(ch); ddtrace_close_span(span); span->duration = 1; diff --git a/ext/handlers_curl_php7.c b/ext/handlers_curl_php7.c index 8af6a433fc..bb2d9dcc71 100644 --- a/ext/handlers_curl_php7.c +++ b/ext/handlers_curl_php7.c @@ -159,7 +159,7 @@ static int dd_inject_distributed_tracing_headers(zval *ch) { static int dd_inject_distributed_tracing_headers_multi(zval *ch) { if (DDTRACE_G(curl_multi_injecting_spans) && Z_TYPE(DDTRACE_G(curl_multi_injecting_spans)->val) == IS_ARRAY) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); int ret = dd_inject_distributed_tracing_headers(ch); ddtrace_close_span(span); span->duration = 1; diff --git a/ext/serializer.c b/ext/serializer.c index 667ae03dbc..0a3b136201 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -679,7 +679,7 @@ static void dd_set_entrypoint_root_span_props(struct superglob_equiv *data, ddtr void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data *parent) { ddtrace_root_span_data *root = span->stack->root_span; - if (&root->span != parent || !root->is_inferred_span) { + if (&root->span != parent || root->type != DDTRACE_INFERRED_SPAN) { zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_COPY(prop_service, &parent->property_service); @@ -762,7 +762,7 @@ void dd_set_entrypoint_root_span_props_from_globals(ddtrace_root_span_data *span dd_set_entrypoint_root_span_props(&data, span); } -void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_inferred) { +void ddtrace_set_root_span_properties(ddtrace_root_span_data *span) { ddtrace_update_root_id_properties(span); span->sampling_rule.rule = INT32_MAX; @@ -784,7 +784,7 @@ void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_infe ZVAL_STR(&zv, encoded_id); zend_hash_str_add_new(meta, ZEND_STRL("runtime-id"), &zv); - if (ddtrace_span_is_entrypoint_root(&span->span) && !is_inferred) { + if (ddtrace_span_is_entrypoint_root(&span->span) && span->type != DDTRACE_INFERRED_SPAN) { dd_set_entrypoint_root_span_props_from_globals(span); } @@ -1194,7 +1194,7 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv ddtrace_exception_to_meta(Z_OBJ_P(exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); } else if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - if (root->is_inferred_span && root->child_root) { + if (root->child_root) { // Can't check for DDTRACE_INFERRED_SPAN because the span is now closed zval *child_exception_zv = &root->child_root->span.property_exception; has_exception = Z_TYPE_P(child_exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(child_exception_zv), zend_ce_throwable); if (has_exception) { diff --git a/ext/serializer.h b/ext/serializer.h index 29697e123a..58a64d0005 100644 --- a/ext/serializer.h +++ b/ext/serializer.h @@ -12,7 +12,7 @@ void ddtrace_serialize_span_to_array(ddtrace_span_data *span, zval *array); void ddtrace_save_active_error_to_metadata(void); void ddtrace_set_global_span_properties(ddtrace_span_data *span); void dd_set_entrypoint_root_span_props_from_globals(ddtrace_root_span_data *span); -void ddtrace_set_root_span_properties(ddtrace_root_span_data *span, bool is_inferred); +void ddtrace_set_root_span_properties(ddtrace_root_span_data *span); void ddtrace_update_root_id_properties(ddtrace_root_span_data *span); void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data *parent); zend_string *ddtrace_default_service_name(void); diff --git a/ext/span.c b/ext/span.c index fba6050189..da5ceb0fad 100644 --- a/ext/span.c +++ b/ext/span.c @@ -150,7 +150,7 @@ uint64_t ddtrace_nanoseconds_realtime(void) { return ts.tv_sec * ZEND_NANO_IN_SEC + ts.tv_nsec; } -ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inferred) { +ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { ddtrace_span_stack *stack = DDTRACE_G(active_stack); // The primary stack is ancestor to all stacks, which signifies that any root spans created on top of it will inherit the distributed tracing context bool primary_stack = stack->parent_stack == NULL; @@ -165,9 +165,8 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inf // ensure dtor can be called again GC_DEL_FLAGS(&stack->std, IS_OBJ_DESTRUCTOR_CALLED); - bool child_of_inferred_span = DDTRACE_G(active_stack)->root_span != NULL - && DDTRACE_G(active_stack)->root_span->is_inferred_span - && DDTRACE_G(active_stack)->root_span->child_root == NULL; + ddtrace_root_span_data *rsd = DDTRACE_G(active_stack)->root_span; + bool child_of_inferred_span = rsd != NULL && rsd->type == DDTRACE_INFERRED_SPAN && rsd->child_root == NULL; bool root_span = DDTRACE_G(active_stack)->root_span == NULL; ddtrace_span_data *span = ddtrace_init_span(type, (root_span || child_of_inferred_span) ? ddtrace_ce_root_span_data : ddtrace_ce_span_data); @@ -206,7 +205,7 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inf ZVAL_NULL(&span->property_parent); span->parent = NULL; - ddtrace_set_root_span_properties(root, is_inferred); + ddtrace_set_root_span_properties(root); } else if (child_of_inferred_span) { span->is_child_of_inferred_span = true; ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); @@ -259,7 +258,7 @@ ddtrace_span_data *ddtrace_alloc_execute_data_span(zend_ulong index, zend_execut span = Z_PTR_P(span_zv); Z_TYPE_INFO_P(span_zv) += 2; } else { - span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN, false); + span = ddtrace_open_span(DDTRACE_INTERNAL_SPAN); // SpanData::$name defaults to fully qualified called name zval *prop_name = &span->property_name; @@ -392,17 +391,15 @@ ddtrace_span_stack *ddtrace_init_span_stack(void) { } void ddtrace_push_root_span(void) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN, false); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN); // We opened the span, but are not going to hold a reference to it directly - the stack will manage it. GC_DELREF(&span->std); } ddtrace_span_data *ddtrace_push_inferred_root_span(void) { - ddtrace_span_data *span = ddtrace_open_span(DDTRACE_AUTOROOT_SPAN, true); + ddtrace_span_data *span = ddtrace_open_span(DDTRACE_INFERRED_SPAN); // We opened the span, but are not going to hold a reference to it directly - the stack will manage it. GC_DELREF(&span->std); - ddtrace_root_span_data *rsd = ROOTSPANDATA(&span->std); - rsd->is_inferred_span = true; return span; } @@ -690,7 +687,7 @@ void ddtrace_close_all_open_spans(bool force_close_root_span) { ddtrace_span_data *span; while (stack->active && (span = SPANDATA(stack->active))->stack == stack) { LOG(DEBUG, "Automatically finishing the next span (in shutdown or force flush requested)"); - if (get_DD_AUTOFINISH_SPANS() || (force_close_root_span && span->type == DDTRACE_AUTOROOT_SPAN)) { + if (get_DD_AUTOFINISH_SPANS() || (force_close_root_span && (span->type == DDTRACE_AUTOROOT_SPAN || span->type == DDTRACE_INFERRED_SPAN))) { dd_trace_stop_span_time(span); ddtrace_close_span(span); } else { diff --git a/ext/span.h b/ext/span.h index a3e6101f41..2136829c7b 100644 --- a/ext/span.h +++ b/ext/span.h @@ -23,6 +23,7 @@ enum ddtrace_span_dataype { DDTRACE_INTERNAL_SPAN, DDTRACE_USER_SPAN, DDTRACE_AUTOROOT_SPAN, + DDTRACE_INFERRED_SPAN, DDTRACE_SPAN_CLOSED, }; @@ -108,8 +109,7 @@ struct ddtrace_root_span_data { ddtrace_rule_result sampling_rule; bool explicit_sampling_priority; enum ddtrace_trace_limited trace_is_limited; - bool is_inferred_span; - struct ddtrace_root_span_data *child_root; // Only used when inferring proxy services + struct ddtrace_root_span_data *child_root; // Only used when inferring proxy services (type: DDTRACE_INFERRED_SPAN) union { ddtrace_span_data; @@ -209,7 +209,7 @@ void ddtrace_init_span_stacks(void); void ddtrace_free_span_stacks(bool silent); void ddtrace_switch_span_stack(ddtrace_span_stack *target_stack); -ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type, bool is_inferred); +ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type); ddtrace_span_data *ddtrace_init_dummy_span(void); ddtrace_span_stack *ddtrace_init_span_stack(void); ddtrace_span_stack *ddtrace_init_root_span_stack(void); From a1c525a7ffdb2cf4ded3cd7ffe263ec7aecbde9f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 17 Feb 2025 09:57:20 +0100 Subject: [PATCH 16/46] tests: Add some (unfinished) tests --- .../Integrations/Swoole/SwooleIntegration.php | 2 +- .../Laravel/Latest/InferredProxyTest.php | 3 + .../Octane/Latest/InferredProxyTest.php | 103 ++++++++ tests/ext/inferred_proxy/alter_service.phpt | 143 +++++++++++ tests/ext/inferred_proxy/basic_test.phpt | 13 +- .../ext/inferred_proxy/error_propagated.phpt | 141 +++++++++++ ...ferred_proxy_test.test_inferred_proxy.json | 236 ++++++++++++++++++ 7 files changed, 638 insertions(+), 3 deletions(-) create mode 100644 tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php create mode 100644 tests/ext/inferred_proxy/alter_service.phpt create mode 100644 tests/ext/inferred_proxy/error_propagated.phpt create mode 100644 tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json diff --git a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php index 6af30f97a8..28994a006e 100644 --- a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php +++ b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php @@ -49,7 +49,7 @@ function (HookData $hook) use ($integration, $server, $scheme) { $hook->data['inferredSpan'] = $inferredSpan; $rootSpan = $hook->span($inferredSpan ?: new SpanStack()); - Logger::get()->debug("Root span: " . var_export($rootSpan, true)); + Logger::get()->debug("Created root span"); $rootSpan->name = "web.request"; $rootSpan->service = \ddtrace_config_app_name('swoole'); $rootSpan->type = Type::WEB_SERVLET; diff --git a/tests/Integrations/Laravel/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Latest/InferredProxyTest.php index c970b12dfd..fd21b51f22 100644 --- a/tests/Integrations/Laravel/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Latest/InferredProxyTest.php @@ -20,11 +20,14 @@ protected static function getEnvs() 'DD_ENV' => 'local-test', 'DD_VERSION' => '1.0', 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + //'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', ]); } public function testInferredProxy() { + self::putEnvAndReloadConfig(['DD_SERVICE=my_service']); + $this->tracesFromWebRequestSnapshot(function () { $this->call( GetSpec::create( diff --git a/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php new file mode 100644 index 0000000000..348bf8e024 --- /dev/null +++ b/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php @@ -0,0 +1,103 @@ + 'laravel_test_app', + 'DD_SERVICE' => 'swoole_test_app', + 'DD_TRACE_CLI_ENABLED' => 'true', + 'PHP_INI_SCAN_DIR' => ':' . dirname(self::getAppIndexScript()), + 'DD_ENV' => 'local-test', + 'DD_VERSION' => '1.0', + 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + 'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', + ]); + } + + public function testInferredProxy() + { + $until = function ($request) { + $body = $request["body"] ?? []; + $traces = empty($body) ? [[]] : json_decode($body, true); + + foreach ($traces as $trace) { + foreach ($trace as $span) { + if ($span + && isset($span["name"]) + && $span["name"] === "laravel.request" + && (str_contains($span["resource"], 'App\\Http\\Controllers') || $span["resource"] === 'GET /does_not_exist') + ) { + return true; + } + } + } + + return false; + }; + + $traces = $this->tracesFromWebRequest(function () { + $this->call( + GetSpec::create( + 'A simple GET request returning a string', + '/simple?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }, null, $until); + + $apigwTrace = null; + foreach ($traces as $trace) { + if ($trace[0]["name"] === "aws-apigateway") { + $apigwTrace = $trace; + break; + } + } + + echo json_encode($apigwTrace, JSON_PRETTY_PRINT); + + $this->snapshotFromTraces([$apigwTrace]); + } +} \ No newline at end of file diff --git a/tests/ext/inferred_proxy/alter_service.phpt b/tests/ext/inferred_proxy/alter_service.phpt new file mode 100644 index 0000000000..d3defffe3e --- /dev/null +++ b/tests/ext/inferred_proxy/alter_service.phpt @@ -0,0 +1,143 @@ +--TEST-- +Inferred span's service shouldn't change on ini_change of datadog.service +--ENV-- +DD_TRACE_AUTO_FLUSH_ENABLED=0 +DD_TRACE_GENERATE_ROOT_SPAN=0 +DD_AUTOFINISH_SPANS=1 +DD_SERVICE=aws-server +DD_ENV=local-prod +DD_VERSION=1.0 + +DD_TRACE_DEBUG=1 + +DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 +HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 +HTTP_X_DD_PROXY_PATH=/test +HTTP_X_DD_PROXY_HTTPMETHOD=GET +HTTP_X_DD_PROXY_DOMAIN_NAME=example.com +HTTP_X_DD_PROXY_STAGE=aws-prod + +METHOD=GET +SERVER_NAME=localhost:8888 +SCRIPT_NAME=/foo.php +REQUEST_URI=/foo + +DD_AGENT_HOST=request-replayer +DD_TRACE_AGENT_PORT=80 +DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=1 +DD_TRACE_AGENT_FLUSH_INTERVAL=666 +DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 + +DD_TRACE_DEBUG_PRNG_SEED=42 +--GET-- +foo=bar +--FILE-- + "localhost", + "accept" => "*/*", + "x-dd-proxy" => "aws-apigateway", + "x-dd-proxy-request-time-ms" => "1739261376000", + "x-dd-proxy-path" => "/test", + "x-dd-proxy-httpmethod" => "GET", + "x-dd-proxy-domain-name" => "example.com", + "x-dd-proxy-stage" => "aws-prod", + "x-datadog-sampling-priority" => "1", + "x-datadog-tags" => "_dd.p.tid=67adbd8500000000,_dd.p.dm=-0", + "x-datadog-trace-id" => "3094185682341082955", + "x-datadog-parent-id" => "3094185682341082955", + "traceparent" => "00-67adbd85000000002af0c17c010a374b-2af0c17c010a374b-01", + "tracestate" => "dd=p:2af0c17c010a374b;t.dm:-0" +]; + +ini_set('datadog.service', 'my_service'); + + +$parent = \DDTrace\start_span(0.120); +$span = \DDTrace\start_span(0.130); +$span->name = "child"; + +dd_trace_close_all_spans_and_flush(); // Simulates end of request + +$body = json_decode($rr->waitForDataAndReplay()["body"], true); +echo json_encode($body, JSON_PRETTY_PRINT); +?> +--EXPECTF-- +[ + [ + { + "trace_id": "13930160852258120406", + "span_id": "13930160852258120406", + "start": 100000000, + "duration": %d, + "name": "aws-apigateway", + "resource": "GET \/test", + "service": "example.com", + "type": "web", + "meta": { + "runtime-id": "%s", + "component": "aws-apigateway", + "http.method": "GET", + "http.url": "example.com\/test", + "stage": "aws-prod", + "_dd.p.dm": "-0", + "env": "local-prod", + "version": "1.0", + "http.status_code": "200", + "_dd.p.tid": "%s" + }, + "metrics": { + "process_id": %d, + "_dd.agent_psr": 1, + "_sampling_priority_v1": 1, + "php.compilation.total_time_ms": %f, + "php.memory.peak_usage_bytes": %d, + "php.memory.peak_real_usage_bytes": %d + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "11788048577503494824", + "parent_id": "13930160852258120406", + "start": 120000000, + "duration": %d, + "name": "web.request", + "resource": "GET \/foo", + "service": "my_service", + "type": "web", + "meta": { + "http.url": "http:\/\/localhost:8888\/foo", + "http.method": "GET", + "env": "local-prod", + "version": "1.0", + "_dd.p.tid": "%s", + "_dd.base_service": "example.com" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "13874630024467741450", + "parent_id": "11788048577503494824", + "start": 130000000, + "duration": %d, + "name": "child", + "resource": "child", + "service": "my_service", + "type": "web", + "meta": { + "env": "local-prod", + "version": "1.0", + "_dd.base_service": "example.com" + } + } + ] +] \ No newline at end of file diff --git a/tests/ext/inferred_proxy/basic_test.phpt b/tests/ext/inferred_proxy/basic_test.phpt index 84271322d5..6ec776ce6a 100644 --- a/tests/ext/inferred_proxy/basic_test.phpt +++ b/tests/ext/inferred_proxy/basic_test.phpt @@ -8,7 +8,7 @@ DD_SERVICE=aws-server DD_ENV=local-prod DD_VERSION=1.0 -DD_TRACE_DEBUG=0 +DD_TRACE_DEBUG=1 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 HTTP_X_DD_PROXY=aws-apigateway @@ -68,7 +68,16 @@ try { dd_trace_close_all_spans_and_flush(); // Simulates end of request -echo json_encode(json_decode($rr->waitForDataAndReplay()["body"]), JSON_PRETTY_PRINT); +$body = json_decode($rr->waitForDataAndReplay()["body"], true); +echo json_encode($body, JSON_PRETTY_PRINT); + +$apiGwSpanDuration = $body[0][0]['duration']; +$apiGwSpanStart = $body[0][0]['start']; +$webRequestSpanDuration = $body[0][1]['duration']; +$webRequestSpanStart = $body[0][1]['start']; + +echo "API GW End: " . ($apiGwSpanStart + $apiGwSpanDuration) . PHP_EOL; +echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PHP_EOL; //$span = dd_trace_serialize_closed_spans(); diff --git a/tests/ext/inferred_proxy/error_propagated.phpt b/tests/ext/inferred_proxy/error_propagated.phpt new file mode 100644 index 0000000000..96703ed37c --- /dev/null +++ b/tests/ext/inferred_proxy/error_propagated.phpt @@ -0,0 +1,141 @@ +--TEST-- +Should create parent and child spans for error +--ENV-- +DD_TRACE_AUTO_FLUSH_ENABLED=0 +DD_TRACE_GENERATE_ROOT_SPAN=0 +DD_AUTOFINISH_SPANS=1 +DD_SERVICE=aws-server +DD_ENV=local-prod +DD_VERSION=1.0 + +DD_TRACE_DEBUG=0 + +DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 +HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 +HTTP_X_DD_PROXY_PATH=/test +HTTP_X_DD_PROXY_HTTPMETHOD=GET +HTTP_X_DD_PROXY_DOMAIN_NAME=example.com +HTTP_X_DD_PROXY_STAGE=aws-prod + +METHOD=GET +SERVER_NAME=localhost:8888 +SCRIPT_NAME=/foo.php +REQUEST_URI=/foo + +DD_AGENT_HOST=request-replayer +DD_TRACE_AGENT_PORT=80 +DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=1 +DD_TRACE_AGENT_FLUSH_INTERVAL=666 +DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 + +DD_TRACE_DEBUG_PRNG_SEED=42 +--GET-- +foo=bar +--FILE-- +name = 'request'; +}); + +try { + oops(); +} catch (\Exception $e) { + // +} + +dd_trace_close_all_spans_and_flush(); // Simulates end of request + +$body = json_decode($rr->waitForDataAndReplay()["body"], true); +echo json_encode($body, JSON_PRETTY_PRINT); +/* + +$apiGwSpanDuration = $body[0][0]['duration']; +$apiGwSpanStart = $body[0][0]['start']; +$webRequestSpanDuration = $body[0][1]['duration']; +$webRequestSpanStart = $body[0][1]['start']; + +echo "API GW End: " . ($apiGwSpanStart + $apiGwSpanDuration) . PHP_EOL; +echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PHP_EOL; +*/ + +//$span = dd_trace_serialize_closed_spans(); + +//echo json_encode($span, JSON_PRETTY_PRINT); +?> +--EXPECTF-- +[ + [ + { + "trace_id": "13930160852258120406", + "span_id": "13930160852258120406", + "start": 100000000, + "duration": %d, + "name": "aws-apigateway", + "resource": "GET \/test", + "service": "example.com", + "type": "web", + "error": 1, + "meta": { + "runtime-id": "%s", + "component": "aws-apigateway", + "http.method": "GET", + "http.url": "example.com\/test", + "stage": "aws-prod", + "_dd.p.dm": "-0", + "env": "local-prod", + "version": "1.0", + "error.message": "Uncaught Exception (500): An exception occurred in %s\/build_extension\/tests\/ext\/inferred_proxy\/error_propagated.php:10", + "error.type": "Exception", + "error.stack": "#0 %s\/tmp\/build_extension\/tests\/ext\/inferred_proxy\/error_propagated.php(18): oops()\n#1 {main}", + "http.status_code": "500", + "_dd.p.tid": "%s" + }, + "metrics": { + "process_id": %d, + "_dd.agent_psr": 1, + "_sampling_priority_v1": 1, + "php.compilation.total_time_ms": %f, + "php.memory.peak_usage_bytes": %d, + "php.memory.peak_real_usage_bytes": %d + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "11788048577503494824", + "parent_id": "13930160852258120406", + "start": %d, + "duration": %d, + "name": "request", + "resource": "GET \/foo", + "service": "aws-server", + "type": "web", + "error": 1, + "meta": { + "http.url": "http:\/\/localhost:8888\/foo", + "http.method": "GET", + "env": "local-prod", + "version": "1.0", + "error.message": "Uncaught Exception (500): An exception occurred in %s\/tmp\/build_extension\/tests\/ext\/inferred_proxy\/error_propagated.php:10", + "error.type": "Exception", + "error.stack": "#0 %s\/tmp\/build_extension\/tests\/ext\/inferred_proxy\/error_propagated.php(18): oops()\n#1 {main}", + "_dd.p.tid": "%s", + "_dd.base_service": "example.com" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + } + ] +] \ No newline at end of file diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..fd94e869f4 --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,236 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 17440839222013114325, + "type": "cli", + "meta": { + "_dd.p.dm": "0", + "_dd.p.tid": "67adcf7300000000", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.url": "example.com/test", + "runtime-id": "0e02b65c-52ad-4004-a371-b09b917f7115", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.request", + "service": "swoole_test_app", + "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67adcf7300000000", + "component": "laravel", + "env": "local-test", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.route": "simple", + "http.status_code": "200", + "http.url": "http://localhost/simple?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", + "laravel.route.name": "simple_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestReceived", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "swoole_test_app", + "resource": "simple", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestTerminated", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] From bd91a710dc79c2f761a091cee078f6cb0394ee3c Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 17 Feb 2025 11:22:23 +0100 Subject: [PATCH 17/46] feat: Very quick Roadrunner support (to be enhanced) --- .../Roadrunner/RoadrunnerIntegration.php | 57 +++++++++++++--- .../Integrations/Swoole/SwooleIntegration.php | 4 +- .../Roadrunner/V2/InferredProxyTest.php | 68 +++++++++++++++++++ ...ferred_proxy_test.test_inferred_proxy.json | 52 ++++++++++++++ 4 files changed, 172 insertions(+), 9 deletions(-) create mode 100644 tests/Integrations/Roadrunner/V2/InferredProxyTest.php create mode 100644 tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json diff --git a/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php b/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php index 27b2b8a0bf..70e3105c5d 100644 --- a/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php +++ b/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php @@ -4,6 +4,7 @@ use DDTrace\HookData; use DDTrace\Integrations\Integration; +use DDTrace\Log\Logger; use DDTrace\Tag; use DDTrace\Type; use DDTrace\Util\Normalizer; @@ -137,15 +138,17 @@ public function init(): int $recCall = 0; \DDTrace\install_hook('Spiral\RoadRunner\Http\HttpWorker::waitRequest', - function () use (&$activeSpan, &$suppressResponse) { + function () use (&$inferredSpan, &$activeSpan, &$suppressResponse) { if ($activeSpan) { \DDTrace\close_spans_until($activeSpan); \DDTrace\close_span(); + dd_trace_close_all_spans_and_flush(); } $activeSpan = null; + $inferredSpan = null; $suppressResponse = null; }, - function (HookData $hook) use (&$activeSpan, &$suppressResponse, $integration, $service, &$recCall) { + function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse, $integration, $service, &$recCall) { /** @var ?\Spiral\RoadRunner\Http\Request $retval */ $retval = $hook->returned; if (!$retval && !$hook->exception) { @@ -155,7 +158,28 @@ function (HookData $hook) use (&$activeSpan, &$suppressResponse, $integration, $ return; } - $activeSpan = \DDTrace\start_trace_span(); + $inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED'); + $inferredSpan = null; + if ($inferredProxyServicesEnabled && $retval && $retval->headers) { + // $retval->headers is an array of arrays, so we need to flatten it + // for instance: "X-Dd-Proxy" -> {0: "aws-apigateway"} + // should become: "x-dd-proxy" -> "aws-apigateway" + $headers = []; + foreach ($retval->headers as $headername => $header) { + $header = implode(", ", $header); // Headers that we are interested in should be single-valued + $headers[strtolower($headername)] = $header; + } + Logger::get()->debug(var_export($headers, true)); + // Convert $retval->headers keys to lowercase + $inferredSpan = \DDTrace\start_inferred_span($headers); + Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no")); + } + $hook->data['inferredSpan'] = $inferredSpan; + + Logger::get()->debug("Starting request span"); + $activeSpan = $inferredSpan ? \DDTrace\start_span() : \DDTrace\start_trace_span(); + Logger::get()->debug("Active Span ID: " . $activeSpan->id); + Logger::get()->debug("Created root span"); $activeSpan->service = $service; $activeSpan->name = "web.request"; @@ -165,8 +189,15 @@ function (HookData $hook) use (&$activeSpan, &$suppressResponse, $integration, $ $integration->addTraceAnalyticsIfEnabled($activeSpan); if ($hook->exception) { $activeSpan->exception = $hook->exception; + if ($inferredSpan) { + $inferredSpan->exception = $hook->exception; + } \DDTrace\close_span(); + if ($inferredSpan) { + dd_trace_close_all_spans_and_flush(); + } $activeSpan = null; + $inferredSpan = null; } else { $headers = []; foreach ($retval->headers as $headername => $header) { @@ -177,14 +208,18 @@ function (HookData $hook) use (&$activeSpan, &$suppressResponse, $integration, $ return $headers[$headername] ?? null; }); - $res = notify_start($activeSpan, RoadrunnerIntegration::build_req_spec($retval), $retval->body); + $res = notify_start($inferredSpan ?: $activeSpan, RoadrunnerIntegration::build_req_spec($retval), $retval->body); if ($res) { // block on start RoadrunnerIntegration::ensure_headers_map_fmt($res['headers']); $this->respond($res['status'], $res['body'] ?? '', $res['headers']); \DDTrace\close_span(); + if ($inferredSpan) { + dd_trace_close_all_spans_and_flush(); + } $activeSpan = null; + $inferredSpan = null; if ($recCall++ > 128) { // too many recursive calls. Exit so that the worker can be restarted @@ -199,7 +234,7 @@ function (HookData $hook) use (&$activeSpan, &$suppressResponse, $integration, $ } else { $thiz = $this; // to support block midrequest - set_blocking_function($activeSpan, + set_blocking_function($inferredSpan ?: $activeSpan, static function ($res) use (&$activeSpan, &$suppressResponse, $thiz) { RoadrunnerIntegration::ensure_headers_map_fmt($res['headers']); $thiz->respond($res['status'], $res['body'] ?? '', $res['headers']); @@ -210,7 +245,7 @@ static function ($res) use (&$activeSpan, &$suppressResponse, $thiz) { } }); - $respondBefore = function (HookData $hook) use (&$activeSpan, &$suppressResponse) { + $respondBefore = function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse) { $hook->disableJitInlining(); if (!$activeSpan || count($hook->args) < 3) { return; @@ -237,7 +272,7 @@ static function ($res) use (&$activeSpan, &$suppressResponse, $thiz) { // send arbitrary addresses. $body = null; } - $blocking = notify_commit($activeSpan, $hook->args[0], $hook->args[2], $body); + $blocking = notify_commit($inferredSpan ?: $activeSpan, $hook->args[0], $hook->args[2], $body); if ($blocking) { $hook->args[0] = $blocking['status']; $hook->args[1] = $blocking['body']; @@ -246,7 +281,7 @@ static function ($res) use (&$activeSpan, &$suppressResponse, $thiz) { } }; - $respondAfter = function (HookData $hook) use (&$activeSpan, &$suppressResponse) { + $respondAfter = function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse) { if (!$activeSpan || count($hook->args) < 3) { return; } @@ -257,8 +292,14 @@ static function ($res) use (&$activeSpan, &$suppressResponse, $thiz) { $activeSpan->meta[Tag::COMPONENT] = RoadrunnerIntegration::NAME; if ($hook->exception && empty($activeSpan->exception)) { $activeSpan->exception = $hook->exception; + if ($inferredSpan) { + $inferredSpan->exception = $hook->exception; + } } elseif ($status >= 500 && $ex = \DDTrace\find_active_exception()) { $activeSpan->exception = $ex; + if ($inferredSpan) { + $inferredSpan->exception = $ex; + } } }; diff --git a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php index 28994a006e..2a11fbb2e1 100644 --- a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php +++ b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php @@ -198,7 +198,9 @@ function ($response, $scope, $args) use ($integration) { && ((int)$rootSpan->meta[Tag::HTTP_STATUS_CODE]) >= 500 && $ex = \DDTrace\find_active_exception() ) { - $rootSpan->exception = $ex; + do { + $rootSpan->exception = $ex; + } while ($rootSpan = $rootSpan->parent); } } ); diff --git a/tests/Integrations/Roadrunner/V2/InferredProxyTest.php b/tests/Integrations/Roadrunner/V2/InferredProxyTest.php new file mode 100644 index 0000000000..25ef111a4e --- /dev/null +++ b/tests/Integrations/Roadrunner/V2/InferredProxyTest.php @@ -0,0 +1,68 @@ + 'roadrunner_test_app', + 'DD_TRACE_CLI_ENABLED' => 'true', + 'DD_ENV' => 'local-test', + 'DD_VERSION' => '1.0', + 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + 'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', + ]); + } + + public function testInferredProxy() + { + $traces = $this->tracesFromWebRequest(function () { + $this->call( + GetSpec::create( + 'A simple GET request returning a string', + '/simple?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); + + echo json_encode($traces, JSON_PRETTY_PRINT); + + $this->snapshotFromTraces($traces); + } +} diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..badf18e041 --- /dev/null +++ b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,52 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /simple", + "trace_id": 0, + "span_id": 1, + "parent_id": 6264193728836627759, + "type": "cli", + "meta": { + "_dd.p.dm": "0", + "_dd.p.tid": "67b30c2d00000000", + "_dd.p.user_id": "42", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.status_code": "200", + "http.url": "http://localhost/simple?key=value&", + "runtime-id": "ace18dbe-38c8-45eb-9a73-142a00010c43", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "web.request", + "service": "roadrunner_test_app", + "resource": "web.request", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b30c2d00000000", + "component": "roadrunner", + "env": "local-test", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }]] From bcc25af0887b2ddb3df5aa91ccc6c3e051edb7e9 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Mon, 17 Feb 2025 11:52:33 +0100 Subject: [PATCH 18/46] Set `_dd.inferred_span` to `1` --- ext/span.c | 2 + ...ferred_proxy_test.test_inferred_proxy.json | 380 ------------------ ...xy_test.test_inferred_proxy_exception.json | 377 ----------------- ...ferred_proxy_test.test_inferred_proxy.json | 236 ----------- ...ferred_proxy_test.test_inferred_proxy.json | 52 --- 5 files changed, 2 insertions(+), 1045 deletions(-) delete mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json delete mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json delete mode 100644 tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json delete mode 100644 tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json diff --git a/ext/span.c b/ext/span.c index da5ceb0fad..3218a11373 100644 --- a/ext/span.c +++ b/ext/span.c @@ -901,6 +901,8 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { zend_hash_str_add_new(meta, ZEND_STRL("stage"), &stage); } + add_assoc_long(&span->property_meta, "_dd.inferred_span", 1); + ddtrace_root_span_data *rsd = ROOTSPANDATA(&span->std); LOG(DEBUG, "Inferred trace_id=%s, span_id=%" PRIu64 " from HTTP_X_DD_PROXY header", Z_STRVAL(rsd->property_trace_id), rsd->span.span_id); diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json deleted file mode 100644 index 54a927b9e3..0000000000 --- a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json +++ /dev/null @@ -1,380 +0,0 @@ -[[ - { - "name": "aws-apigateway", - "service": "example.com", - "resource": "GET /test", - "trace_id": 0, - "span_id": 1, - "parent_id": 6378656277655726371, - "type": "web", - "meta": { - "_dd.p.dm": "-0", - "_dd.p.tid": "67ab0d3a00000000", - "component": "aws-apigateway", - "env": "local-test", - "http.method": "GET", - "http.status_code": "200", - "http.url": "example.com/test", - "runtime-id": "220ddebc-fe8e-4a05-8b4b-418773942fb6", - "stage": "aws-prod", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1.0 - } - }, - { - "name": "laravel.request", - "service": "my_service", - "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", - "trace_id": 0, - "span_id": 2, - "parent_id": 1, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "_dd.p.tid": "67ab0d3a00000000", - "component": "laravel", - "env": "local-test", - "http.method": "GET", - "http.route": "simple", - "http.url": "http://localhost/simple?key=value&", - "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", - "laravel.route.name": "simple_route", - "span.kind": "server", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1.0 - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", - "trace_id": 0, - "span_id": 3, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", - "trace_id": 0, - "span_id": 4, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", - "trace_id": 0, - "span_id": 5, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", - "trace_id": 0, - "span_id": 6, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", - "trace_id": 0, - "span_id": 7, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", - "trace_id": 0, - "span_id": 8, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", - "trace_id": 0, - "span_id": 9, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", - "trace_id": 0, - "span_id": 10, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", - "trace_id": 0, - "span_id": 11, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.provider.load", - "service": "my_service", - "resource": "Illuminate\\Foundation\\ProviderRepository::load", - "trace_id": 0, - "span_id": 12, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", - "trace_id": 0, - "span_id": 13, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", - "trace_id": 0, - "span_id": 14, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", - "trace_id": 0, - "span_id": 15, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\Routing", - "trace_id": 0, - "span_id": 16, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\RouteMatched", - "trace_id": 0, - "span_id": 17, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.action", - "service": "my_service", - "resource": "simple", - "trace_id": 0, - "span_id": 18, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\PreparingResponse", - "trace_id": 0, - "span_id": 19, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", - "trace_id": 0, - "span_id": 20, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\PreparingResponse", - "trace_id": 0, - "span_id": 21, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", - "trace_id": 0, - "span_id": 22, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", - "trace_id": 0, - "span_id": 23, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Foundation\\Events\\Terminating", - "trace_id": 0, - "span_id": 24, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }]] diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json deleted file mode 100644 index 41ce03e68b..0000000000 --- a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json +++ /dev/null @@ -1,377 +0,0 @@ -[[ - { - "name": "aws-apigateway", - "service": "example.com", - "resource": "GET /test", - "trace_id": 0, - "span_id": 1, - "parent_id": 8854955935653512842, - "type": "web", - "error": 1, - "meta": { - "_dd.p.dm": "-0", - "_dd.p.tid": "67ab0d9f00000000", - "component": "aws-apigateway", - "env": "local-test", - "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", - "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", - "error.type": "Exception", - "http.method": "GET", - "http.status_code": "500", - "http.url": "example.com/test", - "runtime-id": "085568b6-4655-412a-b130-6cdeb6d74e9e", - "stage": "aws-prod", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1.0 - } - }, - { - "name": "laravel.request", - "service": "my_service", - "resource": "App\\Http\\Controllers\\CommonSpecsController@error unnamed_route", - "trace_id": 0, - "span_id": 2, - "parent_id": 1, - "type": "web", - "error": 1, - "meta": { - "_dd.base_service": "example.com", - "_dd.p.tid": "67ab0d9f00000000", - "component": "laravel", - "env": "local-test", - "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", - "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", - "error.type": "Exception", - "http.method": "GET", - "http.route": "error", - "http.url": "http://localhost/error?key=value&", - "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@error", - "laravel.route.name": "unnamed_route", - "span.kind": "server", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1.0 - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", - "trace_id": 0, - "span_id": 3, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", - "trace_id": 0, - "span_id": 4, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", - "trace_id": 0, - "span_id": 5, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", - "trace_id": 0, - "span_id": 6, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", - "trace_id": 0, - "span_id": 7, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", - "trace_id": 0, - "span_id": 8, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", - "trace_id": 0, - "span_id": 9, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", - "trace_id": 0, - "span_id": 10, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", - "trace_id": 0, - "span_id": 11, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.provider.load", - "service": "my_service", - "resource": "Illuminate\\Foundation\\ProviderRepository::load", - "trace_id": 0, - "span_id": 12, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", - "trace_id": 0, - "span_id": 13, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", - "trace_id": 0, - "span_id": 14, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", - "trace_id": 0, - "span_id": 15, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\Routing", - "trace_id": 0, - "span_id": 16, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\RouteMatched", - "trace_id": 0, - "span_id": 17, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.action", - "service": "my_service", - "resource": "error", - "trace_id": 0, - "span_id": 18, - "parent_id": 2, - "type": "web", - "error": 1, - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "error.message": "Thrown Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", - "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", - "error.type": "Exception", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Log\\Events\\MessageLogged", - "trace_id": 0, - "span_id": 19, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\PreparingResponse", - "trace_id": 0, - "span_id": 20, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", - "trace_id": 0, - "span_id": 21, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", - "trace_id": 0, - "span_id": 22, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "my_service", - "resource": "Illuminate\\Foundation\\Events\\Terminating", - "trace_id": 0, - "span_id": 23, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }]] diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json deleted file mode 100644 index fd94e869f4..0000000000 --- a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json +++ /dev/null @@ -1,236 +0,0 @@ -[[ - { - "name": "aws-apigateway", - "service": "example.com", - "resource": "GET /test", - "trace_id": 0, - "span_id": 1, - "parent_id": 17440839222013114325, - "type": "cli", - "meta": { - "_dd.p.dm": "0", - "_dd.p.tid": "67adcf7300000000", - "component": "aws-apigateway", - "env": "local-test", - "http.method": "GET", - "http.url": "example.com/test", - "runtime-id": "0e02b65c-52ad-4004-a371-b09b917f7115", - "stage": "aws-prod", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1 - } - }, - { - "name": "laravel.request", - "service": "swoole_test_app", - "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", - "trace_id": 0, - "span_id": 2, - "parent_id": 1, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "_dd.p.tid": "67adcf7300000000", - "component": "laravel", - "env": "local-test", - "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", - "http.request.headers.x-dd-proxy-domain-name": "example.com", - "http.request.headers.x-dd-proxy-httpmethod": "GET", - "http.request.headers.x-dd-proxy-path": "/test", - "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", - "http.request.headers.x-dd-proxy-stage": "aws-prod", - "http.route": "simple", - "http.status_code": "200", - "http.url": "http://localhost/simple?key=value&", - "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", - "laravel.route.name": "simple_route", - "span.kind": "server", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1 - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Laravel\\Octane\\Events\\RequestReceived", - "trace_id": 0, - "span_id": 3, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\Routing", - "trace_id": 0, - "span_id": 4, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\RouteMatched", - "trace_id": 0, - "span_id": 5, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.action", - "service": "swoole_test_app", - "resource": "simple", - "trace_id": 0, - "span_id": 6, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\PreparingResponse", - "trace_id": 0, - "span_id": 7, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", - "trace_id": 0, - "span_id": 8, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\PreparingResponse", - "trace_id": 0, - "span_id": 9, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", - "trace_id": 0, - "span_id": 10, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", - "trace_id": 0, - "span_id": 11, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Laravel\\Octane\\Events\\RequestHandled", - "trace_id": 0, - "span_id": 12, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Illuminate\\Foundation\\Events\\Terminating", - "trace_id": 0, - "span_id": 13, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }, - { - "name": "laravel.event.handle", - "service": "swoole_test_app", - "resource": "Laravel\\Octane\\Events\\RequestTerminated", - "trace_id": 0, - "span_id": 14, - "parent_id": 2, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "component": "laravel", - "env": "local-test", - "version": "1.0" - } - }]] diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json deleted file mode 100644 index badf18e041..0000000000 --- a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json +++ /dev/null @@ -1,52 +0,0 @@ -[[ - { - "name": "aws-apigateway", - "service": "example.com", - "resource": "GET /simple", - "trace_id": 0, - "span_id": 1, - "parent_id": 6264193728836627759, - "type": "cli", - "meta": { - "_dd.p.dm": "0", - "_dd.p.tid": "67b30c2d00000000", - "_dd.p.user_id": "42", - "component": "aws-apigateway", - "env": "local-test", - "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", - "http.request.headers.x-dd-proxy-domain-name": "example.com", - "http.request.headers.x-dd-proxy-httpmethod": "GET", - "http.request.headers.x-dd-proxy-path": "/test", - "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", - "http.request.headers.x-dd-proxy-stage": "aws-prod", - "http.status_code": "200", - "http.url": "http://localhost/simple?key=value&", - "runtime-id": "ace18dbe-38c8-45eb-9a73-142a00010c43", - "stage": "aws-prod", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1 - } - }, - { - "name": "web.request", - "service": "roadrunner_test_app", - "resource": "web.request", - "trace_id": 0, - "span_id": 2, - "parent_id": 1, - "type": "web", - "meta": { - "_dd.base_service": "example.com", - "_dd.p.tid": "67b30c2d00000000", - "component": "roadrunner", - "env": "local-test", - "span.kind": "server", - "version": "1.0" - }, - "metrics": { - "_sampling_priority_v1": 1 - } - }]] From d4b274576628ed3e4e6d9185f70ab46224eae8be Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 09:35:09 +0100 Subject: [PATCH 19/46] tests: Clean EXPECTF section --- tests/ext/inferred_proxy/alter_service.phpt | 23 ++---------- tests/ext/inferred_proxy/basic_test.phpt | 36 ++----------------- .../ext/inferred_proxy/error_propagated.phpt | 15 +------- 3 files changed, 6 insertions(+), 68 deletions(-) diff --git a/tests/ext/inferred_proxy/alter_service.phpt b/tests/ext/inferred_proxy/alter_service.phpt index d3defffe3e..c4ece2ae00 100644 --- a/tests/ext/inferred_proxy/alter_service.phpt +++ b/tests/ext/inferred_proxy/alter_service.phpt @@ -8,7 +8,7 @@ DD_SERVICE=aws-server DD_ENV=local-prod DD_VERSION=1.0 -DD_TRACE_DEBUG=1 +DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 HTTP_X_DD_PROXY=aws-apigateway @@ -39,25 +39,7 @@ include __DIR__ . '/../includes/request_replayer.inc'; $rr = new RequestReplayer; -$headers = [ - "host" => "localhost", - "accept" => "*/*", - "x-dd-proxy" => "aws-apigateway", - "x-dd-proxy-request-time-ms" => "1739261376000", - "x-dd-proxy-path" => "/test", - "x-dd-proxy-httpmethod" => "GET", - "x-dd-proxy-domain-name" => "example.com", - "x-dd-proxy-stage" => "aws-prod", - "x-datadog-sampling-priority" => "1", - "x-datadog-tags" => "_dd.p.tid=67adbd8500000000,_dd.p.dm=-0", - "x-datadog-trace-id" => "3094185682341082955", - "x-datadog-parent-id" => "3094185682341082955", - "traceparent" => "00-67adbd85000000002af0c17c010a374b-2af0c17c010a374b-01", - "tracestate" => "dd=p:2af0c17c010a374b;t.dm:-0" -]; - -ini_set('datadog.service', 'my_service'); - +ini_set('datadog.service', 'my_service'); // Changes web.request's service $parent = \DDTrace\start_span(0.120); $span = \DDTrace\start_span(0.130); @@ -86,6 +68,7 @@ echo json_encode($body, JSON_PRETTY_PRINT); "http.method": "GET", "http.url": "example.com\/test", "stage": "aws-prod", + "_dd.inferred_span": "1", "_dd.p.dm": "-0", "env": "local-prod", "version": "1.0", diff --git a/tests/ext/inferred_proxy/basic_test.phpt b/tests/ext/inferred_proxy/basic_test.phpt index 6ec776ce6a..5bf0c11c84 100644 --- a/tests/ext/inferred_proxy/basic_test.phpt +++ b/tests/ext/inferred_proxy/basic_test.phpt @@ -8,7 +8,7 @@ DD_SERVICE=aws-server DD_ENV=local-prod DD_VERSION=1.0 -DD_TRACE_DEBUG=1 +DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 HTTP_X_DD_PROXY=aws-apigateway @@ -39,49 +39,16 @@ include __DIR__ . '/../includes/request_replayer.inc'; $rr = new RequestReplayer; - $parent = \DDTrace\start_span(0.120); $span = \DDTrace\start_span(0.130); $span->name = "child"; \DDTrace\root_span()->meta['foo'] = 'bar'; // It MUST set it on $parent -//\DDTrace\close_spans_until(null); - -/* -function oops() -{ - http_response_code(500); - throw new \Exception('An exception occurred'); -} - -\DDTrace\trace_function('oops', function($span) { - $span->name = 'request'; -}); - -try { - oops(); -} catch (\Exception $e) { - // -} -*/ - dd_trace_close_all_spans_and_flush(); // Simulates end of request $body = json_decode($rr->waitForDataAndReplay()["body"], true); echo json_encode($body, JSON_PRETTY_PRINT); - -$apiGwSpanDuration = $body[0][0]['duration']; -$apiGwSpanStart = $body[0][0]['start']; -$webRequestSpanDuration = $body[0][1]['duration']; -$webRequestSpanStart = $body[0][1]['start']; - -echo "API GW End: " . ($apiGwSpanStart + $apiGwSpanDuration) . PHP_EOL; -echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PHP_EOL; - -//$span = dd_trace_serialize_closed_spans(); - -//echo json_encode($span, JSON_PRETTY_PRINT); ?> --EXPECTF-- [ @@ -101,6 +68,7 @@ echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PH "http.method": "GET", "http.url": "example.com\/test", "stage": "aws-prod", + "_dd.inferred_span": "1", "_dd.p.dm": "-0", "env": "local-prod", "version": "1.0", diff --git a/tests/ext/inferred_proxy/error_propagated.phpt b/tests/ext/inferred_proxy/error_propagated.phpt index 96703ed37c..3bf74d7638 100644 --- a/tests/ext/inferred_proxy/error_propagated.phpt +++ b/tests/ext/inferred_proxy/error_propagated.phpt @@ -59,20 +59,6 @@ dd_trace_close_all_spans_and_flush(); // Simulates end of request $body = json_decode($rr->waitForDataAndReplay()["body"], true); echo json_encode($body, JSON_PRETTY_PRINT); -/* - -$apiGwSpanDuration = $body[0][0]['duration']; -$apiGwSpanStart = $body[0][0]['start']; -$webRequestSpanDuration = $body[0][1]['duration']; -$webRequestSpanStart = $body[0][1]['start']; - -echo "API GW End: " . ($apiGwSpanStart + $apiGwSpanDuration) . PHP_EOL; -echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PHP_EOL; -*/ - -//$span = dd_trace_serialize_closed_spans(); - -//echo json_encode($span, JSON_PRETTY_PRINT); ?> --EXPECTF-- [ @@ -93,6 +79,7 @@ echo "Web Request End: " . ($webRequestSpanStart + $webRequestSpanDuration) . PH "http.method": "GET", "http.url": "example.com\/test", "stage": "aws-prod", + "_dd.inferred_span": "1", "_dd.p.dm": "-0", "env": "local-prod", "version": "1.0", From e91cc69f166c1c3e1427a5aec28039f0074d9e46 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 10:00:20 +0100 Subject: [PATCH 20/46] fix: Memory leak --- ext/ddtrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index c38f65087d..bbe5c2f73b 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -403,7 +403,6 @@ static inline void dd_alter_prop_skip_inferred_span(size_t prop_offset, zval *ol } bool ddtrace_alter_dd_service(zval *old_value, zval *new_value, zend_string *new_str) { - LOG(DEBUG, "Altering property service to %s", Z_STRVAL_P(new_value)); if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { dd_alter_prop_skip_inferred_span(XtOffsetOf(ddtrace_span_properties, property_service), old_value, new_value, new_str); } else { @@ -1662,7 +1661,7 @@ static PHP_RINIT_FUNCTION(ddtrace) { ddtrace_autoload_rinit(); #endif } - LOG(DEBUG, "RINIT"); + if (get_DD_TRACE_ENABLED()) { dd_initialize_request(); } From dbd2e661b7507e137a21c1b6e2b5ed52507b5961 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 10:00:30 +0100 Subject: [PATCH 21/46] chore: update snapshots --- ...ferred_proxy_test.test_inferred_proxy.json | 381 ++++++++++++++++++ ...xy_test.test_inferred_proxy_exception.json | 378 +++++++++++++++++ ...ferred_proxy_test.test_inferred_proxy.json | 237 +++++++++++ ...ferred_proxy_test.test_inferred_proxy.json | 52 +++ 4 files changed, 1048 insertions(+) create mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json create mode 100644 tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json create mode 100644 tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json create mode 100644 tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..91785b1915 --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,381 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 13967141473350856149, + "type": "web", + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "-0", + "_dd.p.tid": "67b44b4200000000", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.status_code": "200", + "http.url": "example.com/test", + "runtime-id": "772d7e71-61b8-4883-a140-4d8032617997", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.request", + "service": "my_service", + "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b44b4200000000", + "component": "laravel", + "env": "local-test", + "http.method": "GET", + "http.route": "simple", + "http.url": "http://localhost/simple?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", + "laravel.route.name": "simple_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.provider.load", + "service": "my_service", + "resource": "Illuminate\\Foundation\\ProviderRepository::load", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 15, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 16, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 17, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "my_service", + "resource": "simple", + "trace_id": 0, + "span_id": 18, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 19, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 20, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 21, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 22, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 23, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 24, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json new file mode 100644 index 0000000000..e7b8459d39 --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json @@ -0,0 +1,378 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 6404596600830044292, + "type": "web", + "error": 1, + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "-0", + "_dd.p.tid": "67b44b4800000000", + "component": "aws-apigateway", + "env": "local-test", + "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.status_code": "500", + "http.url": "example.com/test", + "runtime-id": "772d7e71-61b8-4883-a140-4d8032617997", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.request", + "service": "my_service", + "resource": "App\\Http\\Controllers\\CommonSpecsController@error unnamed_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b44b4800000000", + "component": "laravel", + "env": "local-test", + "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.route": "error", + "http.url": "http://localhost/error?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@error", + "laravel.route.name": "unnamed_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1.0 + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\LoadConfiguration", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\HandleExceptions", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterFacades", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.provider.load", + "service": "my_service", + "resource": "Illuminate\\Foundation\\ProviderRepository::load", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\RegisterProviders", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapping: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "bootstrapped: Illuminate\\Foundation\\Bootstrap\\BootProviders", + "trace_id": 0, + "span_id": 15, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 16, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 17, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "my_service", + "resource": "error", + "trace_id": 0, + "span_id": 18, + "parent_id": 2, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "error.message": "Thrown Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1216): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Latest/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest()\n#46 {main}", + "error.type": "Exception", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Log\\Events\\MessageLogged", + "trace_id": 0, + "span_id": 19, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 20, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 21, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 22, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "my_service", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 23, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..1abeb39b1d --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,237 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 7890634735527917160, + "type": "cli", + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "0", + "_dd.p.tid": "67b3143a00000000", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.url": "example.com/test", + "runtime-id": "b1b988b9-d9a6-484e-b839-81a851030087", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.request", + "service": "swoole_test_app", + "resource": "App\\Http\\Controllers\\CommonSpecsController@simple simple_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b3143a00000000", + "component": "laravel", + "env": "local-test", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.route": "simple", + "http.status_code": "200", + "http.url": "http://localhost/simple?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@simple", + "laravel.route.name": "simple_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestReceived", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "swoole_test_app", + "resource": "simple", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestTerminated", + "trace_id": 0, + "span_id": 14, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json new file mode 100644 index 0000000000..6f99117c86 --- /dev/null +++ b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json @@ -0,0 +1,52 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /simple", + "trace_id": 0, + "span_id": 1, + "parent_id": 7314532144854371905, + "type": "cli", + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "0", + "_dd.p.tid": "67b3146c00000000", + "component": "aws-apigateway", + "env": "local-test", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.status_code": "200", + "http.url": "http://localhost/simple?key=value&", + "runtime-id": "5d38703c-4633-4b05-82c1-47529cb93a96", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "web.request", + "service": "roadrunner_test_app", + "resource": "web.request", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b3146c00000000", + "component": "roadrunner", + "env": "local-test", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }]] From 3e1945c9764ff5658c7f7f7d4fc8a3015eebca90 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 10:33:23 +0100 Subject: [PATCH 22/46] tests: Distributed Tracing --- .../inferred_proxy/distributed_tracing.phpt | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 tests/ext/inferred_proxy/distributed_tracing.phpt diff --git a/tests/ext/inferred_proxy/distributed_tracing.phpt b/tests/ext/inferred_proxy/distributed_tracing.phpt new file mode 100644 index 0000000000..228c0f1a44 --- /dev/null +++ b/tests/ext/inferred_proxy/distributed_tracing.phpt @@ -0,0 +1,133 @@ +--TEST-- +Span creation with distributed context +--ENV-- +DD_TRACE_AUTO_FLUSH_ENABLED=0 +DD_TRACE_GENERATE_ROOT_SPAN=0 +DD_AUTOFINISH_SPANS=1 +DD_SERVICE=aws-server +DD_ENV=local-prod +DD_VERSION=1.0 + +DD_TRACE_DEBUG=0 + +DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 +HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 +HTTP_X_DD_PROXY_PATH=/test +HTTP_X_DD_PROXY_HTTPMETHOD=GET +HTTP_X_DD_PROXY_DOMAIN_NAME=example.com +HTTP_X_DD_PROXY_STAGE=aws-prod + +HTTP_X_DATADOG_TRACE_ID=1 +HTTP_X_DATADOG_PARENT_ID=2 +HTTP_X_DATADOG_ORIGIN=rum +HTTP_X_DATADOG_SAMPLING_PRIORITY=2 + +METHOD=GET +SERVER_NAME=localhost:8888 +SCRIPT_NAME=/foo.php +REQUEST_URI=/foo + +DD_AGENT_HOST=request-replayer +DD_TRACE_AGENT_PORT=80 +DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=1 +DD_TRACE_AGENT_FLUSH_INTERVAL=666 +DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 + +DD_TRACE_DEBUG_PRNG_SEED=42 +--GET-- +foo=bar +--FILE-- +name = "child"; + +\DDTrace\root_span()->meta['foo'] = 'bar'; // It MUST set it on $parent + +dd_trace_close_all_spans_and_flush(); // Simulates end of request + +$body = json_decode($rr->waitForDataAndReplay()["body"], true); +echo json_encode($body, JSON_PRETTY_PRINT); +?> +--EXPECTF-- +[ + [ + { + "trace_id": "1", + "span_id": "13930160852258120406", + "parent_id": "2", + "start": 100000000, + "duration": 1739871090843965136, + "name": "aws-apigateway", + "resource": "GET \/test", + "service": "example.com", + "type": "web", + "meta": { + "_dd.p.dm": "-0", + "runtime-id": "32f2b05e-ea2d-4fbd-925e-12a853397695", + "component": "aws-apigateway", + "http.method": "GET", + "http.url": "example.com\/test", + "stage": "aws-prod", + "_dd.inferred_span": "1", + "env": "local-prod", + "version": "1.0", + "http.status_code": "200", + "_dd.origin": "rum" + }, + "metrics": { + "process_id": 82117, + "_sampling_priority_v1": 2, + "php.compilation.total_time_ms": 452.042, + "php.memory.peak_usage_bytes": 824392, + "php.memory.peak_real_usage_bytes": 2097152 + } + }, + { + "trace_id": "1", + "span_id": "11788048577503494824", + "parent_id": "13930160852258120406", + "start": 120000000, + "duration": 300959, + "name": "web.request", + "resource": "GET \/foo", + "service": "aws-server", + "type": "web", + "meta": { + "http.url": "http:\/\/localhost:8888\/foo", + "http.method": "GET", + "foo": "bar", + "env": "local-prod", + "version": "1.0", + "_dd.origin": "rum", + "_dd.base_service": "example.com" + }, + "metrics": { + "_sampling_priority_v1": 2 + } + }, + { + "trace_id": "1", + "span_id": "13874630024467741450", + "parent_id": "11788048577503494824", + "start": 130000000, + "duration": 12042, + "name": "child", + "resource": "child", + "service": "aws-server", + "type": "web", + "meta": { + "env": "local-prod", + "version": "1.0", + "_dd.origin": "rum", + "_dd.base_service": "example.com" + } + } + ] +] \ No newline at end of file From 969ff8bc11ee29b7b6833cdb18c68901d31c71d3 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 10:47:51 +0100 Subject: [PATCH 23/46] tests: Exceptions in Roadrunner/Swoole --- .../Octane/Latest/InferredProxyTest.php | 49 ++++++++++++++- .../Roadrunner/V2/InferredProxyTest.php | 22 ++++++- ...ferred_proxy_test.test_inferred_proxy.json | 8 +-- ...xy_test.test_inferred_proxy_exception.json | 60 +++++++++++++++++++ 4 files changed, 133 insertions(+), 6 deletions(-) create mode 100644 tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json diff --git a/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php index 348bf8e024..a4cc9dce47 100644 --- a/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php @@ -96,7 +96,54 @@ public function testInferredProxy() } } - echo json_encode($apigwTrace, JSON_PRETTY_PRINT); + $this->snapshotFromTraces([$apigwTrace]); + } + + public function testInferredProxyException() + { + $until = function ($request) { + $body = $request["body"] ?? []; + $traces = empty($body) ? [[]] : json_decode($body, true); + + foreach ($traces as $trace) { + foreach ($trace as $span) { + if ($span + && isset($span["name"]) + && $span["name"] === "laravel.request" + && (str_contains($span["resource"], 'App\\Http\\Controllers') || $span["resource"] === 'GET /does_not_exist') + ) { + return true; + } + } + } + + return false; + }; + + $traces = $this->tracesFromWebRequest(function () { + $this->call( + GetSpec::create( + 'A GET throwing an exception', + '/error?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }, null, $until); + + $apigwTrace = null; + foreach ($traces as $trace) { + if ($trace[0]["name"] === "aws-apigateway") { + $apigwTrace = $trace; + break; + } + } $this->snapshotFromTraces([$apigwTrace]); } diff --git a/tests/Integrations/Roadrunner/V2/InferredProxyTest.php b/tests/Integrations/Roadrunner/V2/InferredProxyTest.php index 25ef111a4e..20498a57d0 100644 --- a/tests/Integrations/Roadrunner/V2/InferredProxyTest.php +++ b/tests/Integrations/Roadrunner/V2/InferredProxyTest.php @@ -61,7 +61,27 @@ public function testInferredProxy() ); }); - echo json_encode($traces, JSON_PRETTY_PRINT); + $this->snapshotFromTraces($traces); + } + + public function testInferredProxyException() + { + $traces = $this->tracesFromWebRequest(function () { + $this->call( + GetSpec::create( + 'A GET throwing an exception', + '/error?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); $this->snapshotFromTraces($traces); } diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json index 6f99117c86..89bdb5d971 100644 --- a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json @@ -5,12 +5,12 @@ "resource": "GET /simple", "trace_id": 0, "span_id": 1, - "parent_id": 7314532144854371905, + "parent_id": 7104662190533113224, "type": "cli", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b3146c00000000", + "_dd.p.tid": "67b455a800000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", @@ -22,7 +22,7 @@ "http.request.headers.x-dd-proxy-stage": "aws-prod", "http.status_code": "200", "http.url": "http://localhost/simple?key=value&", - "runtime-id": "5d38703c-4633-4b05-82c1-47529cb93a96", + "runtime-id": "359d51e2-d5d9-4e02-86d0-abb244bc082f", "stage": "aws-prod", "version": "1.0" }, @@ -40,7 +40,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b3146c00000000", + "_dd.p.tid": "67b455a800000000", "component": "roadrunner", "env": "local-test", "span.kind": "server", diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json new file mode 100644 index 0000000000..36af82f7e1 --- /dev/null +++ b/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json @@ -0,0 +1,60 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /error", + "trace_id": 0, + "span_id": 1, + "parent_id": 9768559703299532556, + "type": "cli", + "error": 1, + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "0", + "_dd.p.tid": "67b455b200000000", + "component": "aws-apigateway", + "env": "local-test", + "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", + "error.stack": "#0 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.status_code": "500", + "http.url": "http://localhost/error?key=value&", + "runtime-id": "359d51e2-d5d9-4e02-86d0-abb244bc082f", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "web.request", + "service": "roadrunner_test_app", + "resource": "web.request", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b455b200000000", + "component": "roadrunner", + "env": "local-test", + "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", + "error.stack": "#0 {main}", + "error.type": "Exception", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }]] From 18a152705a0d2b97b71220ca607b646f9c64b72f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 11:03:26 +0100 Subject: [PATCH 24/46] fix: Laravel Latest CLI Test Script Location --- .../Integrations/CLI/Laravel/Latest/CommonScenariosTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Integrations/CLI/Laravel/Latest/CommonScenariosTest.php b/tests/Integrations/CLI/Laravel/Latest/CommonScenariosTest.php index a317486761..58f04c6162 100644 --- a/tests/Integrations/CLI/Laravel/Latest/CommonScenariosTest.php +++ b/tests/Integrations/CLI/Laravel/Latest/CommonScenariosTest.php @@ -8,6 +8,11 @@ class CommonScenariosTest extends \DDTrace\Tests\Integrations\CLI\Laravel\V10_X\CommonScenariosTest { + protected function getScriptLocation() + { + return __DIR__ . '/../../../../Frameworks/Laravel/Latest/artisan'; + } + public function testCommandWithNoArguments() { $this->retrieveDumpedData(); From 8c22cd587fdf0e46fcc1f98f73e3a20dec72a986 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 11:06:33 +0100 Subject: [PATCH 25/46] fix: persisting DD_SERVICE on Laravel Tests --- .../Laravel/Latest/InferredProxyTest.php | 2 - ...xy_test.test_inferred_proxy_exception.json | 234 ++++++++++++++++++ 2 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json diff --git a/tests/Integrations/Laravel/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Latest/InferredProxyTest.php index fd21b51f22..ad98e4d202 100644 --- a/tests/Integrations/Laravel/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Latest/InferredProxyTest.php @@ -26,8 +26,6 @@ protected static function getEnvs() public function testInferredProxy() { - self::putEnvAndReloadConfig(['DD_SERVICE=my_service']); - $this->tracesFromWebRequestSnapshot(function () { $this->call( GetSpec::create( diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json new file mode 100644 index 0000000000..8e7e67a275 --- /dev/null +++ b/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json @@ -0,0 +1,234 @@ +[[ + { + "name": "aws-apigateway", + "service": "example.com", + "resource": "GET /test", + "trace_id": 0, + "span_id": 1, + "parent_id": 14161928432233596578, + "type": "cli", + "error": 1, + "meta": { + "_dd.inferred_span": "1", + "_dd.p.dm": "0", + "_dd.p.tid": "67b456a300000000", + "component": "aws-apigateway", + "env": "local-test", + "error.message": "Uncaught Exception: Controller error in /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/ApplicationGateway.php(36): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/Worker.php(84): Laravel\\Octane\\ApplicationGateway->handle()\n#46 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(122): Laravel\\Octane\\Worker->handle()\n#47 [internal function]: {closure}()\n#48 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(172): Swoole\\Server->start()\n#49 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.url": "example.com/test", + "runtime-id": "03158492-c513-4d0a-85b8-969b9f12c443", + "stage": "aws-prod", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.request", + "service": "swoole_test_app", + "resource": "App\\Http\\Controllers\\CommonSpecsController@error unnamed_route", + "trace_id": 0, + "span_id": 2, + "parent_id": 1, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "_dd.p.tid": "67b456a300000000", + "component": "laravel", + "env": "local-test", + "error.message": "Uncaught Exception: Controller error in /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/ApplicationGateway.php(36): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/Worker.php(84): Laravel\\Octane\\ApplicationGateway->handle()\n#46 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(122): Laravel\\Octane\\Worker->handle()\n#47 [internal function]: {closure}()\n#48 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(172): Swoole\\Server->start()\n#49 {main}", + "error.type": "Exception", + "http.method": "GET", + "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy-domain-name": "example.com", + "http.request.headers.x-dd-proxy-httpmethod": "GET", + "http.request.headers.x-dd-proxy-path": "/test", + "http.request.headers.x-dd-proxy-request-time-ms": "1739261376000", + "http.request.headers.x-dd-proxy-stage": "aws-prod", + "http.route": "error", + "http.status_code": "500", + "http.url": "http://localhost/error?key=value&", + "laravel.route.action": "App\\Http\\Controllers\\CommonSpecsController@error", + "laravel.route.name": "unnamed_route", + "span.kind": "server", + "version": "1.0" + }, + "metrics": { + "_sampling_priority_v1": 1 + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestReceived", + "trace_id": 0, + "span_id": 3, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\Routing", + "trace_id": 0, + "span_id": 4, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\RouteMatched", + "trace_id": 0, + "span_id": 5, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.action", + "service": "swoole_test_app", + "resource": "error", + "trace_id": 0, + "span_id": 6, + "parent_id": 2, + "type": "web", + "error": 1, + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "error.message": "Thrown Exception: Controller error in /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/app/Http/Controllers/CommonSpecsController.php:19", + "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/ApplicationGateway.php(36): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/Worker.php(84): Laravel\\Octane\\ApplicationGateway->handle()\n#46 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(122): Laravel\\Octane\\Worker->handle()\n#47 [internal function]: {closure}()\n#48 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(172): Swoole\\Server->start()\n#49 {main}", + "error.type": "Exception", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Log\\Events\\MessageLogged", + "trace_id": 0, + "span_id": 7, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\PreparingResponse", + "trace_id": 0, + "span_id": 8, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Routing\\Events\\ResponsePrepared", + "trace_id": 0, + "span_id": 9, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Http\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 10, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestHandled", + "trace_id": 0, + "span_id": 11, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Illuminate\\Foundation\\Events\\Terminating", + "trace_id": 0, + "span_id": 12, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }, + { + "name": "laravel.event.handle", + "service": "swoole_test_app", + "resource": "Laravel\\Octane\\Events\\RequestTerminated", + "trace_id": 0, + "span_id": 13, + "parent_id": 2, + "type": "web", + "meta": { + "_dd.base_service": "example.com", + "component": "laravel", + "env": "local-test", + "version": "1.0" + } + }]] From 42e3581aebce828d90bd783aaa891e62091ce4f5 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 11:11:00 +0100 Subject: [PATCH 26/46] fix: Roadrunner tests order --- .../V2/{InferredProxyTest.php => APIGWTest.php} | 3 ++- ...ons.roadrunner.v2.apigw_test.test_inferred_proxy.json} | 8 ++++---- ...nner.v2.apigw_test.test_inferred_proxy_exception.json} | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) rename tests/Integrations/Roadrunner/V2/{InferredProxyTest.php => APIGWTest.php} (94%) rename tests/snapshots/{tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json => tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json} (88%) rename tests/snapshots/{tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json => tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json} (91%) diff --git a/tests/Integrations/Roadrunner/V2/InferredProxyTest.php b/tests/Integrations/Roadrunner/V2/APIGWTest.php similarity index 94% rename from tests/Integrations/Roadrunner/V2/InferredProxyTest.php rename to tests/Integrations/Roadrunner/V2/APIGWTest.php index 20498a57d0..1515a012df 100644 --- a/tests/Integrations/Roadrunner/V2/InferredProxyTest.php +++ b/tests/Integrations/Roadrunner/V2/APIGWTest.php @@ -8,7 +8,8 @@ use DDTrace\Tests\Frameworks\Util\Request\GetSpec; use DDTrace\Tests\Frameworks\Util\Request\RequestSpec; -class InferredProxyTest extends WebFrameworkTestCase +// Nota Bene: This test HAS to run first. This is because other Roadrunner tests are setting persisting distributed tags. +class APIGWTest extends WebFrameworkTestCase { public static function getAppIndexScript() { diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json similarity index 88% rename from tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json index 89bdb5d971..90c660fb4d 100644 --- a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json @@ -5,12 +5,12 @@ "resource": "GET /simple", "trace_id": 0, "span_id": 1, - "parent_id": 7104662190533113224, + "parent_id": 1018392648284749904, "type": "cli", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b455a800000000", + "_dd.p.tid": "67b45c9500000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", @@ -22,7 +22,7 @@ "http.request.headers.x-dd-proxy-stage": "aws-prod", "http.status_code": "200", "http.url": "http://localhost/simple?key=value&", - "runtime-id": "359d51e2-d5d9-4e02-86d0-abb244bc082f", + "runtime-id": "853263cf-31b4-4204-8a89-b001e2d59ec1", "stage": "aws-prod", "version": "1.0" }, @@ -40,7 +40,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b455a800000000", + "_dd.p.tid": "67b45c9500000000", "component": "roadrunner", "env": "local-test", "span.kind": "server", diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json similarity index 91% rename from tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json index 36af82f7e1..6cec864855 100644 --- a/tests/snapshots/tests.integrations.roadrunner.v2.inferred_proxy_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json @@ -5,13 +5,13 @@ "resource": "GET /error", "trace_id": 0, "span_id": 1, - "parent_id": 9768559703299532556, + "parent_id": 6434621651349511300, "type": "cli", "error": 1, "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b455b200000000", + "_dd.p.tid": "67b45c9a00000000", "component": "aws-apigateway", "env": "local-test", "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", @@ -26,7 +26,7 @@ "http.request.headers.x-dd-proxy-stage": "aws-prod", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", - "runtime-id": "359d51e2-d5d9-4e02-86d0-abb244bc082f", + "runtime-id": "853263cf-31b4-4204-8a89-b001e2d59ec1", "stage": "aws-prod", "version": "1.0" }, @@ -45,7 +45,7 @@ "error": 1, "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b455b200000000", + "_dd.p.tid": "67b45c9a00000000", "component": "roadrunner", "env": "local-test", "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", From cf59fa32133ae3af67d051c7b7d22c60189645c6 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 11:27:46 +0100 Subject: [PATCH 27/46] fix: Laravel Connection issue --- tests/Frameworks/Laravel/Latest/.env | 8 ++++---- tests/Integrations/Laravel/Latest/CommonScenariosTest.php | 2 ++ tests/Integrations/Laravel/Latest/InferredProxyTest.php | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/Frameworks/Laravel/Latest/.env b/tests/Frameworks/Laravel/Latest/.env index 1047bb0413..fb543cfb09 100644 --- a/tests/Frameworks/Laravel/Latest/.env +++ b/tests/Frameworks/Laravel/Latest/.env @@ -20,11 +20,11 @@ LOG_DEPRECATIONS_CHANNEL=null LOG_LEVEL=debug DB_CONNECTION=mysql -DB_HOST=127.0.0.1 +DB_HOST=mysql_integration DB_PORT=3306 -DB_DATABASE=laravel -DB_USERNAME=root -DB_PASSWORD= +DB_DATABASE=laravel11 +DB_USERNAME=test +DB_PASSWORD=test SESSION_DRIVER=file SESSION_LIFETIME=120 diff --git a/tests/Integrations/Laravel/Latest/CommonScenariosTest.php b/tests/Integrations/Laravel/Latest/CommonScenariosTest.php index d5262ba8a4..045deed71d 100644 --- a/tests/Integrations/Laravel/Latest/CommonScenariosTest.php +++ b/tests/Integrations/Laravel/Latest/CommonScenariosTest.php @@ -4,6 +4,8 @@ class CommonScenariosTest extends \DDTrace\Tests\Integrations\Laravel\V9_x\CommonScenariosTest { + public static $database = "laravel11"; + public static function getAppIndexScript() { return __DIR__ . '/../../../Frameworks/Laravel/Latest/public/index.php'; diff --git a/tests/Integrations/Laravel/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Latest/InferredProxyTest.php index ad98e4d202..33b5a86cb4 100644 --- a/tests/Integrations/Laravel/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Latest/InferredProxyTest.php @@ -7,6 +7,8 @@ class InferredProxyTest extends WebFrameworkTestCase { + public static $database = "laravel11"; + public static function getAppIndexScript() { return __DIR__ . '/../../../Frameworks/Laravel/Latest/public/index.php'; From 509bc510d99d598471efc295464d61d9503f5ca9 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 11:49:06 +0100 Subject: [PATCH 28/46] fix: Laravel Connection issue --- .../Latest/{InferredProxyTest.php => APIGWTest.php} | 2 +- ...ns.laravel.latest.apigw_test.test_inferred_proxy.json} | 8 ++++---- ....latest.apigw_test.test_inferred_proxy_exception.json} | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) rename tests/Integrations/Laravel/Latest/{InferredProxyTest.php => APIGWTest.php} (97%) rename tests/snapshots/{tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json => tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json} (98%) rename tests/snapshots/{tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json => tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json} (99%) diff --git a/tests/Integrations/Laravel/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Latest/APIGWTest.php similarity index 97% rename from tests/Integrations/Laravel/Latest/InferredProxyTest.php rename to tests/Integrations/Laravel/Latest/APIGWTest.php index 33b5a86cb4..433de6a26c 100644 --- a/tests/Integrations/Laravel/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Latest/APIGWTest.php @@ -5,7 +5,7 @@ use DDTrace\Tests\Common\WebFrameworkTestCase; use DDTrace\Tests\Frameworks\Util\Request\GetSpec; -class InferredProxyTest extends WebFrameworkTestCase +class APIGWTest extends WebFrameworkTestCase { public static $database = "laravel11"; diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json similarity index 98% rename from tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json index 91785b1915..988b9fccec 100644 --- a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json @@ -5,18 +5,18 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 13967141473350856149, + "parent_id": 8781673972826334496, "type": "web", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "-0", - "_dd.p.tid": "67b44b4200000000", + "_dd.p.tid": "67b4652600000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", "http.status_code": "200", "http.url": "example.com/test", - "runtime-id": "772d7e71-61b8-4883-a140-4d8032617997", + "runtime-id": "74f55080-3f8f-4708-8283-24d6bb7d160a", "stage": "aws-prod", "version": "1.0" }, @@ -34,7 +34,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b44b4200000000", + "_dd.p.tid": "67b4652600000000", "component": "laravel", "env": "local-test", "http.method": "GET", diff --git a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json similarity index 99% rename from tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json index e7b8459d39..1d3f0051cd 100644 --- a/tests/snapshots/tests.integrations.laravel.latest.inferred_proxy_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json @@ -5,13 +5,13 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 6404596600830044292, + "parent_id": 10950178965489427610, "type": "web", "error": 1, "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "-0", - "_dd.p.tid": "67b44b4800000000", + "_dd.p.tid": "67b4653800000000", "component": "aws-apigateway", "env": "local-test", "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", @@ -20,7 +20,7 @@ "http.method": "GET", "http.status_code": "500", "http.url": "example.com/test", - "runtime-id": "772d7e71-61b8-4883-a140-4d8032617997", + "runtime-id": "74f55080-3f8f-4708-8283-24d6bb7d160a", "stage": "aws-prod", "version": "1.0" }, @@ -39,7 +39,7 @@ "error": 1, "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b44b4800000000", + "_dd.p.tid": "67b4653800000000", "component": "laravel", "env": "local-test", "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", From 4c29c16e0dcccda6d26bbeead534ae4eceb714a1 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 15:00:34 +0100 Subject: [PATCH 29/46] error output --- tests/Sapi/CliServer/CliServer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/Sapi/CliServer/CliServer.php b/tests/Sapi/CliServer/CliServer.php index 9ce308b554..63d90f7fad 100644 --- a/tests/Sapi/CliServer/CliServer.php +++ b/tests/Sapi/CliServer/CliServer.php @@ -93,6 +93,9 @@ public function start() $this->process = new Process($processCmd); $this->process->start(); + if (!$this->process->isRunning()) { + error_log("[cli-server] Error starting: " . $this->process->getErrorOutput()); + } } public function stop() From 340b32e1cd8195f937373a8741e97364445841be Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 15:37:36 +0100 Subject: [PATCH 30/46] error output --- tests/Sapi/CliServer/CliServer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Sapi/CliServer/CliServer.php b/tests/Sapi/CliServer/CliServer.php index 63d90f7fad..4f3639d71e 100644 --- a/tests/Sapi/CliServer/CliServer.php +++ b/tests/Sapi/CliServer/CliServer.php @@ -93,9 +93,7 @@ public function start() $this->process = new Process($processCmd); $this->process->start(); - if (!$this->process->isRunning()) { - error_log("[cli-server] Error starting: " . $this->process->getErrorOutput()); - } + error_log("[cli-server] Startup errors: " . $this->process->getErrorOutput()); } public function stop() From 5fb7511442c9862e90652498f1787095967a6ecf Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Tue, 18 Feb 2025 16:21:17 +0100 Subject: [PATCH 31/46] Try to disable DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED and see what happens --- tests/Integrations/Laravel/Latest/APIGWTest.php | 2 +- tests/Sapi/CliServer/CliServer.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Integrations/Laravel/Latest/APIGWTest.php b/tests/Integrations/Laravel/Latest/APIGWTest.php index 433de6a26c..ac5ee1862c 100644 --- a/tests/Integrations/Laravel/Latest/APIGWTest.php +++ b/tests/Integrations/Laravel/Latest/APIGWTest.php @@ -21,7 +21,7 @@ protected static function getEnvs() 'DD_SERVICE' => 'my_service', 'DD_ENV' => 'local-test', 'DD_VERSION' => '1.0', - 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'false', //'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', ]); } diff --git a/tests/Sapi/CliServer/CliServer.php b/tests/Sapi/CliServer/CliServer.php index 4f3639d71e..3b1072a1ee 100644 --- a/tests/Sapi/CliServer/CliServer.php +++ b/tests/Sapi/CliServer/CliServer.php @@ -93,7 +93,11 @@ public function start() $this->process = new Process($processCmd); $this->process->start(); - error_log("[cli-server] Startup errors: " . $this->process->getErrorOutput()); + if ($this->process->isRunning()) { + error_log("[cli-server] Started with PID: " . $this->process->getPid()); + } else { + error_log("[cli-server] Failed to start"); + } } public function stop() From 572fbfdd3fbecd5e83d968e815a00ebe1cd3d40c Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 09:05:26 +0100 Subject: [PATCH 32/46] Try to split the tests --- tests/Integrations/Laravel/APIGWTestSuite.php | 61 +++++++++++++++++++ .../Integrations/Laravel/Latest/APIGWTest.php | 56 +---------------- 2 files changed, 64 insertions(+), 53 deletions(-) create mode 100644 tests/Integrations/Laravel/APIGWTestSuite.php diff --git a/tests/Integrations/Laravel/APIGWTestSuite.php b/tests/Integrations/Laravel/APIGWTestSuite.php new file mode 100644 index 0000000000..d45ff9780d --- /dev/null +++ b/tests/Integrations/Laravel/APIGWTestSuite.php @@ -0,0 +1,61 @@ + 'laravel_test_app', + 'DD_SERVICE' => 'my_service', + 'DD_ENV' => 'local-test', + 'DD_VERSION' => '1.0', + 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', + //'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', + ]); + } + + public function testInferredProxy() + { + $this->tracesFromWebRequestSnapshot(function () { + $this->call( + GetSpec::create( + 'A simple GET request returning a string', + '/simple?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); + } + + public function testInferredProxyException() + { + $this->tracesFromWebRequestSnapshot(function () { + $this->call( + GetSpec::create( + 'A GET throwing an exception', + '/error?key=value&pwd=should_redact', + [ + 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy-request-time-ms: 1739261376000', + 'x-dd-proxy-path: /test', + 'x-dd-proxy-httpmethod: GET', + 'x-dd-proxy-domain-name: example.com', + 'x-dd-proxy-stage: aws-prod', + ] + ) + ); + }); + } +} \ No newline at end of file diff --git a/tests/Integrations/Laravel/Latest/APIGWTest.php b/tests/Integrations/Laravel/Latest/APIGWTest.php index ac5ee1862c..24c7319b16 100644 --- a/tests/Integrations/Laravel/Latest/APIGWTest.php +++ b/tests/Integrations/Laravel/Latest/APIGWTest.php @@ -4,8 +4,10 @@ use DDTrace\Tests\Common\WebFrameworkTestCase; use DDTrace\Tests\Frameworks\Util\Request\GetSpec; +use DDTrace\Tests\Integrations\Laravel\APIGWTestSuite; -class APIGWTest extends WebFrameworkTestCase + +class APIGWTest extends APIGWTestSuite { public static $database = "laravel11"; @@ -13,56 +15,4 @@ public static function getAppIndexScript() { return __DIR__ . '/../../../Frameworks/Laravel/Latest/public/index.php'; } - - protected static function getEnvs() - { - return array_merge(parent::getEnvs(), [ - 'APP_NAME' => 'laravel_test_app', - 'DD_SERVICE' => 'my_service', - 'DD_ENV' => 'local-test', - 'DD_VERSION' => '1.0', - 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'false', - //'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', - ]); - } - - public function testInferredProxy() - { - $this->tracesFromWebRequestSnapshot(function () { - $this->call( - GetSpec::create( - 'A simple GET request returning a string', - '/simple?key=value&pwd=should_redact', - [ - 'x-dd-proxy: aws-apigateway', - 'x-dd-proxy-request-time-ms: 1739261376000', - 'x-dd-proxy-path: /test', - 'x-dd-proxy-httpmethod: GET', - 'x-dd-proxy-domain-name: example.com', - 'x-dd-proxy-stage: aws-prod', - ] - ) - ); - }); - } - - public function testInferredProxyException() - { - $this->tracesFromWebRequestSnapshot(function () { - $this->call( - GetSpec::create( - 'A GET throwing an exception', - '/error?key=value&pwd=should_redact', - [ - 'x-dd-proxy: aws-apigateway', - 'x-dd-proxy-request-time-ms: 1739261376000', - 'x-dd-proxy-path: /test', - 'x-dd-proxy-httpmethod: GET', - 'x-dd-proxy-domain-name: example.com', - 'x-dd-proxy-stage: aws-prod', - ] - ) - ); - }); - } } \ No newline at end of file From f54687aaab8cabdf1be2216f9b4f5011b77e0557 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 09:05:37 +0100 Subject: [PATCH 33/46] Remove logs --- tests/Sapi/CliServer/CliServer.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/Sapi/CliServer/CliServer.php b/tests/Sapi/CliServer/CliServer.php index 3b1072a1ee..9ce308b554 100644 --- a/tests/Sapi/CliServer/CliServer.php +++ b/tests/Sapi/CliServer/CliServer.php @@ -93,11 +93,6 @@ public function start() $this->process = new Process($processCmd); $this->process->start(); - if ($this->process->isRunning()) { - error_log("[cli-server] Started with PID: " . $this->process->getPid()); - } else { - error_log("[cli-server] Failed to start"); - } } public function stop() From ec98ccd3d6c48d63ed5a8f3859b5af1d1e4f8479 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 09:45:14 +0100 Subject: [PATCH 34/46] Totally split the tests --- Makefile | 4 ++++ .../{APIGWTestSuite.php => APIGWTest.php} | 10 +++++++++- .../Integrations/Laravel/Latest/APIGWTest.php | 18 ------------------ tests/phpunit.xml | 3 +++ ...aravel.apigw_test.test_inferred_proxy.json} | 8 ++++---- ...gw_test.test_inferred_proxy_exception.json} | 8 ++++---- 6 files changed, 24 insertions(+), 27 deletions(-) rename tests/Integrations/Laravel/{APIGWTestSuite.php => APIGWTest.php} (90%) delete mode 100644 tests/Integrations/Laravel/Latest/APIGWTest.php rename tests/snapshots/{tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json => tests.integrations.laravel.apigw_test.test_inferred_proxy.json} (98%) rename tests/snapshots/{tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json => tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json} (99%) diff --git a/Makefile b/Makefile index 666ccc07c8..2f8fb33fa7 100644 --- a/Makefile +++ b/Makefile @@ -981,6 +981,7 @@ TEST_WEB_82 := \ test_web_laravel_9x \ test_web_laravel_10x \ test_web_laravel_latest \ + test_web_apigw \ test_web_laravel_octane_latest \ test_web_lumen_81 \ test_web_lumen_90 \ @@ -1042,6 +1043,7 @@ TEST_WEB_83 := \ test_web_laravel_9x \ test_web_laravel_10x \ test_web_laravel_latest \ + test_web_apigw \ test_web_laravel_octane_latest \ test_web_lumen_81 \ test_web_lumen_90 \ @@ -1311,6 +1313,8 @@ test_integrations_sqlsrv: global_test_run_dependencies $(eval TEST_EXTRA_INI=) test_integrations_swoole_5: global_test_run_dependencies $(call run_tests_debug,--testsuite=swoole-test) +test_web_apigw: global_test_run_dependencies tests/Frameworks/Laravel/Latest/composer.lock-php$(PHP_MAJOR_MINOR) + $(call run_tests_debug,--testsuite=api-gateway-test) test_web_cakephp_28: global_test_run_dependencies tests/Frameworks/CakePHP/Version_2_8/composer.lock-php$(PHP_MAJOR_MINOR) $(call run_tests_debug,--testsuite=cakephp-28-test) test_web_cakephp_310: global_test_run_dependencies tests/Frameworks/CakePHP/Version_3_10/composer.lock-php$(PHP_MAJOR_MINOR) diff --git a/tests/Integrations/Laravel/APIGWTestSuite.php b/tests/Integrations/Laravel/APIGWTest.php similarity index 90% rename from tests/Integrations/Laravel/APIGWTestSuite.php rename to tests/Integrations/Laravel/APIGWTest.php index d45ff9780d..57af97cc6c 100644 --- a/tests/Integrations/Laravel/APIGWTestSuite.php +++ b/tests/Integrations/Laravel/APIGWTest.php @@ -5,8 +5,16 @@ use DDTrace\Tests\Common\WebFrameworkTestCase; use DDTrace\Tests\Frameworks\Util\Request\GetSpec; -class APIGWTestSuite extends WebFrameworkTestCase + +class APIGWTest extends WebFrameworkTestCase { + public static $database = "laravel11"; + + public static function getAppIndexScript() + { + return __DIR__ . '/../../Frameworks/Laravel/Latest/public/index.php'; + } + protected static function getEnvs() { return array_merge(parent::getEnvs(), [ diff --git a/tests/Integrations/Laravel/Latest/APIGWTest.php b/tests/Integrations/Laravel/Latest/APIGWTest.php deleted file mode 100644 index 24c7319b16..0000000000 --- a/tests/Integrations/Laravel/Latest/APIGWTest.php +++ /dev/null @@ -1,18 +0,0 @@ - ./Integrations/Laravel/Octane/Latest + + ./Integrations/Laravel/APIGWTest.php + ./OpenTelemetry/Integration/Context/Fiber ./OpenTelemetry/Unit/API diff --git a/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json similarity index 98% rename from tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json index 988b9fccec..8daf4dc10c 100644 --- a/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json @@ -5,18 +5,18 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 8781673972826334496, + "parent_id": 16608282385995297226, "type": "web", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "-0", - "_dd.p.tid": "67b4652600000000", + "_dd.p.tid": "67b5998500000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", "http.status_code": "200", "http.url": "example.com/test", - "runtime-id": "74f55080-3f8f-4708-8283-24d6bb7d160a", + "runtime-id": "696b2e43-4025-464d-8b9b-1ce63ba78d6e", "stage": "aws-prod", "version": "1.0" }, @@ -34,7 +34,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b4652600000000", + "_dd.p.tid": "67b5998500000000", "component": "laravel", "env": "local-test", "http.method": "GET", diff --git a/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json similarity index 99% rename from tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json index 1d3f0051cd..3fa84d6480 100644 --- a/tests/snapshots/tests.integrations.laravel.latest.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json @@ -5,13 +5,13 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 10950178965489427610, + "parent_id": 3960688414599440033, "type": "web", "error": 1, "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "-0", - "_dd.p.tid": "67b4653800000000", + "_dd.p.tid": "67b5998f00000000", "component": "aws-apigateway", "env": "local-test", "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", @@ -20,7 +20,7 @@ "http.method": "GET", "http.status_code": "500", "http.url": "example.com/test", - "runtime-id": "74f55080-3f8f-4708-8283-24d6bb7d160a", + "runtime-id": "696b2e43-4025-464d-8b9b-1ce63ba78d6e", "stage": "aws-prod", "version": "1.0" }, @@ -39,7 +39,7 @@ "error": 1, "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b4653800000000", + "_dd.p.tid": "67b5998f00000000", "component": "laravel", "env": "local-test", "error.message": "Uncaught Exception (500): Controller error in /home/circleci/app/tests/Frameworks/Laravel/Latest/app/Http/Controllers/CommonSpecsController.php:19", From ed31db3fb7fe96dfe0af08a5131b1f3d7ce1bd26 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 13:12:39 +0100 Subject: [PATCH 35/46] style: Use `ddtrace_read_header` --- Makefile | 2 +- config.m4 | 1 + config.w32 | 1 + ext/ddtrace.c | 14 +-- ext/distributed_tracing_headers.c | 12 +++ ext/distributed_tracing_headers.h | 1 + ext/inferred_proxy_headers.c | 16 ++++ ext/inferred_proxy_headers.h | 18 ++++ ext/span.c | 95 +++++++------------ .../InferredProxyTest.php => APIGWTest.php} | 8 +- .../Roadrunner/{V2 => }/APIGWTest.php | 7 +- tests/ext/inferred_proxy/alter_service.phpt | 2 +- tests/ext/inferred_proxy/basic_test.phpt | 2 +- .../inferred_proxy/distributed_tracing.phpt | 18 ++-- .../ext/inferred_proxy/error_propagated.phpt | 2 +- tests/phpunit.xml | 2 + ...ctane.apigw_test.test_inferred_proxy.json} | 8 +- ...w_test.test_inferred_proxy_exception.json} | 8 +- ...unner.apigw_test.test_inferred_proxy.json} | 8 +- ...w_test.test_inferred_proxy_exception.json} | 8 +- 20 files changed, 119 insertions(+), 114 deletions(-) create mode 100644 ext/inferred_proxy_headers.c create mode 100644 ext/inferred_proxy_headers.h rename tests/Integrations/Laravel/Octane/{Latest/InferredProxyTest.php => APIGWTest.php} (94%) rename tests/Integrations/Roadrunner/{V2 => }/APIGWTest.php (91%) rename tests/snapshots/{tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json => tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json} (97%) rename tests/snapshots/{tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json => tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json} (99%) rename tests/snapshots/{tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json => tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json} (88%) rename tests/snapshots/{tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json => tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json} (91%) diff --git a/Makefile b/Makefile index 2f8fb33fa7..b7f1e536ed 100644 --- a/Makefile +++ b/Makefile @@ -1313,7 +1313,7 @@ test_integrations_sqlsrv: global_test_run_dependencies $(eval TEST_EXTRA_INI=) test_integrations_swoole_5: global_test_run_dependencies $(call run_tests_debug,--testsuite=swoole-test) -test_web_apigw: global_test_run_dependencies tests/Frameworks/Laravel/Latest/composer.lock-php$(PHP_MAJOR_MINOR) +test_web_apigw: global_test_run_dependencies tests/Frameworks/Laravel/Latest/composer.lock-php$(PHP_MAJOR_MINOR) tests/Frameworks/Laravel/Octane/Latest/composer.lock-php$(PHP_MAJOR_MINOR) tests/Frameworks/Roadrunner/Version_2/composer.lock-php$(PHP_MAJOR_MINOR) $(call run_tests_debug,--testsuite=api-gateway-test) test_web_cakephp_28: global_test_run_dependencies tests/Frameworks/CakePHP/Version_2_8/composer.lock-php$(PHP_MAJOR_MINOR) $(call run_tests_debug,--testsuite=cakephp-28-test) diff --git a/config.m4 b/config.m4 index 241f81657b..96ee803147 100644 --- a/config.m4 +++ b/config.m4 @@ -187,6 +187,7 @@ if test "$PHP_DDTRACE" != "no"; then ext/handlers_kafka.c \ ext/handlers_pcntl.c \ ext/handlers_signal.c \ + ext/inferred_proxy_headers.c \ ext/integrations/exec_integration.c \ ext/integrations/integrations.c \ ext/ip_extraction.c \ diff --git a/config.w32 b/config.w32 index dc151bd508..7addf079fe 100644 --- a/config.w32 +++ b/config.w32 @@ -39,6 +39,7 @@ if (PHP_DDTRACE != 'no') { DDTRACE_EXT_SOURCES += " handlers_internal.c"; DDTRACE_EXT_SOURCES += " handlers_kafka.c"; DDTRACE_EXT_SOURCES += " handlers_pcntl.c"; + DDTRACE_EXT_SOURCES += " inferred_proxy_headers.c"; DDTRACE_EXT_SOURCES += " ip_extraction.c"; DDTRACE_EXT_SOURCES += " standalone_limiter.c"; DDTRACE_EXT_SOURCES += " live_debugger.c"; diff --git a/ext/ddtrace.c b/ext/ddtrace.c index bbe5c2f73b..261e76fefb 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -3117,18 +3117,6 @@ static bool dd_read_userspace_header(zai_str zai_header, const char *lowercase_h return true; } -static bool dd_read_array_header(zai_str zai_header, const char *lowercase_header, zend_string **header_value, void *data) { - UNUSED(zai_header); - zend_array *array = (zend_array *) data; - zval *value = zend_hash_str_find(array, lowercase_header, strlen(lowercase_header)); - if (!value) { - return false; - } - - *header_value = zval_get_string(value); - return true; -} - static ddtrace_distributed_tracing_result dd_parse_distributed_tracing_headers_function(INTERNAL_FUNCTION_PARAMETERS, bool *success) { UNUSED(return_value); @@ -3171,7 +3159,7 @@ static ddtrace_distributed_tracing_result dd_parse_distributed_tracing_headers_f func.fci.param_count = 1; if (array) { - return ddtrace_read_distributed_tracing_ids(dd_read_array_header, array); + return ddtrace_read_distributed_tracing_ids(ddtrace_read_array_header, array); } else if (use_server_headers) { return ddtrace_read_distributed_tracing_ids(ddtrace_read_zai_header, &func); } else { diff --git a/ext/distributed_tracing_headers.c b/ext/distributed_tracing_headers.c index f54a4d06e4..f338a90adb 100644 --- a/ext/distributed_tracing_headers.c +++ b/ext/distributed_tracing_headers.c @@ -522,3 +522,15 @@ bool ddtrace_read_zai_header(zai_str zai_header, const char *lowercase_header, z *header_value = zend_string_copy(*header_value); return true; } + +bool ddtrace_read_array_header(zai_str zai_header, const char *lowercase_header, zend_string **header_value, void *data) { + UNUSED(zai_header); + zend_array *array = (zend_array *) data; + zval *value = zend_hash_str_find(array, lowercase_header, strlen(lowercase_header)); + if (!value) { + return false; + } + + *header_value = zval_get_string(value); + return true; +} diff --git a/ext/distributed_tracing_headers.h b/ext/distributed_tracing_headers.h index b69120cdf2..29747bc541 100644 --- a/ext/distributed_tracing_headers.h +++ b/ext/distributed_tracing_headers.h @@ -22,5 +22,6 @@ typedef bool (ddtrace_read_header)(zai_str zai_header, const char *lowercase_hea ddtrace_distributed_tracing_result ddtrace_read_distributed_tracing_ids(ddtrace_read_header *read_header, void *data); void ddtrace_apply_distributed_tracing_result(ddtrace_distributed_tracing_result *result, ddtrace_root_span_data *span); bool ddtrace_read_zai_header(zai_str zai_header, const char *lowercase_header, zend_string **header_value, void *data); +bool ddtrace_read_array_header(zai_str zai_header, const char *lowercase_header, zend_string **header_value, void *data); #endif // DD_DISTRIBUTED_TRACING_HEADERS_H diff --git a/ext/inferred_proxy_headers.c b/ext/inferred_proxy_headers.c new file mode 100644 index 0000000000..c1420a16b5 --- /dev/null +++ b/ext/inferred_proxy_headers.c @@ -0,0 +1,16 @@ +#include "inferred_proxy_headers.h" + +ZEND_EXTERN_MODULE_GLOBALS(ddtrace); + +ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data) { + ddtrace_inferred_proxy_result result = {0}; + + read_header((zai_str)ZAI_STRL("X_DD_PROXY"), "x-dd-proxy", &result.system, data); + read_header((zai_str)ZAI_STRL("X_DD_PROXY_REQUEST_TIME_MS"), "x-dd-proxy-request-time-ms", &result.start_time_ms, data); + read_header((zai_str)ZAI_STRL("X_DD_PROXY_PATH"), "x-dd-proxy-path", &result.path, data); + read_header((zai_str)ZAI_STRL("X_DD_PROXY_HTTPMETHOD"), "x-dd-proxy-httpmethod", &result.http_method, data); + read_header((zai_str)ZAI_STRL("X_DD_PROXY_DOMAIN_NAME"), "x-dd-proxy-domain-name", &result.domain, data); + read_header((zai_str)ZAI_STRL("X_DD_PROXY_STAGE"), "x-dd-proxy-stage", &result.stage, data); + + return result; +} \ No newline at end of file diff --git a/ext/inferred_proxy_headers.h b/ext/inferred_proxy_headers.h new file mode 100644 index 0000000000..97f4ed8836 --- /dev/null +++ b/ext/inferred_proxy_headers.h @@ -0,0 +1,18 @@ +#ifndef DD_INFERRED_PROXY_HEADERS_H +#define DD_INFERRED_PROXY_HEADERS_H + +#include "ddtrace.h" +#include "distributed_tracing_headers.h" + +typedef struct { + zend_string *system; + zend_string *start_time_ms; + zend_string *path; + zend_string *http_method; + zend_string *domain; + zend_string *stage; +} ddtrace_inferred_proxy_result; + +ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data); + +#endif // DD_INFERRED_PROXY_HEADERS_H \ No newline at end of file diff --git a/ext/span.c b/ext/span.c index 3218a11373..47e9b09838 100644 --- a/ext/span.c +++ b/ext/span.c @@ -18,6 +18,7 @@ #include "user_request.h" #include "zend_types.h" #include "sidecar.h" +#include "inferred_proxy_headers.h" #define USE_REALTIME_CLOCK 0 #define USE_MONOTONIC_CLOCK 1 @@ -826,90 +827,58 @@ zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id) { return str; } + ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { - zval *proxy_header_system = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY")); - if (!proxy_header_system) { - proxy_header_system = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy")); - } - zval *proxy_header_start_time_ms = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_REQUEST_TIME_MS")); - if (!proxy_header_start_time_ms) { - proxy_header_start_time_ms = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-request-time-ms")); - } + ddtrace_read_header *read_header = headers ? ddtrace_read_array_header : ddtrace_read_zai_header; + ddtrace_inferred_proxy_result result = ddtrace_read_inferred_proxy_headers(read_header, headers); - if (!proxy_header_system || Z_TYPE_P(proxy_header_system) != IS_STRING || Z_STRLEN_P(proxy_header_system) == 0 || !proxy_header_start_time_ms || Z_TYPE_P(proxy_header_start_time_ms) != IS_STRING || Z_STRLEN_P(proxy_header_start_time_ms) == 0) { + if (!result.system || !result.start_time_ms ) { return NULL; } - zval *proxy_header_path = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_PATH")); - if (!proxy_header_path) { - proxy_header_path = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-path")); - } - zval *proxy_header_http_method = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_HTTPMETHOD")); - if (!proxy_header_http_method) { - proxy_header_http_method = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-httpmethod")); - } - zval *proxy_header_domain = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_DOMAIN_NAME")); - if (!proxy_header_domain) { - proxy_header_domain = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-domain-name")); - } - zval *proxy_header_stage = zend_hash_str_find(headers, ZEND_STRL("HTTP_X_DD_PROXY_STAGE")); - if (!proxy_header_stage) { - proxy_header_stage = zend_hash_str_find(headers, ZEND_STRL("x-dd-proxy-stage")); - } - ddtrace_span_data *span = ddtrace_push_inferred_root_span(); - zval *prop_name = &span->property_name; - zval_ptr_dtor(prop_name); - ZVAL_STR_COPY(prop_name, Z_STR_P(proxy_header_system)); + zval zv; - zval *prop_resource = &span->property_resource; - zval_ptr_dtor(prop_resource); - ZVAL_STR(prop_resource, strpprintf(0, "%s %s", Z_STRVAL_P(proxy_header_http_method), Z_STRVAL_P(proxy_header_path))); + ZVAL_STR(&zv, result.system); + ddtrace_assign_variable(&span->property_name, &zv); - span->start = (zend_long)zend_strtod(Z_STRVAL_P(proxy_header_start_time_ms), NULL) * 1000000; - span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); // // Now - offset + zval_ptr_dtor(&span->property_resource); + ZVAL_STR(&span->property_resource, strpprintf(0, "%s %s", ZSTR_VAL(result.http_method), ZSTR_VAL(result.path))); - if (proxy_header_domain && Z_TYPE_P(proxy_header_domain) == IS_STRING && Z_STRLEN_P(proxy_header_domain) > 0) { - LOG(DEBUG, "Inferred service=%s from HTTP_X_DD_PROXY header", Z_STRVAL_P(proxy_header_domain)); - zval *prop_service = &span->property_service; - zval_ptr_dtor(prop_service); - ZVAL_STR_COPY(prop_service, Z_STR_P(proxy_header_domain)); - LOG(DEBUG, "Verification: service=%s", Z_STRVAL_P(prop_service)); - } // Defaults to DD_SERVICE + span->start = (zend_long)zend_strtod(ZSTR_VAL(result.start_time_ms), NULL) * 1000000; + span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); + + if (result.domain) { + ZVAL_STR_COPY(&zv, result.domain); + ddtrace_assign_variable(&span->property_service, &zv); + } - // Set meta component to aws-apigateway zend_array *meta = ddtrace_property_array(&span->property_meta); - zval component; - ZVAL_STR(&component, zend_string_init("aws-apigateway", sizeof("aws-apigateway") - 1, 0)); - zend_hash_str_add_new(meta, ZEND_STRL("component"), &component); - // Set meta "http.method" to value of x-dd-proxy-httpmethod - zval http_method; - ZVAL_STR_COPY(&http_method, Z_STR_P(proxy_header_http_method)); - zend_hash_str_add_new(meta, ZEND_STRL("http.method"), &http_method); + ZVAL_STR_COPY(&zv, result.http_method); + zend_hash_str_add_new(meta, ZEND_STRL("http.method"), &zv); - // Set meta "http.url" to x-dd-proxy-domain-name + x-dd-proxy-path - zval http_url; - ZVAL_STR(&http_url, strpprintf(0, "%s%s", Z_STRVAL_P(proxy_header_domain), Z_STRVAL_P(proxy_header_path))); - zend_hash_str_add_new(meta, ZEND_STRL("http.url"), &http_url); + ZVAL_STR(&zv, strpprintf(0, "%s%s", ZSTR_VAL(result.domain), ZSTR_VAL(result.path))); + zend_hash_str_add_new(meta, ZEND_STRL("http.url"), &zv); - // Set meta "stage" to x-dd-proxy-stage - if (proxy_header_stage && Z_TYPE_P(proxy_header_stage) == IS_STRING && Z_STRLEN_P(proxy_header_stage) > 0) { - zval stage; - ZVAL_STR_COPY(&stage, Z_STR_P(proxy_header_stage)); - zend_hash_str_add_new(meta, ZEND_STRL("stage"), &stage); + if (result.stage) { + ZVAL_STR_COPY(&zv, result.stage); + zend_hash_str_add_new(meta, ZEND_STRL("stage"), &zv); } add_assoc_long(&span->property_meta, "_dd.inferred_span", 1); + add_assoc_string(&span->property_meta, "component", "aws-apigateway"); - ddtrace_root_span_data *rsd = ROOTSPANDATA(&span->std); - LOG(DEBUG, "Inferred trace_id=%s, span_id=%" PRIu64 " from HTTP_X_DD_PROXY header", Z_STRVAL(rsd->property_trace_id), rsd->span.span_id); + zend_string_release(result.start_time_ms); + zend_string_release(result.path); + zend_string_release(result.http_method); + zend_string_release(result.domain); + zend_string_release(result.stage); - return rsd; + return ROOTSPANDATA(&span->std); } void ddtrace_infer_proxy_services(void) { - zend_array *server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); - ddtrace_open_inferred_span(server); + ddtrace_open_inferred_span(NULL); } diff --git a/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php b/tests/Integrations/Laravel/Octane/APIGWTest.php similarity index 94% rename from tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php rename to tests/Integrations/Laravel/Octane/APIGWTest.php index a4cc9dce47..61272f5a52 100644 --- a/tests/Integrations/Laravel/Octane/Latest/InferredProxyTest.php +++ b/tests/Integrations/Laravel/Octane/APIGWTest.php @@ -1,15 +1,15 @@ ./Integrations/Laravel/APIGWTest.php + ./Integrations/Laravel/Octane/APIGWTest.php + ./Integrations/Roadrunner/APIGWTest.php ./OpenTelemetry/Integration/Context/Fiber diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json similarity index 97% rename from tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json index 1abeb39b1d..93e1278665 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json @@ -5,17 +5,17 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 7890634735527917160, + "parent_id": 15744600919684174002, "type": "cli", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b3143a00000000", + "_dd.p.tid": "67b5c8a600000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", "http.url": "example.com/test", - "runtime-id": "b1b988b9-d9a6-484e-b839-81a851030087", + "runtime-id": "f17d43eb-d9ba-4756-b37a-8dab181a4319", "stage": "aws-prod", "version": "1.0" }, @@ -33,7 +33,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b3143a00000000", + "_dd.p.tid": "67b5c8a600000000", "component": "laravel", "env": "local-test", "http.method": "GET", diff --git a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json similarity index 99% rename from tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json index 8e7e67a275..19fd67b161 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.latest.inferred_proxy_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json @@ -5,13 +5,13 @@ "resource": "GET /test", "trace_id": 0, "span_id": 1, - "parent_id": 14161928432233596578, + "parent_id": 13636397762784364900, "type": "cli", "error": 1, "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b456a300000000", + "_dd.p.tid": "67b5c8bc00000000", "component": "aws-apigateway", "env": "local-test", "error.message": "Uncaught Exception: Controller error in /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/app/Http/Controllers/CommonSpecsController.php:19", @@ -19,7 +19,7 @@ "error.type": "Exception", "http.method": "GET", "http.url": "example.com/test", - "runtime-id": "03158492-c513-4d0a-85b8-969b9f12c443", + "runtime-id": "f17d43eb-d9ba-4756-b37a-8dab181a4319", "stage": "aws-prod", "version": "1.0" }, @@ -38,7 +38,7 @@ "error": 1, "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b456a300000000", + "_dd.p.tid": "67b5c8bc00000000", "component": "laravel", "env": "local-test", "error.message": "Uncaught Exception: Controller error in /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/app/Http/Controllers/CommonSpecsController.php:19", diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json similarity index 88% rename from tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json index 90c660fb4d..8458538d17 100644 --- a/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json @@ -5,12 +5,12 @@ "resource": "GET /simple", "trace_id": 0, "span_id": 1, - "parent_id": 1018392648284749904, + "parent_id": 496562999704294221, "type": "cli", "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b45c9500000000", + "_dd.p.tid": "67b5c9a300000000", "component": "aws-apigateway", "env": "local-test", "http.method": "GET", @@ -22,7 +22,7 @@ "http.request.headers.x-dd-proxy-stage": "aws-prod", "http.status_code": "200", "http.url": "http://localhost/simple?key=value&", - "runtime-id": "853263cf-31b4-4204-8a89-b001e2d59ec1", + "runtime-id": "6423c0c2-fbc3-4ee4-ad68-25dd48ee99f3", "stage": "aws-prod", "version": "1.0" }, @@ -40,7 +40,7 @@ "type": "web", "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b45c9500000000", + "_dd.p.tid": "67b5c9a300000000", "component": "roadrunner", "env": "local-test", "span.kind": "server", diff --git a/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json similarity index 91% rename from tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json index 6cec864855..cb69b66762 100644 --- a/tests/snapshots/tests.integrations.roadrunner.v2.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json @@ -5,13 +5,13 @@ "resource": "GET /error", "trace_id": 0, "span_id": 1, - "parent_id": 6434621651349511300, + "parent_id": 6078099901530556271, "type": "cli", "error": 1, "meta": { "_dd.inferred_span": "1", "_dd.p.dm": "0", - "_dd.p.tid": "67b45c9a00000000", + "_dd.p.tid": "67b5c9a800000000", "component": "aws-apigateway", "env": "local-test", "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", @@ -26,7 +26,7 @@ "http.request.headers.x-dd-proxy-stage": "aws-prod", "http.status_code": "500", "http.url": "http://localhost/error?key=value&", - "runtime-id": "853263cf-31b4-4204-8a89-b001e2d59ec1", + "runtime-id": "6423c0c2-fbc3-4ee4-ad68-25dd48ee99f3", "stage": "aws-prod", "version": "1.0" }, @@ -45,7 +45,7 @@ "error": 1, "meta": { "_dd.base_service": "example.com", - "_dd.p.tid": "67b45c9a00000000", + "_dd.p.tid": "67b5c9a800000000", "component": "roadrunner", "env": "local-test", "error.message": "Uncaught Exception: Error page in /home/circleci/app/tests/Frameworks/Roadrunner/Version_2/worker.php:26", From f0ccfa3832dd2f57a74243b8123cbd23f51fa284 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 13:17:42 +0100 Subject: [PATCH 36/46] style: Remove some debug logs --- ext/ddtrace.c | 4 ---- ext/serializer.c | 7 ------- ext/span.c | 24 +++++++++++------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 261e76fefb..1c5d4f6ec5 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -1568,7 +1568,6 @@ static void dd_rinit_once(void) { static pthread_once_t dd_rinit_once_control = PTHREAD_ONCE_INIT; static void dd_initialize_request(void) { - LOG(DEBUG, "dd_initialize_request"); DDTRACE_G(distributed_trace_id) = (ddtrace_trace_id){0}; DDTRACE_G(distributed_parent_trace_id) = 0; DDTRACE_G(additional_global_tags) = zend_new_array(0); @@ -1635,12 +1634,10 @@ static void dd_initialize_request(void) { ddtrace_apply_distributed_tracing_result(&distributed_result, NULL); if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { - LOG(DEBUG, "Inferred proxy services enabled"); ddtrace_infer_proxy_services(); } if (get_DD_TRACE_GENERATE_ROOT_SPAN()) { - LOG(DEBUG, "Root span generation enabled"); ddtrace_push_root_span(); } } @@ -2780,7 +2777,6 @@ PHP_FUNCTION(DDTrace_start_inferred_span) { RETURN_NULL(); } - LOG(DEBUG, "Starting inferred span"); ddtrace_root_span_data *root_span = ddtrace_open_inferred_span(headers); if (root_span) { RETURN_OBJ_COPY(&root_span->std); diff --git a/ext/serializer.c b/ext/serializer.c index 0a3b136201..2c39ed133c 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -683,9 +683,6 @@ void ddtrace_inherit_span_properties(ddtrace_span_data *span, ddtrace_span_data zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_COPY(prop_service, &parent->property_service); - LOG(DEBUG, "Inherited service name: %s", Z_STRVAL_P(prop_service)); - } else { - LOG(DEBUG, "Child of inferred span; not inheriting service name"); } zval *prop_type = &span->property_type; @@ -826,7 +823,6 @@ void ddtrace_set_root_span_properties(ddtrace_root_span_data *span) { ZVAL_STR(prop_name, ddtrace_default_service_name()); zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, ZSTR_LEN(get_DD_SERVICE()) ? get_DD_SERVICE() : Z_STR_P(prop_name)); - LOG(DEBUG, "Service set to %s when setting root span properties", ZSTR_VAL(Z_STR_P(prop_service))); zend_string *version = get_DD_VERSION(); @@ -1318,16 +1314,13 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv zend_array *service_mappings = get_DD_SERVICE_MAPPING(); zval *new_root_name = zend_hash_find(service_mappings, Z_STR(prop_root_service_as_string)); if (new_root_name) { - LOG(DEBUG, "New root service name found: %s", Z_STRVAL_P(new_root_name)); zend_string_release(Z_STR(prop_root_service_as_string)); ZVAL_COPY(&prop_root_service_as_string, new_root_name); } if (!zend_string_equals_ci(Z_STR(prop_service_as_string), Z_STR(prop_root_service_as_string))) { - LOG(DEBUG, "Setting _dd.base_service to %s", Z_STRVAL(prop_root_service_as_string)); add_assoc_str(meta, "_dd.base_service", Z_STR(prop_root_service_as_string)); } else { - LOG(DEBUG, "Service name matches root service name; not adding _dd.base_service"); zend_string_release(Z_STR(prop_root_service_as_string)); } diff --git a/ext/span.c b/ext/span.c index 47e9b09838..9e286f2393 100644 --- a/ext/span.c +++ b/ext/span.c @@ -45,9 +45,9 @@ static void dd_drop_span_nodestroy(ddtrace_span_data *span, bool silent) { if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(DEBUG, "Dropping root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); + LOG(SPAN_TRACE, "Dropping root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); } else { - LOG(DEBUG, "Dropping span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(SPAN_TRACE, "Dropping span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); } } @@ -225,8 +225,6 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { zval *prop_service = &span->property_service; zval_ptr_dtor(prop_service); ZVAL_STR_COPY(prop_service, ZSTR_LEN(get_DD_SERVICE()) ? get_DD_SERVICE() : Z_STR_P(prop_name)); - LOG(DEBUG, "Setting child of inferred span's service to: %s", ZSTR_VAL(Z_STR_P(prop_service))); - LOG(DEBUG, "Root span's service is: %s", ZSTR_VAL(Z_STR_P(&DDTRACE_G(active_stack)->root_span->span.property_service))); } else { // do not copy the parent, it was active span before, just transfer that reference ZVAL_OBJ(&span->property_parent, &parent_span->std); @@ -239,13 +237,13 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { if (root_span) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(DEBUG, "Starting new root span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d, parent_SpanStack=%d", Z_STRVAL(root->property_trace_id), span->span_id, root->parent_id, root->stack->std.handle, root->stack->parent_stack->std.handle); + LOG(SPAN_TRACE, "Starting new root span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d, parent_SpanStack=%d", Z_STRVAL(root->property_trace_id), span->span_id, root->parent_id, root->stack->std.handle, root->stack->parent_stack->std.handle); if (ddtrace_span_is_entrypoint_root(span)) { ddtrace_sidecar_submit_root_span_data(); } } else { - LOG(DEBUG, "Starting new span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d", Z_STRVAL(span->root->property_trace_id), span->span_id, SPANDATA(span->parent)->span_id, span->stack->std.handle); + LOG(SPAN_TRACE, "Starting new span: trace_id=%s, span_id=%" PRIu64 ", parent_id=%" PRIu64 ", SpanStack=%d", Z_STRVAL(span->root->property_trace_id), span->span_id, SPANDATA(span->parent)->span_id, span->stack->std.handle); } return span; @@ -337,9 +335,9 @@ void ddtrace_clear_execute_data_span(zend_ulong index, bool keep) { void ddtrace_switch_span_stack(ddtrace_span_stack *target_stack) { if (target_stack->active) { ddtrace_span_data *span = SPANDATA(target_stack->active); - LOG(DEBUG, "Switching to different SpanStack: %d, top of stack: trace_id=%s, span_id=%" PRIu64, target_stack->std.handle, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(SPAN_TRACE, "Switching to different SpanStack: %d, top of stack: trace_id=%s, span_id=%" PRIu64, target_stack->std.handle, Z_STRVAL(span->root->property_trace_id), span->span_id); } else { - LOG(DEBUG, "Switching to different SpanStack: %d", target_stack->std.handle); + LOG(SPAN_TRACE, "Switching to different SpanStack: %d", target_stack->std.handle); } GC_ADDREF(&target_stack->std); @@ -374,7 +372,7 @@ ddtrace_span_stack *ddtrace_init_root_span_stack(void) { span_stack->root_stack = span_stack; span_stack->root_span = NULL; - LOG(DEBUG, "Creating new root SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); + LOG(SPAN_TRACE, "Creating new root SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); return span_stack; } @@ -386,7 +384,7 @@ ddtrace_span_stack *ddtrace_init_span_stack(void) { span_stack->root_stack = DDTRACE_G(active_stack)->root_stack; span_stack->root_span = DDTRACE_G(active_stack)->root_span; - LOG(DEBUG, "Creating new SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); + LOG(SPAN_TRACE, "Creating new SpanStack: %d, parent_stack: %d", span_stack->std.handle, span_stack->parent_stack ? span_stack->parent_stack->std.handle : 0); return span_stack; } @@ -642,9 +640,9 @@ void ddtrace_close_top_span_without_stack_swap(ddtrace_span_data *span) { if (span->std.ce == ddtrace_ce_root_span_data) { ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - LOG(DEBUG, "Closing root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); + LOG(SPAN_TRACE, "Closing root span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(root->property_trace_id), span->span_id); } else { - LOG(DEBUG, "Closing span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); + LOG(SPAN_TRACE, "Closing span: trace_id=%s, span_id=%" PRIu64, Z_STRVAL(span->root->property_trace_id), span->span_id); } if (!stack->active || SPANDATA(stack->active)->stack != stack) { @@ -687,7 +685,7 @@ void ddtrace_close_all_open_spans(bool force_close_root_span) { ddtrace_span_data *span; while (stack->active && (span = SPANDATA(stack->active))->stack == stack) { - LOG(DEBUG, "Automatically finishing the next span (in shutdown or force flush requested)"); + LOG(SPAN_TRACE, "Automatically finishing the next span (in shutdown or force flush requested)"); if (get_DD_AUTOFINISH_SPANS() || (force_close_root_span && (span->type == DDTRACE_AUTOROOT_SPAN || span->type == DDTRACE_INFERRED_SPAN))) { dd_trace_stop_span_time(span); ddtrace_close_span(span); From 43f3bf1ce8eed1543ea9de36c4a1e9922c463bb2 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Wed, 19 Feb 2025 14:55:56 +0100 Subject: [PATCH 37/46] style: Remove some debug logs --- .../Roadrunner/RoadrunnerIntegration.php | 28 ++++++------------- .../Integrations/Swoole/SwooleIntegration.php | 7 +---- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php b/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php index 70e3105c5d..6941c7c4f5 100644 --- a/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php +++ b/src/DDTrace/Integrations/Roadrunner/RoadrunnerIntegration.php @@ -4,7 +4,6 @@ use DDTrace\HookData; use DDTrace\Integrations\Integration; -use DDTrace\Log\Logger; use DDTrace\Tag; use DDTrace\Type; use DDTrace\Util\Normalizer; @@ -158,28 +157,22 @@ function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse, return; } - $inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED'); - $inferredSpan = null; - if ($inferredProxyServicesEnabled && $retval && $retval->headers) { - // $retval->headers is an array of arrays, so we need to flatten it - // for instance: "X-Dd-Proxy" -> {0: "aws-apigateway"} - // should become: "x-dd-proxy" -> "aws-apigateway" - $headers = []; + $headers = []; + if ($retval) { foreach ($retval->headers as $headername => $header) { - $header = implode(", ", $header); // Headers that we are interested in should be single-valued + $header = implode(", ", $header); $headers[strtolower($headername)] = $header; } - Logger::get()->debug(var_export($headers, true)); - // Convert $retval->headers keys to lowercase + } + + $inferredProxyServicesEnabled = \dd_trace_env_config('DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED'); + $inferredSpan = null; + if ($inferredProxyServicesEnabled && $headers) { $inferredSpan = \DDTrace\start_inferred_span($headers); - Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no")); } $hook->data['inferredSpan'] = $inferredSpan; - Logger::get()->debug("Starting request span"); $activeSpan = $inferredSpan ? \DDTrace\start_span() : \DDTrace\start_trace_span(); - Logger::get()->debug("Active Span ID: " . $activeSpan->id); - Logger::get()->debug("Created root span"); $activeSpan->service = $service; $activeSpan->name = "web.request"; @@ -199,11 +192,6 @@ function (HookData $hook) use (&$inferredSpan, &$activeSpan, &$suppressResponse, $activeSpan = null; $inferredSpan = null; } else { - $headers = []; - foreach ($retval->headers as $headername => $header) { - $header = implode(", ", $header); - $headers[strtolower($headername)] = $header; - } \DDTrace\consume_distributed_tracing_headers(function ($headername) use ($headers) { return $headers[$headername] ?? null; }); diff --git a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php index 2a11fbb2e1..a0aafd81d5 100644 --- a/src/DDTrace/Integrations/Swoole/SwooleIntegration.php +++ b/src/DDTrace/Integrations/Swoole/SwooleIntegration.php @@ -4,7 +4,6 @@ use DDTrace\HookData; use DDTrace\Integrations\Integration; -use DDTrace\Log\Logger; use DDTrace\SpanStack; use DDTrace\Tag; use DDTrace\Type; @@ -44,12 +43,10 @@ function (HookData $hook) use ($integration, $server, $scheme) { $inferredSpan = null; if ($inferredProxyServicesEnabled) { $inferredSpan = \DDTrace\start_inferred_span($request->header); - Logger::get()->debug("Inferred span? " . ($inferredSpan ? "yes" : "no")); } $hook->data['inferredSpan'] = $inferredSpan; $rootSpan = $hook->span($inferredSpan ?: new SpanStack()); - Logger::get()->debug("Created root span"); $rootSpan->name = "web.request"; $rootSpan->service = \ddtrace_config_app_name('swoole'); $rootSpan->type = Type::WEB_SERVLET; @@ -117,12 +114,10 @@ function (HookData $hook) use ($integration, $server, $scheme) { function (HookData $hook) { $inferredSpan = $hook->data['inferredSpan']; if ($inferredSpan) { - Logger::get()->debug("Closing inferred span"); $autofinishConfig = ini_get('datadog.autofinish_spans'); ini_set('datadog.autofinish_spans', 'true'); + \DDTrace\switch_stack($inferredSpan); dd_trace_close_all_spans_and_flush(); - //dd_trace_synchronous_flush(1); - //set_distributed_tracing_context("0", "0"); ini_set('datadog.autofinish_spans', $autofinishConfig); } } From d39e0b7665008e3f0f1263558fa261b09b6c6a5f Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 20 Feb 2025 10:07:14 +0100 Subject: [PATCH 38/46] style: Change x-dd-proxy value from aws-apigateway to aws.apigateway --- tests/Integrations/Laravel/APIGWTest.php | 4 ++-- tests/Integrations/Laravel/Octane/APIGWTest.php | 8 ++++---- tests/Integrations/Roadrunner/APIGWTest.php | 4 ++-- tests/ext/inferred_proxy/alter_service.phpt | 4 ++-- tests/ext/inferred_proxy/basic_test.phpt | 4 ++-- tests/ext/inferred_proxy/distributed_tracing.phpt | 4 ++-- tests/ext/inferred_proxy/error_propagated.phpt | 4 ++-- ...tegrations.laravel.apigw_test.test_inferred_proxy.json | 2 +- ....laravel.apigw_test.test_inferred_proxy_exception.json | 2 +- ...ons.laravel.octane.apigw_test.test_inferred_proxy.json | 4 ++-- ...l.octane.apigw_test.test_inferred_proxy_exception.json | 4 ++-- ...rations.roadrunner.apigw_test.test_inferred_proxy.json | 4 ++-- ...adrunner.apigw_test.test_inferred_proxy_exception.json | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/Integrations/Laravel/APIGWTest.php b/tests/Integrations/Laravel/APIGWTest.php index 57af97cc6c..c09c1c5394 100644 --- a/tests/Integrations/Laravel/APIGWTest.php +++ b/tests/Integrations/Laravel/APIGWTest.php @@ -35,7 +35,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -55,7 +55,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', diff --git a/tests/Integrations/Laravel/Octane/APIGWTest.php b/tests/Integrations/Laravel/Octane/APIGWTest.php index 61272f5a52..e42c0aa890 100644 --- a/tests/Integrations/Laravel/Octane/APIGWTest.php +++ b/tests/Integrations/Laravel/Octane/APIGWTest.php @@ -77,7 +77,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -90,7 +90,7 @@ public function testInferredProxy() $apigwTrace = null; foreach ($traces as $trace) { - if ($trace[0]["name"] === "aws-apigateway") { + if ($trace[0]["name"] === "aws.apigateway") { $apigwTrace = $trace; break; } @@ -126,7 +126,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -139,7 +139,7 @@ public function testInferredProxyException() $apigwTrace = null; foreach ($traces as $trace) { - if ($trace[0]["name"] === "aws-apigateway") { + if ($trace[0]["name"] === "aws.apigateway") { $apigwTrace = $trace; break; } diff --git a/tests/Integrations/Roadrunner/APIGWTest.php b/tests/Integrations/Roadrunner/APIGWTest.php index 8bec3ff722..a3e1ff0fab 100644 --- a/tests/Integrations/Roadrunner/APIGWTest.php +++ b/tests/Integrations/Roadrunner/APIGWTest.php @@ -48,7 +48,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -70,7 +70,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws-apigateway', + 'x-dd-proxy: aws.apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', diff --git a/tests/ext/inferred_proxy/alter_service.phpt b/tests/ext/inferred_proxy/alter_service.phpt index 3f81c61f17..7b60ba15b5 100644 --- a/tests/ext/inferred_proxy/alter_service.phpt +++ b/tests/ext/inferred_proxy/alter_service.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY=aws.apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET @@ -58,7 +58,7 @@ echo json_encode($body, JSON_PRETTY_PRINT); "span_id": "13930160852258120406", "start": 100000000, "duration": %d, - "name": "aws-apigateway", + "name": "aws.apigateway", "resource": "GET \/test", "service": "example.com", "type": "web", diff --git a/tests/ext/inferred_proxy/basic_test.phpt b/tests/ext/inferred_proxy/basic_test.phpt index d130e78b12..8a2a79b405 100644 --- a/tests/ext/inferred_proxy/basic_test.phpt +++ b/tests/ext/inferred_proxy/basic_test.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY=aws.apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET @@ -58,7 +58,7 @@ echo json_encode($body, JSON_PRETTY_PRINT); "span_id": "13930160852258120406", "start": 100000000, "duration": %d, - "name": "aws-apigateway", + "name": "aws.apigateway", "resource": "GET \/test", "service": "example.com", "type": "web", diff --git a/tests/ext/inferred_proxy/distributed_tracing.phpt b/tests/ext/inferred_proxy/distributed_tracing.phpt index 8edb6c8e1b..d19d783b66 100644 --- a/tests/ext/inferred_proxy/distributed_tracing.phpt +++ b/tests/ext/inferred_proxy/distributed_tracing.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY=aws.apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET @@ -64,7 +64,7 @@ echo json_encode($body, JSON_PRETTY_PRINT); "parent_id": "2", "start": 100000000, "duration": %d, - "name": "aws-apigateway", + "name": "aws.apigateway", "resource": "GET \/test", "service": "example.com", "type": "web", diff --git a/tests/ext/inferred_proxy/error_propagated.phpt b/tests/ext/inferred_proxy/error_propagated.phpt index a97561501e..4ede281bc9 100644 --- a/tests/ext/inferred_proxy/error_propagated.phpt +++ b/tests/ext/inferred_proxy/error_propagated.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws-apigateway +HTTP_X_DD_PROXY=aws.apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET @@ -68,7 +68,7 @@ echo json_encode($body, JSON_PRETTY_PRINT); "span_id": "13930160852258120406", "start": 100000000, "duration": %d, - "name": "aws-apigateway", + "name": "aws.apigateway", "resource": "GET \/test", "service": "example.com", "type": "web", diff --git a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json index 8daf4dc10c..20c7419bd9 100644 --- a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /test", "trace_id": 0, diff --git a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json index 3fa84d6480..ed8b71ce04 100644 --- a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /test", "trace_id": 0, diff --git a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json index 93e1278665..501b1011e0 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /test", "trace_id": 0, @@ -37,7 +37,7 @@ "component": "laravel", "env": "local-test", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy": "aws.apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json index 19fd67b161..a0d241c1ba 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /test", "trace_id": 0, @@ -45,7 +45,7 @@ "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/ApplicationGateway.php(36): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/Worker.php(84): Laravel\\Octane\\ApplicationGateway->handle()\n#46 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(122): Laravel\\Octane\\Worker->handle()\n#47 [internal function]: {closure}()\n#48 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(172): Swoole\\Server->start()\n#49 {main}", "error.type": "Exception", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy": "aws.apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json index 8458538d17..debb3d6242 100644 --- a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /simple", "trace_id": 0, @@ -14,7 +14,7 @@ "component": "aws-apigateway", "env": "local-test", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy": "aws.apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json index cb69b66762..2b2b3da7dc 100644 --- a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json @@ -1,6 +1,6 @@ [[ { - "name": "aws-apigateway", + "name": "aws.apigateway", "service": "example.com", "resource": "GET /error", "trace_id": 0, @@ -18,7 +18,7 @@ "error.stack": "#0 {main}", "error.type": "Exception", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws-apigateway", + "http.request.headers.x-dd-proxy": "aws.apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", From 6aecc1f6377a579bf8f6509023b58adcf7d11a00 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 20 Feb 2025 10:56:25 +0100 Subject: [PATCH 39/46] style: Remove duration from serialization debug logs --- ext/serializer.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/serializer.c b/ext/serializer.c index fd0f8b7c18..1cf29186c9 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1806,17 +1806,14 @@ void ddtrace_serialize_span_to_array(ddtrace_span_data *span, zval *array) { smart_str_0(&metrics_str); } prop_name = zend_hash_str_find(Z_ARR_P(el), ZEND_STRL("name")); // refetch, array may have been rehashed - log("Encoding span %" PRIu64 ": trace_id=%s, name='%s', service='%s', resource: '%s', type '%s' with tags: %s; metrics: %s; start: %ld; duration_start: %ld, and duration: %ld", + log("Encoding span %" PRIu64 ": trace_id=%s, name='%s', service='%s', resource: '%s', type '%s' with tags: %s; and metrics: %s", span->span_id, Z_STRVAL(span->root->property_trace_id), prop_name && Z_TYPE_P(prop_name) == IS_STRING ? Z_STRVAL_P(prop_name) : "", Z_TYPE(prop_service_as_string) == IS_STRING ? Z_STRVAL(prop_service_as_string) : "", Z_TYPE(prop_resource_as_string) == IS_STRING ? Z_STRVAL(prop_resource_as_string) : "", Z_TYPE(prop_type_as_string) == IS_STRING ? Z_STRVAL(prop_type_as_string) : "", meta_str.s ? ZSTR_VAL(meta_str.s) : "-", - metrics_str.s ? ZSTR_VAL(metrics_str.s) : "-", - span->start, - span->duration_start, - span->duration); + metrics_str.s ? ZSTR_VAL(metrics_str.s) : "-"); smart_str_free(&meta_str); smart_str_free(&metrics_str); }) From 926dd2be3796ce2391939b09ddcb27029048c6ba Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 20 Feb 2025 15:07:23 +0100 Subject: [PATCH 40/46] fix: Prevent segfaults/mem leak on missing headers --- ext/span.c | 32 +++++-- .../inferred_proxy/incomplete_headers.phpt | 93 +++++++++++++++++++ 2 files changed, 115 insertions(+), 10 deletions(-) create mode 100644 tests/ext/inferred_proxy/incomplete_headers.phpt diff --git a/ext/span.c b/ext/span.c index 9e286f2393..e07458c441 100644 --- a/ext/span.c +++ b/ext/span.c @@ -830,7 +830,13 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { ddtrace_read_header *read_header = headers ? ddtrace_read_array_header : ddtrace_read_zai_header; ddtrace_inferred_proxy_result result = ddtrace_read_inferred_proxy_headers(read_header, headers); - if (!result.system || !result.start_time_ms ) { + if (!result.system || !result.start_time_ms) { + if (result.system) { + zend_string_release(result.system); + } + if (result.start_time_ms) { + zend_string_release(result.start_time_ms); + } return NULL; } @@ -842,7 +848,9 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { ddtrace_assign_variable(&span->property_name, &zv); zval_ptr_dtor(&span->property_resource); - ZVAL_STR(&span->property_resource, strpprintf(0, "%s %s", ZSTR_VAL(result.http_method), ZSTR_VAL(result.path))); + if (result.http_method && result.path) { + ZVAL_STR(&span->property_resource, strpprintf(0, "%s %s", ZSTR_VAL(result.http_method), ZSTR_VAL(result.path))); + } span->start = (zend_long)zend_strtod(ZSTR_VAL(result.start_time_ms), NULL) * 1000000; span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); @@ -854,11 +862,15 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { zend_array *meta = ddtrace_property_array(&span->property_meta); - ZVAL_STR_COPY(&zv, result.http_method); - zend_hash_str_add_new(meta, ZEND_STRL("http.method"), &zv); + if (result.http_method) { + ZVAL_STR_COPY(&zv, result.http_method); + zend_hash_str_add_new(meta, ZEND_STRL("http.method"), &zv); + } - ZVAL_STR(&zv, strpprintf(0, "%s%s", ZSTR_VAL(result.domain), ZSTR_VAL(result.path))); - zend_hash_str_add_new(meta, ZEND_STRL("http.url"), &zv); + if (result.domain && result.path) { + ZVAL_STR(&zv, strpprintf(0, "%s%s", ZSTR_VAL(result.domain), ZSTR_VAL(result.path))); + zend_hash_str_add_new(meta, ZEND_STRL("http.url"), &zv); + } if (result.stage) { ZVAL_STR_COPY(&zv, result.stage); @@ -869,10 +881,10 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { add_assoc_string(&span->property_meta, "component", "aws-apigateway"); zend_string_release(result.start_time_ms); - zend_string_release(result.path); - zend_string_release(result.http_method); - zend_string_release(result.domain); - zend_string_release(result.stage); + if (result.path) zend_string_release(result.path); + if (result.http_method) zend_string_release(result.http_method); + if (result.domain) zend_string_release(result.domain); + if (result.stage) zend_string_release(result.stage); return ROOTSPANDATA(&span->std); } diff --git a/tests/ext/inferred_proxy/incomplete_headers.phpt b/tests/ext/inferred_proxy/incomplete_headers.phpt new file mode 100644 index 0000000000..53c50c93da --- /dev/null +++ b/tests/ext/inferred_proxy/incomplete_headers.phpt @@ -0,0 +1,93 @@ +--TEST-- +Should create parent and child spans for a 200 +--ENV-- +DD_TRACE_AUTO_FLUSH_ENABLED=0 +DD_TRACE_GENERATE_ROOT_SPAN=0 +DD_AUTOFINISH_SPANS=1 +DD_SERVICE=aws-server +DD_ENV=local-prod +DD_VERSION=1.0 + +DD_TRACE_DEBUG=0 + +DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 +HTTP_X_DD_PROXY=aws.apigateway + +METHOD=GET +SERVER_NAME=localhost:8888 +SCRIPT_NAME=/foo.php +REQUEST_URI=/foo + +DD_AGENT_HOST=request-replayer +DD_TRACE_AGENT_PORT=80 +DD_TRACE_AGENT_FLUSH_AFTER_N_REQUESTS=1 +DD_TRACE_AGENT_FLUSH_INTERVAL=666 +DD_INSTRUMENTATION_TELEMETRY_ENABLED=0 + +DD_TRACE_DEBUG_PRNG_SEED=42 +--GET-- +foo=bar +--FILE-- +name = "child"; + +dd_trace_close_all_spans_and_flush(); // Simulates end of request + +$body = json_decode($rr->waitForDataAndReplay()["body"], true); +echo json_encode($body, JSON_PRETTY_PRINT); +?> +--EXPECTF-- +[ + [ + { + "trace_id": "13930160852258120406", + "span_id": "13930160852258120406", + "start": 120000000, + "duration": %d, + "name": "web.request", + "resource": "GET \/foo", + "service": "aws-server", + "type": "web", + "meta": { + "runtime-id": "%s", + "http.url": "http:\/\/localhost:8888\/foo", + "http.method": "GET", + "_dd.p.dm": "-0", + "env": "local-prod", + "version": "1.0", + "http.status_code": "200", + "_dd.p.tid": "%s" + }, + "metrics": { + "process_id": %d, + "_dd.agent_psr": 1, + "_sampling_priority_v1": 1, + "php.compilation.total_time_ms": %f, + "php.memory.peak_usage_bytes": %f, + "php.memory.peak_real_usage_bytes": %f + } + }, + { + "trace_id": "13930160852258120406", + "span_id": "11788048577503494824", + "parent_id": "13930160852258120406", + "start": 130000000, + "duration": %d, + "name": "child", + "resource": "child", + "service": "aws-server", + "type": "web", + "meta": { + "env": "local-prod", + "version": "1.0" + } + } + ] +] \ No newline at end of file From bdb31b57ee28ef352762f7298af32ad3f7ad011d Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 20 Feb 2025 15:07:46 +0100 Subject: [PATCH 41/46] style: one-liner --- ext/span.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ext/span.c b/ext/span.c index e07458c441..6448610bec 100644 --- a/ext/span.c +++ b/ext/span.c @@ -831,12 +831,8 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { ddtrace_inferred_proxy_result result = ddtrace_read_inferred_proxy_headers(read_header, headers); if (!result.system || !result.start_time_ms) { - if (result.system) { - zend_string_release(result.system); - } - if (result.start_time_ms) { - zend_string_release(result.start_time_ms); - } + if (result.system) zend_string_release(result.system); + if (result.start_time_ms) zend_string_release(result.start_time_ms); return NULL; } From e5707d727fd6852c885d02e2cf6462cea73892b7 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 20 Feb 2025 15:16:39 +0100 Subject: [PATCH 42/46] style: change test description --- tests/ext/inferred_proxy/incomplete_headers.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ext/inferred_proxy/incomplete_headers.phpt b/tests/ext/inferred_proxy/incomplete_headers.phpt index 53c50c93da..ff313243d4 100644 --- a/tests/ext/inferred_proxy/incomplete_headers.phpt +++ b/tests/ext/inferred_proxy/incomplete_headers.phpt @@ -1,5 +1,5 @@ --TEST-- -Should create parent and child spans for a 200 +An Inferred Span should not be created on missing headers --ENV-- DD_TRACE_AUTO_FLUSH_ENABLED=0 DD_TRACE_GENERATE_ROOT_SPAN=0 From aaac75357a903781515d8c97fcb96ef37d93d4ab Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Fri, 21 Feb 2025 09:56:40 +0100 Subject: [PATCH 43/46] Add a hashmap of supported proxies --- ext/ddtrace.c | 9 ++++++ ext/inferred_proxy_headers.c | 31 ++++++++++++++++++- ext/inferred_proxy_headers.h | 8 +++++ ext/span.c | 18 ++++++++--- tests/Integrations/Laravel/APIGWTest.php | 9 +++--- .../Integrations/Laravel/Octane/APIGWTest.php | 4 +-- tests/Integrations/Roadrunner/APIGWTest.php | 4 +-- tests/ext/inferred_proxy/alter_service.phpt | 2 +- tests/ext/inferred_proxy/basic_test.phpt | 2 +- .../inferred_proxy/distributed_tracing.phpt | 2 +- .../ext/inferred_proxy/error_propagated.phpt | 2 +- .../inferred_proxy/incomplete_headers.phpt | 2 +- ...igw_test.test_laravel_inferred_proxy.json} | 0 ...est_laravel_inferred_proxy_exception.json} | 0 ...octane.apigw_test.test_inferred_proxy.json | 2 +- ...gw_test.test_inferred_proxy_exception.json | 2 +- ...runner.apigw_test.test_inferred_proxy.json | 2 +- ...gw_test.test_inferred_proxy_exception.json | 2 +- 18 files changed, 77 insertions(+), 24 deletions(-) rename tests/snapshots/{tests.integrations.laravel.apigw_test.test_inferred_proxy.json => tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy.json} (100%) rename tests/snapshots/{tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json => tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy_exception.json} (100%) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index 1c5d4f6ec5..b0b6f6a006 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -100,6 +100,7 @@ #endif #include "ddtrace_arginfo.h" #include "distributed_tracing_headers.h" +#include "inferred_proxy_headers.h" #include "live_debugger.h" #include "agent_info.h" @@ -1659,6 +1660,10 @@ static PHP_RINIT_FUNCTION(ddtrace) { #endif } + if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + ddtrace_init_proxy_info_map(); + } + if (get_DD_TRACE_ENABLED()) { dd_initialize_request(); } @@ -1803,6 +1808,10 @@ static PHP_RSHUTDOWN_FUNCTION(ddtrace) { ddtrace_clean_git_object(); + if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { + ddtrace_free_proxy_info_map(); + } + return SUCCESS; } diff --git a/ext/inferred_proxy_headers.c b/ext/inferred_proxy_headers.c index c1420a16b5..c20b0ec5a4 100644 --- a/ext/inferred_proxy_headers.c +++ b/ext/inferred_proxy_headers.c @@ -2,6 +2,31 @@ ZEND_EXTERN_MODULE_GLOBALS(ddtrace); +static HashTable proxy_info_map; + +void ddtrace_add_proxy_info(const char *system, const char *span_name, const char *component) { + ddtrace_proxy_info *info = emalloc(sizeof(ddtrace_proxy_info)); + info->span_name = span_name; + info->component = component; + zend_hash_str_add_ptr(&proxy_info_map, system, strlen(system), info); +} + +void ddtrace_init_proxy_info_map(void) { + zend_hash_init(&proxy_info_map, 8, NULL, NULL, 1); + + ddtrace_add_proxy_info("aws-apigateway", "aws.apigateway", "aws-apigateway"); + + // Add more proxies using ddtrace_add_proxy_info +} + +void ddtrace_free_proxy_info_map(void) { + ddtrace_proxy_info *info; + ZEND_HASH_FOREACH_PTR(&proxy_info_map, info) { + efree(info); + } ZEND_HASH_FOREACH_END(); + zend_hash_destroy(&proxy_info_map); +} + ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data) { ddtrace_inferred_proxy_result result = {0}; @@ -13,4 +38,8 @@ ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_h read_header((zai_str)ZAI_STRL("X_DD_PROXY_STAGE"), "x-dd-proxy-stage", &result.stage, data); return result; -} \ No newline at end of file +} + +const ddtrace_proxy_info* ddtrace_get_proxy_info(zend_string *system) { + return zend_hash_find_ptr(&proxy_info_map, system); +} diff --git a/ext/inferred_proxy_headers.h b/ext/inferred_proxy_headers.h index 97f4ed8836..2b77cfa323 100644 --- a/ext/inferred_proxy_headers.h +++ b/ext/inferred_proxy_headers.h @@ -13,6 +13,14 @@ typedef struct { zend_string *stage; } ddtrace_inferred_proxy_result; +typedef struct { + const char *span_name; + const char *component; +} ddtrace_proxy_info; + ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data); +const ddtrace_proxy_info* ddtrace_get_proxy_info(zend_string *system); +void ddtrace_init_proxy_info_map(void); +void ddtrace_free_proxy_info_map(void); #endif // DD_INFERRED_PROXY_HEADERS_H \ No newline at end of file diff --git a/ext/span.c b/ext/span.c index 6448610bec..37db2e2325 100644 --- a/ext/span.c +++ b/ext/span.c @@ -836,12 +836,17 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { return NULL; } - ddtrace_span_data *span = ddtrace_push_inferred_root_span(); + const ddtrace_proxy_info *proxy_info = ddtrace_get_proxy_info(result.system); + if (!proxy_info) { + zend_string_release(result.system); + zend_string_release(result.start_time_ms); + return NULL; + } - zval zv; + ddtrace_span_data *span = ddtrace_push_inferred_root_span(); - ZVAL_STR(&zv, result.system); - ddtrace_assign_variable(&span->property_name, &zv); + zval_ptr_dtor(&span->property_name); + ZVAL_STR(&span->property_name, zend_string_init(proxy_info->span_name, strlen(proxy_info->span_name), 0)); zval_ptr_dtor(&span->property_resource); if (result.http_method && result.path) { @@ -851,6 +856,8 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { span->start = (zend_long)zend_strtod(ZSTR_VAL(result.start_time_ms), NULL) * 1000000; span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); + zval zv; + if (result.domain) { ZVAL_STR_COPY(&zv, result.domain); ddtrace_assign_variable(&span->property_service, &zv); @@ -874,8 +881,9 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { } add_assoc_long(&span->property_meta, "_dd.inferred_span", 1); - add_assoc_string(&span->property_meta, "component", "aws-apigateway"); + add_assoc_string(&span->property_meta, "component", proxy_info->component); + zend_string_release(result.system); zend_string_release(result.start_time_ms); if (result.path) zend_string_release(result.path); if (result.http_method) zend_string_release(result.http_method); diff --git a/tests/Integrations/Laravel/APIGWTest.php b/tests/Integrations/Laravel/APIGWTest.php index c09c1c5394..873bf75f73 100644 --- a/tests/Integrations/Laravel/APIGWTest.php +++ b/tests/Integrations/Laravel/APIGWTest.php @@ -23,11 +23,10 @@ protected static function getEnvs() 'DD_ENV' => 'local-test', 'DD_VERSION' => '1.0', 'DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED' => 'true', - //'DD_TRACE_HEADER_TAGS' => 'x-dd-proxy-domain-name,x-dd-proxy,x-dd-proxy-httpmethod,x-dd-proxy-path,x-dd-proxy-request-time-ms,x-dd-proxy-stage', ]); } - public function testInferredProxy() + public function testLaravelInferredProxy() { $this->tracesFromWebRequestSnapshot(function () { $this->call( @@ -35,7 +34,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -47,7 +46,7 @@ public function testInferredProxy() }); } - public function testInferredProxyException() + public function testLaravelInferredProxyException() { $this->tracesFromWebRequestSnapshot(function () { $this->call( @@ -55,7 +54,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', diff --git a/tests/Integrations/Laravel/Octane/APIGWTest.php b/tests/Integrations/Laravel/Octane/APIGWTest.php index e42c0aa890..e62c90bdf6 100644 --- a/tests/Integrations/Laravel/Octane/APIGWTest.php +++ b/tests/Integrations/Laravel/Octane/APIGWTest.php @@ -77,7 +77,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -126,7 +126,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', diff --git a/tests/Integrations/Roadrunner/APIGWTest.php b/tests/Integrations/Roadrunner/APIGWTest.php index a3e1ff0fab..8bec3ff722 100644 --- a/tests/Integrations/Roadrunner/APIGWTest.php +++ b/tests/Integrations/Roadrunner/APIGWTest.php @@ -48,7 +48,7 @@ public function testInferredProxy() 'A simple GET request returning a string', '/simple?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', @@ -70,7 +70,7 @@ public function testInferredProxyException() 'A GET throwing an exception', '/error?key=value&pwd=should_redact', [ - 'x-dd-proxy: aws.apigateway', + 'x-dd-proxy: aws-apigateway', 'x-dd-proxy-request-time-ms: 1739261376000', 'x-dd-proxy-path: /test', 'x-dd-proxy-httpmethod: GET', diff --git a/tests/ext/inferred_proxy/alter_service.phpt b/tests/ext/inferred_proxy/alter_service.phpt index 7b60ba15b5..be589fc18d 100644 --- a/tests/ext/inferred_proxy/alter_service.phpt +++ b/tests/ext/inferred_proxy/alter_service.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws.apigateway +HTTP_X_DD_PROXY=aws-apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET diff --git a/tests/ext/inferred_proxy/basic_test.phpt b/tests/ext/inferred_proxy/basic_test.phpt index 8a2a79b405..06b26a30f3 100644 --- a/tests/ext/inferred_proxy/basic_test.phpt +++ b/tests/ext/inferred_proxy/basic_test.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws.apigateway +HTTP_X_DD_PROXY=aws-apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET diff --git a/tests/ext/inferred_proxy/distributed_tracing.phpt b/tests/ext/inferred_proxy/distributed_tracing.phpt index d19d783b66..0f0c5c6b4b 100644 --- a/tests/ext/inferred_proxy/distributed_tracing.phpt +++ b/tests/ext/inferred_proxy/distributed_tracing.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws.apigateway +HTTP_X_DD_PROXY=aws-apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET diff --git a/tests/ext/inferred_proxy/error_propagated.phpt b/tests/ext/inferred_proxy/error_propagated.phpt index 4ede281bc9..e2d0c8043d 100644 --- a/tests/ext/inferred_proxy/error_propagated.phpt +++ b/tests/ext/inferred_proxy/error_propagated.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws.apigateway +HTTP_X_DD_PROXY=aws-apigateway HTTP_X_DD_PROXY_REQUEST_TIME_MS=100 HTTP_X_DD_PROXY_PATH=/test HTTP_X_DD_PROXY_HTTPMETHOD=GET diff --git a/tests/ext/inferred_proxy/incomplete_headers.phpt b/tests/ext/inferred_proxy/incomplete_headers.phpt index ff313243d4..254f88b3e2 100644 --- a/tests/ext/inferred_proxy/incomplete_headers.phpt +++ b/tests/ext/inferred_proxy/incomplete_headers.phpt @@ -11,7 +11,7 @@ DD_VERSION=1.0 DD_TRACE_DEBUG=0 DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED=1 -HTTP_X_DD_PROXY=aws.apigateway +HTTP_X_DD_PROXY=aws-apigateway METHOD=GET SERVER_NAME=localhost:8888 diff --git a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy.json similarity index 100% rename from tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy.json rename to tests/snapshots/tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy.json diff --git a/tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy_exception.json similarity index 100% rename from tests/snapshots/tests.integrations.laravel.apigw_test.test_inferred_proxy_exception.json rename to tests/snapshots/tests.integrations.laravel.apigw_test.test_laravel_inferred_proxy_exception.json diff --git a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json index 501b1011e0..664f34ff48 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy.json @@ -37,7 +37,7 @@ "component": "laravel", "env": "local-test", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws.apigateway", + "http.request.headers.x-dd-proxy": "aws-apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json index a0d241c1ba..f422be272c 100644 --- a/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.laravel.octane.apigw_test.test_inferred_proxy_exception.json @@ -45,7 +45,7 @@ "error.stack": "#0 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(47): App\\Http\\Controllers\\CommonSpecsController->error()\n#1 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(266): Illuminate\\Routing\\ControllerDispatcher->dispatch()\n#2 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\Route->runController()\n#3 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()\n#4 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()\n#5 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#6 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()\n#7 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#8 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()\n#9 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#10 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()\n#11 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#12 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()\n#13 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Session\\Middleware\\StartSession->handle()\n#14 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#15 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()\n#16 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#17 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()\n#18 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#19 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()\n#20 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()\n#21 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()\n#22 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()\n#23 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()\n#24 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(170): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()\n#25 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#26 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#27 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()\n#28 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#29 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()\n#30 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()\n#31 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#32 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()\n#33 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#34 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()\n#35 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#36 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\HandleCors->handle()\n#37 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#38 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Http\\Middleware\\TrustProxies->handle()\n#39 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#40 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(209): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()\n#41 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()\n#42 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()\n#43 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()\n#44 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/ApplicationGateway.php(36): Illuminate\\Foundation\\Http\\Kernel->handle()\n#45 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/src/Worker.php(84): Laravel\\Octane\\ApplicationGateway->handle()\n#46 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(122): Laravel\\Octane\\Worker->handle()\n#47 [internal function]: {closure}()\n#48 /home/circleci/app/tests/Frameworks/Laravel/Octane/Latest/vendor/laravel/octane/bin/swoole-server(172): Swoole\\Server->start()\n#49 {main}", "error.type": "Exception", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws.apigateway", + "http.request.headers.x-dd-proxy": "aws-apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json index debb3d6242..22d6ae651f 100644 --- a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy.json @@ -14,7 +14,7 @@ "component": "aws-apigateway", "env": "local-test", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws.apigateway", + "http.request.headers.x-dd-proxy": "aws-apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", diff --git a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json index 2b2b3da7dc..368f960024 100644 --- a/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json +++ b/tests/snapshots/tests.integrations.roadrunner.apigw_test.test_inferred_proxy_exception.json @@ -18,7 +18,7 @@ "error.stack": "#0 {main}", "error.type": "Exception", "http.method": "GET", - "http.request.headers.x-dd-proxy": "aws.apigateway", + "http.request.headers.x-dd-proxy": "aws-apigateway", "http.request.headers.x-dd-proxy-domain-name": "example.com", "http.request.headers.x-dd-proxy-httpmethod": "GET", "http.request.headers.x-dd-proxy-path": "/test", From 2a1da160ec8dd6a4aaabfb636abb8d68ebb4fb21 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 27 Feb 2025 10:24:32 +0100 Subject: [PATCH 44/46] CR refactor --- ext/ddtrace.c | 16 +++++----------- ext/inferred_proxy_headers.c | 16 ++++++---------- ext/inferred_proxy_headers.h | 1 - ext/serializer.c | 18 +++++++----------- ext/span.c | 5 ++--- ext/span.h | 7 ++++--- 6 files changed, 24 insertions(+), 39 deletions(-) diff --git a/ext/ddtrace.c b/ext/ddtrace.c index b0b6f6a006..2b759bfed8 100644 --- a/ext/ddtrace.c +++ b/ext/ddtrace.c @@ -382,7 +382,7 @@ static inline void dd_alter_prop_common(size_t prop_offset, zval *old_value, zva while (pspan) { if (skip_inferred) { ddtrace_span_data *span = SPANDATA(pspan); - if (span && span->type == DDTRACE_INFERRED_SPAN) { + if (span->type == DDTRACE_INFERRED_SPAN) { pspan = pspan->parent; // It should be NULL, but just in case... continue; } @@ -953,7 +953,7 @@ static zend_object *ddtrace_root_span_data_create(zend_class_entry *class_type) array_init(&span->property_propagated_tags); array_init(&span->property_tracestate_tags); #endif - span->child_root = NULL; + span->inferred_root = NULL; return &span->std; } @@ -1481,6 +1481,8 @@ static PHP_MINIT_FUNCTION(ddtrace) { ddtrace_minit_remote_config(); ddtrace_appsec_minit(); + ddtrace_init_proxy_info_map(); + return SUCCESS; } @@ -1660,10 +1662,6 @@ static PHP_RINIT_FUNCTION(ddtrace) { #endif } - if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { - ddtrace_init_proxy_info_map(); - } - if (get_DD_TRACE_ENABLED()) { dd_initialize_request(); } @@ -1808,10 +1806,6 @@ static PHP_RSHUTDOWN_FUNCTION(ddtrace) { ddtrace_clean_git_object(); - if (get_DD_TRACE_INFERRED_PROXY_SERVICES_ENABLED()) { - ddtrace_free_proxy_info_map(); - } - return SUCCESS; } @@ -2728,7 +2722,7 @@ PHP_FUNCTION(DDTrace_root_span) { dd_ensure_root_span(); ddtrace_root_span_data *span = DDTRACE_G(active_stack)->root_span; if (span && span->type == DDTRACE_INFERRED_SPAN) { - span = span->child_root; + span = span->inferred_root; } if (span) { diff --git a/ext/inferred_proxy_headers.c b/ext/inferred_proxy_headers.c index c20b0ec5a4..1152609998 100644 --- a/ext/inferred_proxy_headers.c +++ b/ext/inferred_proxy_headers.c @@ -5,28 +5,24 @@ ZEND_EXTERN_MODULE_GLOBALS(ddtrace); static HashTable proxy_info_map; void ddtrace_add_proxy_info(const char *system, const char *span_name, const char *component) { - ddtrace_proxy_info *info = emalloc(sizeof(ddtrace_proxy_info)); + ddtrace_proxy_info *info = pemalloc(sizeof(ddtrace_proxy_info), 1); info->span_name = span_name; info->component = component; zend_hash_str_add_ptr(&proxy_info_map, system, strlen(system), info); } +static void dd_proxy_info_dtor(zval *zv) { + pefree(Z_PTR_P(zv), 1); +} + void ddtrace_init_proxy_info_map(void) { - zend_hash_init(&proxy_info_map, 8, NULL, NULL, 1); + zend_hash_init(&proxy_info_map, 8, NULL, (dtor_func_t)dd_proxy_info_dtor, 1); ddtrace_add_proxy_info("aws-apigateway", "aws.apigateway", "aws-apigateway"); // Add more proxies using ddtrace_add_proxy_info } -void ddtrace_free_proxy_info_map(void) { - ddtrace_proxy_info *info; - ZEND_HASH_FOREACH_PTR(&proxy_info_map, info) { - efree(info); - } ZEND_HASH_FOREACH_END(); - zend_hash_destroy(&proxy_info_map); -} - ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data) { ddtrace_inferred_proxy_result result = {0}; diff --git a/ext/inferred_proxy_headers.h b/ext/inferred_proxy_headers.h index 2b77cfa323..20cfb30fcb 100644 --- a/ext/inferred_proxy_headers.h +++ b/ext/inferred_proxy_headers.h @@ -21,6 +21,5 @@ typedef struct { ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_header *read_header, void *data); const ddtrace_proxy_info* ddtrace_get_proxy_info(zend_string *system); void ddtrace_init_proxy_info_map(void); -void ddtrace_free_proxy_info_map(void); #endif // DD_INFERRED_PROXY_HEADERS_H \ No newline at end of file diff --git a/ext/serializer.c b/ext/serializer.c index 1cf29186c9..c123c6925d 100644 --- a/ext/serializer.c +++ b/ext/serializer.c @@ -1181,6 +1181,13 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv zval *exception_zv = &span->property_exception; bool has_exception = Z_TYPE_P(exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception_zv), zend_ce_throwable); + if (!has_exception && span->std.ce == ddtrace_ce_root_span_data) { // inherit exception on inferred span from child root + ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); + if (root->inferred_root) { // Can't check for DDTRACE_INFERRED_SPAN because the span is now closed + exception_zv = &root->inferred_root->span.property_exception; + has_exception = Z_TYPE_P(exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception_zv), zend_ce_throwable); + } + } if (has_exception) { ignore_error = false; enum dd_exception exception_type = DD_EXCEPTION_THROWN; @@ -1188,17 +1195,6 @@ static void _serialize_meta(zval *el, ddtrace_span_data *span, zend_string *serv exception_type = Z_PROP_FLAG_P(exception_zv) == 2 ? DD_EXCEPTION_CAUGHT : DD_EXCEPTION_UNCAUGHT; } ddtrace_exception_to_meta(Z_OBJ_P(exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); - } else if (span->std.ce == ddtrace_ce_root_span_data) { - ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - if (root->child_root) { // Can't check for DDTRACE_INFERRED_SPAN because the span is now closed - zval *child_exception_zv = &root->child_root->span.property_exception; - has_exception = Z_TYPE_P(child_exception_zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(child_exception_zv), zend_ce_throwable); - if (has_exception) { - ignore_error = false; - enum dd_exception exception_type = Z_PROP_FLAG_P(child_exception_zv) == 2 ? DD_EXCEPTION_CAUGHT : DD_EXCEPTION_UNCAUGHT; - ddtrace_exception_to_meta(Z_OBJ_P(child_exception_zv), service_name, span->start, meta, dd_add_meta_array, exception_type); - } - } } zend_array *span_links = ddtrace_property_array(&span->property_links); diff --git a/ext/span.c b/ext/span.c index 37db2e2325..c717d2a78d 100644 --- a/ext/span.c +++ b/ext/span.c @@ -167,7 +167,7 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { GC_DEL_FLAGS(&stack->std, IS_OBJ_DESTRUCTOR_CALLED); ddtrace_root_span_data *rsd = DDTRACE_G(active_stack)->root_span; - bool child_of_inferred_span = rsd != NULL && rsd->type == DDTRACE_INFERRED_SPAN && rsd->child_root == NULL; + bool child_of_inferred_span = rsd != NULL && rsd->type == DDTRACE_INFERRED_SPAN && rsd->inferred_root == NULL; bool root_span = DDTRACE_G(active_stack)->root_span == NULL; ddtrace_span_data *span = ddtrace_init_span(type, (root_span || child_of_inferred_span) ? ddtrace_ce_root_span_data : ddtrace_ce_span_data); @@ -208,9 +208,8 @@ ddtrace_span_data *ddtrace_open_span(enum ddtrace_span_dataype type) { ddtrace_set_root_span_properties(root); } else if (child_of_inferred_span) { - span->is_child_of_inferred_span = true; ddtrace_root_span_data *root = ROOTSPANDATA(&span->std); - DDTRACE_G(active_stack)->root_span->child_root = root; + DDTRACE_G(active_stack)->root_span->inferred_root = root; root->trace_id = DDTRACE_G(active_stack)->root_span->trace_id; root->parent_id = DDTRACE_G(active_stack)->root_span->span.span_id; diff --git a/ext/span.h b/ext/span.h index 2136829c7b..8545faa025 100644 --- a/ext/span.h +++ b/ext/span.h @@ -87,7 +87,6 @@ struct ddtrace_span_data { bool notify_user_req_end; struct ddtrace_span_data *next; struct ddtrace_root_span_data *root; - bool is_child_of_inferred_span; union { ddtrace_span_properties; @@ -109,7 +108,7 @@ struct ddtrace_root_span_data { ddtrace_rule_result sampling_rule; bool explicit_sampling_priority; enum ddtrace_trace_limited trace_is_limited; - struct ddtrace_root_span_data *child_root; // Only used when inferring proxy services (type: DDTRACE_INFERRED_SPAN) + struct ddtrace_root_span_data *inferred_root; // Only used when inferring proxy services (type: DDTRACE_INFERRED_SPAN) union { ddtrace_span_data; @@ -256,7 +255,9 @@ static inline bool ddtrace_span_is_dropped(ddtrace_span_data *span) { static inline bool ddtrace_span_is_entrypoint_root(ddtrace_span_data *span) { // The parent stack of a true top-level stack does never have a parent stack itself - return span->std.ce == ddtrace_ce_root_span_data && (!span->stack->parent_stack || !span->stack->parent_stack->parent_stack) && !span->is_child_of_inferred_span; + return span->std.ce == ddtrace_ce_root_span_data + && (!span->stack->parent_stack || !span->stack->parent_stack->parent_stack) + && (!span->root || !span->root->inferred_root || &span->root->inferred_root->span != span); } #endif // DD_SPAN_H From 2e54a22cd006deef17d9f81b2882349dfff3f98b Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 27 Feb 2025 14:09:39 +0100 Subject: [PATCH 45/46] cr: early-return & memory leak --- ext/inferred_proxy_headers.c | 5 +++++ ext/span.c | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/inferred_proxy_headers.c b/ext/inferred_proxy_headers.c index 1152609998..8f917de401 100644 --- a/ext/inferred_proxy_headers.c +++ b/ext/inferred_proxy_headers.c @@ -28,6 +28,11 @@ ddtrace_inferred_proxy_result ddtrace_read_inferred_proxy_headers(ddtrace_read_h read_header((zai_str)ZAI_STRL("X_DD_PROXY"), "x-dd-proxy", &result.system, data); read_header((zai_str)ZAI_STRL("X_DD_PROXY_REQUEST_TIME_MS"), "x-dd-proxy-request-time-ms", &result.start_time_ms, data); + + if (!result.system || !result.start_time_ms) { + return result; + } + read_header((zai_str)ZAI_STRL("X_DD_PROXY_PATH"), "x-dd-proxy-path", &result.path, data); read_header((zai_str)ZAI_STRL("X_DD_PROXY_HTTPMETHOD"), "x-dd-proxy-httpmethod", &result.http_method, data); read_header((zai_str)ZAI_STRL("X_DD_PROXY_DOMAIN_NAME"), "x-dd-proxy-domain-name", &result.domain, data); diff --git a/ext/span.c b/ext/span.c index c717d2a78d..7f64a75967 100644 --- a/ext/span.c +++ b/ext/span.c @@ -824,14 +824,22 @@ zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id) { return str; } +void free_inferred_proxy_result(ddtrace_inferred_proxy_result *result) { + zend_string_release(result->system); + zend_string_release(result->start_time_ms); + if (result->http_method) zend_string_release(result->http_method); + if (result->path) zend_string_release(result->path); + if (result->domain) zend_string_release(result->domain); + if (result->stage) zend_string_release(result->stage); +} + ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { ddtrace_read_header *read_header = headers ? ddtrace_read_array_header : ddtrace_read_zai_header; ddtrace_inferred_proxy_result result = ddtrace_read_inferred_proxy_headers(read_header, headers); if (!result.system || !result.start_time_ms) { - if (result.system) zend_string_release(result.system); - if (result.start_time_ms) zend_string_release(result.start_time_ms); + free_inferred_proxy_result(&result); return NULL; } @@ -852,7 +860,7 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { ZVAL_STR(&span->property_resource, strpprintf(0, "%s %s", ZSTR_VAL(result.http_method), ZSTR_VAL(result.path))); } - span->start = (zend_long)zend_strtod(ZSTR_VAL(result.start_time_ms), NULL) * 1000000; + span->start = ZEND_ATOL(ZSTR_VAL(result.start_time_ms)) * 1000000; span->duration_start = zend_hrtime() - (ddtrace_nanoseconds_realtime() - span->start); zval zv; @@ -882,12 +890,7 @@ ddtrace_root_span_data *ddtrace_open_inferred_span(zend_array *headers) { add_assoc_long(&span->property_meta, "_dd.inferred_span", 1); add_assoc_string(&span->property_meta, "component", proxy_info->component); - zend_string_release(result.system); - zend_string_release(result.start_time_ms); - if (result.path) zend_string_release(result.path); - if (result.http_method) zend_string_release(result.http_method); - if (result.domain) zend_string_release(result.domain); - if (result.stage) zend_string_release(result.stage); + free_inferred_proxy_result(&result); return ROOTSPANDATA(&span->std); } From c0f1c2835d84f3611d02bfe2cf5c1afc970b4e02 Mon Sep 17 00:00:00 2001 From: Alexandre Choura Date: Thu, 27 Feb 2025 14:29:26 +0100 Subject: [PATCH 46/46] cr: Set free_inferred_proxy_result to static --- ext/span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/span.c b/ext/span.c index 7f64a75967..1e657def23 100644 --- a/ext/span.c +++ b/ext/span.c @@ -824,7 +824,7 @@ zend_string *ddtrace_trace_id_as_hex_string(ddtrace_trace_id id) { return str; } -void free_inferred_proxy_result(ddtrace_inferred_proxy_result *result) { +static void free_inferred_proxy_result(ddtrace_inferred_proxy_result *result) { zend_string_release(result->system); zend_string_release(result->start_time_ms); if (result->http_method) zend_string_release(result->http_method);