Skip to content

Add support for project traces via GraphQL

Max Woolf requested to merge 2904-opstrace/graphql-trace-issues-links into master

What does this MR do and why?

  • Adds a new observabilityTracesLinks GraphQL edge to ProjectType.
  • 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

  1. Ensure you're using an Ultimate namespace.

  2. Enable the :observability_features feature flag.

  3. Create a new project, within an Ultimate group.

  4. Create a new issue, and note its ID.

  5. 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.
  6. 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
            }
          }
        }
      }
    }
  7. 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)

Edited by Max Woolf

Merge request reports