Skip to content

Update usage ping to use Issue incident spec

Sean Arnold requested to merge 229548-adjust-telemetry-code-for-incidents into master

What does this MR do?

Updates the incident_issues query to use the new issue_type column on Incident.

All previous ~incident labelled issues were updated to use incident issue_type in !37668 (merged).

SQL queries and plans:

Before:
Gitlab::UsageData.count(::Issue.authored(::User.alert_bot), start: issue_minimum_id, finish: issue_maximum_id)
  User Load (2.7ms)  SELECT "users".* FROM "users" WHERE "users"."user_type" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["user_type", 2], ["LIMIT", 1]]
   (2.7ms)  SELECT COUNT("issues"."id") FROM "issues" WHERE "issues"."author_id" = $1 AND "issues"."id" BETWEEN $2 AND $3  [["author_id", 45], ["id", 1], ["id", 100000]]

(On database-lab, change the author_id to 278964 which is the alert bots ID).

Explains:

Database-lab plan:

Aggregate  (cost=3.59..3.60 rows=1 width=8) (actual time=11.326..11.326 rows=1 loops=1)
   Buffers: shared read=4
   I/O Timings: read=11.266
   ->  Index Only Scan using index_issues_on_author_id_and_id_and_created_at on public.issues  (cost=0.56..3.59 rows=1 width=4) (actual time=11.322..11.322 rows=0 loops=1)
         Index Cond: ((issues.author_id = 278964) AND (issues.id >= 1) AND (issues.id <= 100000))
         Heap Fetches: 0
         Buffers: shared read=4
         I/O Timings: read=11.266

Time: 11.671 ms
  - planning: 0.310 ms
  - execution: 11.361 ms
    - I/O read: 11.266 ms
    - I/O write: 0.000 ms

After:
Gitlab::UsageData.count(::Issue.incident, start: issue_minimum_id, finish: issue_maximum_id)
(3.1ms)  SELECT COUNT("issues"."id") FROM "issues" WHERE "issues"."issue_type" = $1 AND "issues"."id" BETWEEN $2 AND $3  [["issue_type", 1], ["id", 1], ["id", 100000]]

Explains:

Database-lab plan:

Aggregate  (cost=1208.48..1208.49 rows=1 width=8) (actual time=25.874..25.875 rows=1 loops=1)
   Buffers: shared hit=683
   ->  Bitmap Heap Scan on public.issues  (cost=1194.77..1208.46 rows=9 width=4) (actual time=25.869..25.869 rows=0 loops=1)
         Buffers: shared hit=683
         ->  BitmapAnd  (cost=1194.77..1194.77 rows=9 width=0) (actual time=25.849..25.849 rows=0 loops=1)
               Buffers: shared hit=683
               ->  Bitmap Index Scan using index_issues_on_incident_issue_type  (cost=0.00..87.13 rows=7769 width=0) (actual time=1.741..1.742 rows=8378 loops=1)
                     Buffers: shared hit=33
               ->  Bitmap Index Scan using issues_pkey  (cost=0.00..1107.39 rows=67932 width=0) (actual time=23.871..23.871 rows=78812 loops=1)
                     Index Cond: ((issues.id >= 1) AND (issues.id <= 100000))
                     Buffers: shared hit=650

Time: 27.018 ms
  - planning: 0.320 ms
  - execution: 26.698 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

#229548 (closed)

Edited by Sean Arnold

Merge request reports