Design comment removal metric
What does this MR do and why?
Here you can find the snowplow event and redis counters which are getting issued/updated when a design comment is deleted (using the destroyNote
GraphQL mutation).
Instrumentation here follows the same structure as existing issue_design_*
events which were migrated in !95325 (merged).
New redis counters:
redis_hll_counters.issues_edit.g_project_management_issue_design_comments_removed_weekly
redis_hll_counters.issues_edit.g_project_management_issue_design_comments_removed_monthly
New event: g_project_management_issue_design_comments_removed
Screenshots or screen recordings
Usage data on version.gitlab.com side
pry(main)> ::UsageData.last.redis_hll_counters.dig('issues_edit', 'g_project_management_issue_design_comments_removed_monthly')
UsageData Load (11.5ms) SELECT "usage_data".* FROM "usage_data" ORDER BY "usage_data"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> 1
pry(main)> ::UsageData.last.redis_hll_counters.dig('issues_edit', 'g_project_management_issue_design_comments_removed_weekly')
UsageData Load (5.7ms) SELECT "usage_data".* FROM "usage_data" ORDER BY "usage_data"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> 1
Snowplow event
[
{
"rawEvent": {
"api": {
"vendor": "com.snowplowanalytics.snowplow",
"version": "tp1"
},
"parameters": {
"se_pr": "g_project_management_issue_design_comments_removed",
"se_ac": "perform_issue_action",
"se_la": "redis_hll_counters.issues_edit.issues_edit_total_unique_counts_monthly",
"se_ca": "issues_edit",
# ...
},
"contentType": null,
"source": {
# ...
},
"context": {
# ...
}
},
"eventType": "struct",
"schema": "iglu:com.google.analytics/event/jsonschema/1-0-0",
"contexts": [
"iglu:com.gitlab/gitlab_standard/jsonschema/1-0-8",
"iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0"
],
"event": {
# ...
"contexts": {
"schema": "iglu:com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-0",
"data": [
{
"schema": "iglu:com.gitlab/gitlab_standard/jsonschema/1-0-8",
"data": {
"environment": "development",
"source": "gitlab-rails",
"plan": "default",
"extra": {
},
"user_id": 1,
"namespace_id": 75,
"project_id": 20,
"context_generated_at": "2023-01-16 20:40:09 UTC"
}
},
{
"schema": "iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0",
"data": {
"data_source": "redis_hll",
"event_name": "g_project_management_issue_design_comments_removed"
}
}
]
},
"se_category": "issues_edit",
"se_action": "perform_issue_action",
"se_label": "redis_hll_counters.issues_edit.issues_edit_total_unique_counts_monthly",
"se_property": "g_project_management_issue_design_comments_removed",
# ...
}
}
]
How to set up and validate locally
Emit event
- Pick an issue (Example: Local gdk.test Wget2#1)
- Add a design and start a discussion on it
- Remove the last design discussion by running the following
👇 GraphQL mutation
Mutation:
mutation destroyNote($input: DestroyNoteInput!) {
destroyNote(input: $input) {
errors
}
}
Query variables:
{
"input": {
"id": "gid://gitlab/DiffNote/1"
}
}
Please, use output of bin/rails r 'puts "gid://gitlab/DiffNote/#{DiffNote.last.id}"'
as input
.id
value.
Check service ping
First thing is to check that the new metric definitions appear on usage data API response curl http://gdk.test:3000/api/v4/usage_data/metric_definitions | grep -C 5 'g_project_management_issue_design_comments_removed_'
(and will be picked by version.gitlab.com).
The second thing is the counter value, to check it run the following lines on rails console
usage = GitlabServicePingWorker.new.usage_data
puts "removed_monthly: #{usage.dig('redis_hll_counters', 'issues_edit', 'g_project_management_issue_design_comments_removed_monthly')}"
puts "removed_weekly: #{usage.dig('redis_hll_counters', 'issues_edit', 'g_project_management_issue_design_comments_removed_weekly')}"
Output should be
removed_monthly: 1
removed_weekly: 1
P.S To perfrom an E2E test please use the following guide or just reach out to me and I will help to configure local environment for it.
Check snowplow event
Prerequisites:
- Configure snowplow-micro locally
- Make sure it's running by resetting data using
curl http://localhost:9091/micro/reset
(PREVIOUS EVENTS WILL BE REMOVED)
Run in terminal
curl http://localhost:9091/micro/good
There should be an instance of "event_name": "g_project_management_issue_design_comments_removed"
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #297662 (closed)