diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php index 332ae454095..63a3a07cd73 100644 --- a/core/tests/Drupal/Tests/PerformanceTestTrait.php +++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php @@ -339,6 +339,20 @@ trait PerformanceTestTrait { ->setAttribute('http.url', $url) ->startSpan(); $first_byte_span->end($response_wall_time); + + $collection = \Drupal::keyValue('performance_test'); + $performance_test_data = $collection->get('performance_test_data'); + $query_events = $performance_test_data['database_events'] ?? []; + foreach ($query_events as $key => $event) { + // Use the first part of the database query for the span name. + $query_span = $tracer->spanBuilder(substr($event->queryString, 0, 64)) + ->setStartTimestamp((int) ($event->startTime * $nanoseconds_per_second)) + ->setAttribute('query.string', $event->queryString) + ->setAttribute('query.args', var_export($event->args, TRUE)) + ->setAttribute('query.caller', var_export($event->caller, TRUE)) + ->startSpan(); + $query_span->end((int) ($event->time * $nanoseconds_per_second)); + } $lcp_timestamp = NULL; $fcp_timestamp = NULL; $lcp_size = 0;