Add database query spans to otel traces

Created on 28 July 2023, over 1 year ago
Updated 3 January 2024, 12 months ago

Problem/Motivation

Depends on 📌 Allow assertions on the number of database queries run during tests RTBC which adds assertions for database queries (and cache operations) to PerformanceTestTrait.

This issue adds open telemetry spans for the database queries too - this means you can go to the Grafana dashboard, click on a trace, and see every query that was recorded for the request.

Because we cumulatively record database queries, if there is a redirect, AJAX requests, asset or image style route requests while recording, it will include those database queries too, so you get a complete view of what was executed as a result of the thing you were testing.

A potential follow-up would be to add EXPLAIN output for each of the queries too, but we might want to do that after fully separating out cache and other database queries, since there's no point EXPLAIN-ing dozens of identical cache gets 📌 Separate cache operations from database queries in OpenTelemetry and assertions Fixed .

Steps to reproduce

If you want to manually test this, and have an existing core install based on ddev that can run functional javascript tests, you can do the following:

$ ddev add tag1consulting/gander
$ ddev restart

Then run any test from the Umami OpenTelemetry tests, e.g.:

../vendor/bin/phpunit profiles/demo_umami/tests/src/FunctionalJavascript/OpenTelemetryNodePagePerformanceTest.php --filter=warm

You can then go to http://localhost:3000/d/teMVIdjVz/umami?orgId=1&refresh=30s and browse through the traces.

https://github.com/tag1consulting/ddev-gander

Once it's merged, the same thing will be available via core branch runs on http://grafana.tag1demo.tag1.io/d/teMVIdjVz/umami?orgId=1&refresh=30s

Proposed resolution

The database API has query start/end events, we can use those verbatim to create open telemetry spans within PerformanceTestTrait.

It will then be possible to go to to the grafana dashboard, click on a trace, and see all the queries executed, the query string, the caller etc.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.2

Component
PHPUnit 

Last updated about 17 hours ago

Created by

🇬🇧United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024