Skip to content
Snippets Groups Projects
Commit 898fb4ce authored by Sean McGivern's avatar Sean McGivern :red_circle:
Browse files

Merge branch...

Merge branch 'mwaw/mirror_redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly_to_snowplow' into 'master'

Migrate incident_management service ping metrics to Snowplow events

See merge request !105223



Merged-by: default avatarSean McGivern <sean@gitlab.com>
Approved-by: default avatarNiko Belokolodov <nbelokolodov@gitlab.com>
Approved-by: default avatarSean McGivern <sean@gitlab.com>
Reviewed-by: Mikołaj Wawrzyniak's avatarMikołaj Wawrzyniak <mwawrzyniak@gitlab.com>
Reviewed-by: default avatarNiko Belokolodov <nbelokolodov@gitlab.com>
Co-authored-by: Mikołaj Wawrzyniak's avatarMikolaj Wawrzyniak <mwawrzyniak@gitlab.com>
parents 46f062c7 1458caeb
No related branches found
No related tags found
1 merge request!105223Migrate incident_management service ping metrics to Snowplow events
Pipeline #721047384 passed with warnings
Pipeline: GitLab

#721052756

    Pipeline: GitLab

    #721052740

      Showing
      with 310 additions and 26 deletions
      ......@@ -20,7 +20,7 @@ def resolve(args)
      alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
      result = set_assignees(alert, args[:assignee_usernames], args[:operation_mode])
      track_usage_event(:incident_management_alert_assigned, current_user.id)
      track_alert_events('incident_management_alert_assigned', alert)
      prepare_response(result)
      end
      ......
      ......@@ -11,7 +11,7 @@ def resolve(args)
      alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
      result = ::AlertManagement::Alerts::Todo::CreateService.new(alert, current_user).execute
      track_usage_event(:incident_management_alert_todo, current_user.id)
      track_alert_events('incident_management_alert_todo', alert)
      prepare_response(result)
      end
      ......
      ......@@ -39,6 +39,24 @@ def find_object(project_path:, **args)
      ::AlertManagement::AlertsFinder.new(current_user, project, args).execute.first
      end
      def track_alert_events(event, alert)
      project = alert.project
      namespace = project.namespace
      track_usage_event(event, current_user.id)
      return unless Feature.enabled?(:route_hll_to_snowplow_phase2, namespace)
      Gitlab::Tracking.event(
      self.class.to_s,
      event,
      project: project,
      namespace: namespace,
      user: current_user,
      label: 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly',
      context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event).to_context]
      )
      end
      end
      end
      end
      ......@@ -9,7 +9,7 @@ def resolve(args)
      alert = authorized_find!(project_path: args[:project_path], iid: args[:iid])
      result = create_alert_issue(alert, current_user)
      track_usage_event(:incident_management_incident_created, current_user.id)
      track_alert_events('incident_management_incident_created', alert)
      track_usage_event(:incident_management_alert_create_incident, current_user.id)
      prepare_response(alert, result)
      ......
      ......@@ -13,7 +13,7 @@ def resolve(project_path:, iid:, status:)
      alert = authorized_find!(project_path: project_path, iid: iid)
      result = update_status(alert, status)
      track_usage_event(:incident_management_alert_status_changed, current_user.id)
      track_alert_events('incident_management_alert_status_changed', alert)
      prepare_response(result)
      end
      ......
      ......@@ -7,7 +7,23 @@ module UsageData
      def track_incident_action(current_user, target, action)
      return unless target.incident?
      track_usage_event(:"incident_management_#{action}", current_user.id)
      event = "incident_management_#{action}"
      track_usage_event(event, current_user.id)
      namespace = target.try(:namespace)
      project = target.try(:project)
      return unless Feature.enabled?(:route_hll_to_snowplow_phase2, target.try(:namespace))
      Gitlab::Tracking.event(
      self.class.to_s,
      event,
      project: project,
      namespace: namespace,
      user: current_user,
      label: 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly',
      context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event).to_context]
      )
      end
      end
      end
      ......@@ -24,6 +24,23 @@ def error_no_permissions
      def error_in_save(timeline_event)
      error(timeline_event.errors.full_messages.to_sentence)
      end
      def track_timeline_event(event, project)
      namespace = project.namespace
      track_usage_event(event, user.id)
      return unless Feature.enabled?(:route_hll_to_snowplow_phase2, namespace)
      Gitlab::Tracking.event(
      self.class.to_s,
      event,
      project: project,
      namespace: namespace,
      user: user,
      label: 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly',
      context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event).to_context]
      )
      end
      end
      end
      end
      ......@@ -106,7 +106,7 @@ def execute
      create_timeline_event_tag_links(timeline_event, params[:timeline_event_tag_names])
      track_usage_event(:incident_management_timeline_event_created, user.id)
      track_timeline_event("incident_management_timeline_event_created", project)
      success(timeline_event)
      else
      ......
      ......@@ -18,7 +18,7 @@ def execute
      if timeline_event.destroy
      add_system_note(incident, user)
      track_usage_event(:incident_management_timeline_event_deleted, user.id)
      track_timeline_event('incident_management_timeline_event_deleted', project)
      success(timeline_event)
      else
      error_in_save(timeline_event)
      ......
      ......@@ -43,7 +43,7 @@ def execute
      if timeline_event_saved
      add_system_note(timeline_event)
      track_usage_event(:incident_management_timeline_event_edited, user.id)
      track_timeline_event('incident_management_timeline_event_edited', timeline_event.project)
      success(timeline_event)
      else
      error_in_save(timeline_event)
      ......
      ......@@ -146,7 +146,7 @@ def handle_confidential_change(issue)
      # don't enqueue immediately to prevent todos removal in case of a mistake
      TodosDestroyer::ConfidentialIssueWorker.perform_in(Todo::WAIT_FOR_DELETE, issue.id) if issue.confidential?
      create_confidentiality_note(issue)
      track_usage_event(:incident_management_incident_change_confidential, current_user.id)
      track_incident_action(current_user, issue, :incident_change_confidential)
      end
      end
      ......
      ......@@ -166,8 +166,9 @@ def new_award_emoji(awardable, current_user)
      # When user marks a target as todo
      def mark_todo(target, current_user)
      attributes = attributes_for_todo(target.project, target, current_user, Todo::MARKED)
      create_todos(current_user, attributes)
      project = target.project
      attributes = attributes_for_todo(project, target, current_user, Todo::MARKED)
      create_todos(current_user, attributes, project&.namespace, project)
      end
      def todo_exist?(issuable, current_user)
      ......@@ -214,8 +215,9 @@ def restore_todo(todo, current_user)
      end
      def create_request_review_todo(target, author, reviewers)
      attributes = attributes_for_todo(target.project, target, author, Todo::REVIEW_REQUESTED)
      create_todos(reviewers, attributes)
      project = target.project
      attributes = attributes_for_todo(project, target, author, Todo::REVIEW_REQUESTED)
      create_todos(reviewers, attributes, project.namespace, project)
      end
      def create_member_access_request(member)
      ......@@ -225,12 +227,20 @@ def create_member_access_request(member)
      approvers = source.access_request_approvers_to_be_notified.map(&:user)
      return true if approvers.empty?
      create_todos(approvers, attributes)
      if source.instance_of? Project
      project = source
      namespace = project.namespace
      else
      project = nil
      namespace = source
      end
      create_todos(approvers, attributes, namespace, project)
      end
      private
      def create_todos(users, attributes)
      def create_todos(users, attributes, namespace, project)
      users = Array(users)
      return if users.empty?
      ......@@ -256,7 +266,7 @@ def create_todos(users, attributes)
      todos = users.map do |user|
      issue_type = attributes.delete(:issue_type)
      track_todo_creation(user, issue_type)
      track_todo_creation(user, issue_type, namespace, project)
      Todo.create(attributes.merge(user_id: user.id))
      end
      ......@@ -296,9 +306,10 @@ def handle_note(note, author, skip_users = [])
      def create_assignment_todo(target, author, old_assignees = [])
      if target.assignees.any?
      project = target.project
      assignees = target.assignees - old_assignees
      attributes = attributes_for_todo(target.project, target, author, Todo::ASSIGNED)
      create_todos(assignees, attributes)
      attributes = attributes_for_todo(project, target, author, Todo::ASSIGNED)
      create_todos(assignees, attributes, project.namespace, project)
      end
      end
      ......@@ -313,22 +324,24 @@ def create_mention_todos(parent, target, author, note = nil, skip_users = [])
      # Create Todos for directly addressed users
      directly_addressed_users = filter_directly_addressed_users(parent, note || target, author, skip_users)
      attributes = attributes_for_todo(parent, target, author, Todo::DIRECTLY_ADDRESSED, note)
      create_todos(directly_addressed_users, attributes)
      create_todos(directly_addressed_users, attributes, parent&.namespace, parent)
      # Create Todos for mentioned users
      mentioned_users = filter_mentioned_users(parent, note || target, author, skip_users + directly_addressed_users)
      attributes = attributes_for_todo(parent, target, author, Todo::MENTIONED, note)
      create_todos(mentioned_users, attributes)
      create_todos(mentioned_users, attributes, parent&.namespace, parent)
      end
      def create_build_failed_todo(merge_request, todo_author)
      attributes = attributes_for_todo(merge_request.project, merge_request, todo_author, Todo::BUILD_FAILED)
      create_todos(todo_author, attributes)
      project = merge_request.project
      attributes = attributes_for_todo(project, merge_request, todo_author, Todo::BUILD_FAILED)
      create_todos(todo_author, attributes, project.namespace, project)
      end
      def create_unmergeable_todo(merge_request, todo_author)
      attributes = attributes_for_todo(merge_request.project, merge_request, todo_author, Todo::UNMERGEABLE)
      create_todos(todo_author, attributes)
      project = merge_request.project
      attributes = attributes_for_todo(project, merge_request, todo_author, Todo::UNMERGEABLE)
      create_todos(todo_author, attributes, project.namespace, project)
      end
      def attributes_for_target(target)
      ......@@ -392,10 +405,23 @@ def pending_todos(users, criteria = {})
      PendingTodosFinder.new(users, criteria).execute
      end
      def track_todo_creation(user, issue_type)
      def track_todo_creation(user, issue_type, namespace, project)
      return unless issue_type == 'incident'
      track_usage_event(:incident_management_incident_todo, user.id)
      event = "incident_management_incident_todo"
      track_usage_event(event, user.id)
      return unless Feature.enabled?(:route_hll_to_snowplow_phase2, namespace)
      Gitlab::Tracking.event(
      self.class.to_s,
      event,
      project: project,
      namespace: namespace,
      user: user,
      label: 'redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly',
      context: [Gitlab::Tracking::ServicePingContext.new(data_source: :redis_hll, event: event).to_context]
      )
      end
      def attributes_for_access_request_todos(source, author, action, note = nil)
      ......
      ---
      description: Mirrored Service Ping Redis metric. Count of unique users that published incidents per month
      category: StatusPage::PublishService
      action: incident_management_incident_published
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: monitor
      product_category:
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ee
      tiers:
      - premium
      - ultimate
      ---
      description: Migrated Service Ping metric. Count of unique users adding alerts to the TODO list
      category: Mutations::AlertManagement::Alerts::Todo::Create
      action: incident_management_alert_todo
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: monitor
      product_category:
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223/diffs
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      description: Count of unique users assigning an alert per week. Migrated form Service Ping metric
      category: Mutations::AlertManagement::Alerts::SetAssignees
      action: incident_management_alert_assigned
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: monitor
      product_category:
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      description: Migrated from Service Ping metric. Count of unique users creating incidents
      category: Mutations::AlertManagement::CreateAlertIssue
      action: incident_management_incident_created
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: monitor
      product_category:
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      description: Count of unique users changing alert's status. Migrated from Service Ping metric
      category: Mutations::AlertManagement::UpdateAlertStatus
      action: incident_management_alert_status_changed
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: monitor
      product_category:
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      description: Count of unique users created timeline events
      category: IncidentManagement::TimelineEvents::CreateService
      action: incident_management_timeline_event_created
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      product_section: ops
      product_stage: monitor
      product_group: respond
      product_category: incident_management
      value_type: number
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      category: IncidentManagement::TimelineEvents::DestroyService
      action: incident_management_timeline_event_deleted
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      description: "Event migrates from Service Ping metric. Count of unique users deleted timeline events"
      product_section: ops
      product_stage: monitor
      product_group: respond
      product_category: incident_management
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      ---
      category: IncidentManagement::TimelineEvents::UpdateService
      action: incident_management_timeline_event_edited
      label_description: "Mirrored Service Ping total metric key_path: redis_hll_counters.incident_management.incident_management_total_unique_counts_monthly"
      property_description:
      value_description:
      extra_properties:
      identifiers:
      - project
      - user
      - namespace
      description: "Event migrated form Service Ping metric. Count of unique users edited timeline events"
      product_section: ops
      product_stage: monitor
      product_group: respond
      product_category: incident_management
      milestone: "15.7"
      introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/105223
      distributions:
      - ce
      - ee
      tiers:
      - free
      - premium
      - ultimate
      0% Loading or .
      You are about to add 0 people to the discussion. Proceed with caution.
      Finish editing this message first!
      Please register or to comment