Add support for project traces via GraphQL
What does this MR do and why?
- Adds a new
observabilityTracesLinks
GraphQL edge toProjectType
. - Adds required types and resolver to implement it.
- Adds specs, including changes to other files as well as request specs for the new GraphQL interface.
Database queries
All records for a project
(These are from locally generated data since the table is brand new)
This query reads from an index condition as expected.
SELECT "observability_traces_issues_connections".* FROM "observability_traces_issues_connections" WHERE "observability_traces_issues_connections"."project_id" = 15;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------------------------------
Seq Scan on observability_traces_issues_connections (cost=0.00..129.50 rows=5000 width=77)
Filter: (project_id = 15)
(2 rows)
### Selecting an individual record for a project
Query uses same index condition as above, and then filters on specific criteria. This will likely never return more than 1 or 2 records.
```sql
SELECT "observability_traces_issues_connections".* FROM "observability_traces_issues_connections" WHERE "observability_traces_issues_connections"."project_id" = 15 AND "observability_traces_issues_connections"."trace_identifier" = '46c0d0dc-b3af-4a3b-be80-b15ae022bfcc' LIMIT 1
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.28..93.80 rows=1 width=77)
-> Index Scan using idx_o11y_trace_issue_conn_on_issue_id_trace_identifier on observability_traces_issues_connections (cost=0.28..93.80 rows=1 width=77)
Index Cond: (trace_identifier = '46c0d0dc-b3af-4a3b-be80-b15ae022bfcc'::text)
Filter: (project_id = 15)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
-
Ensure you're using an Ultimate namespace.
-
Enable the
:observability_features
feature flag. -
Create a new project, within an Ultimate group.
-
Create a new issue, and note its ID.
-
On a
rails console
, create a linked log for that project.issue_id = {{ID}} a = a = Observability::TracesIssuesConnection.create(issue: Project.find(issue_id).issues.last, trace_identifier: 'xxxxxx') a.save! # Raise an exception if something went wrong.
-
For the created log, we can query a list of links - note the format of the timestamp should be iso8601.
query { project(fullPath: "Flightjs/Flight") { id observabilityTracesLinks { nodes { traceIdentifier issue { title webUrl } } } } }
-
If successful, it should return a list of
observabiltyLogsLinks
, each representing the link between an observabililtyLog and its issue (if queried, as above){ "data": { "project": { "id": "gid://gitlab/Project/7", "observabilityTracesLinks": { "nodes": [ { "traceIdentifier": "23489affd", "issue": { "title": "fdfsdfsdfsdfsdfs", "webUrl": "http://127.0.0.1:3000/flightjs/Flight/-/issues/40" } } ] } } } }
Related to gitlab-org/opstrace/opstrace#2904 (closed)