From e2e6abdd939342e40d77b8f82c0e34587cc32c26 Mon Sep 17 00:00:00 2001 From: Munir Abdinur Date: Wed, 20 Nov 2024 16:08:50 -0500 Subject: [PATCH] [php] parametric: update dd and otel flush endpoints (#3514) Co-authored-by: Bob Weinand --- manifests/php.yml | 1 - utils/build/docker/php/parametric/server.php | 17 ++++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifests/php.yml b/manifests/php.yml index 7e3b9670c3..0a47e38cff 100644 --- a/manifests/php.yml +++ b/manifests/php.yml @@ -332,7 +332,6 @@ tests/: Test_Parametric_DDSpan_Start: bug (APMAPI-778) # Does not support creating a child span from a finished span Test_Parametric_DDTrace_Baggage: missing_feature (baggage is not supported) Test_Parametric_DDTrace_Current_Span: bug (APMAPI-778) # current span endpoint should return span and trace id of zero if no span is "active" - Test_Parametric_DDTrace_Flush: missing_feature (flush endpoint is not implemented, the lack of this feature introduce flakiness in all tests) Test_Parametric_Otel_Baggage: missing_feature (otel baggage is not supported) Test_Parametric_Otel_Current_Span: bug (APMAPI-778) # otel current span endpoint should return a span and trace id of zero if no span is "active" test_partial_flushing.py: diff --git a/utils/build/docker/php/parametric/server.php b/utils/build/docker/php/parametric/server.php index 068f184f4c..bf78e46e78 100644 --- a/utils/build/docker/php/parametric/server.php +++ b/utils/build/docker/php/parametric/server.php @@ -239,8 +239,11 @@ function remappedSpanKind($spanKind) { return jsonResponse([]); })); $router->addRoute('POST', '/trace/span/flush', new ClosureRequestHandler(function () use (&$spans) { - \DDTrace\flush(); - dd_trace_internal_fn("synchronous_flush"); + dd_trace_synchronous_flush(1000); # flush spans with a timeout of 1s + return jsonResponse([]); +})); +$router->addRoute('POST', '/trace/stats/flush', new ClosureRequestHandler(function () use (&$spans) { + # NOP: php doesn't expose an API to flush trace stats return jsonResponse([]); })); $router->addRoute('GET', '/trace/span/current', new ClosureRequestHandler(function () use (&$spans, &$activeSpan) { @@ -398,11 +401,11 @@ function remappedSpanKind($spanKind) { return jsonResponse([]); })); $router->addRoute('POST', '/trace/otel/flush', new ClosureRequestHandler(function (Request $req) { - \DDTrace\flush(); - dd_trace_internal_fn("synchronous_flush"); - return jsonResponse([ - 'success' => true - ]); + $timeout = (arg($req, 'seconds') ?: 0.1) * 1000; # convert timeout to ms + dd_trace_synchronous_flush($timeout); + return jsonResponse([ + 'success' => true + ]); })); $router->addRoute('POST', '/trace/otel/is_recording', new ClosureRequestHandler(function (Request $req) use (&$otelSpans) { $spanId = arg($req, 'span_id');