Skip to content

Commit

Permalink
Gather metrics about comment creation on request action diffs
Browse files Browse the repository at this point in the history
Instrumenting the feature introduced in #13912
  • Loading branch information
krauselukas authored and danidoni committed Mar 13, 2023
1 parent 597f03f commit 5f0889a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_event
when 'BsRequest'
Event::CommentForRequest.create(event_parameters)
when 'BsRequestAction'
Event::CommentForRequest.create(event_parameters.merge({ id: commentable.bs_request.id }))
Event::CommentForRequest.create(event_parameters.merge({ id: commentable.bs_request.id, diff_ref: diff_ref }))
end
end

Expand Down
14 changes: 13 additions & 1 deletion src/api/app/models/event/comment_for_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CommentForRequest < Request
include CommentEvent
self.message_bus_routing_key = 'request.comment'
self.description = 'New comment for request created'
payload_keys :request_number
payload_keys :request_number, :diff_ref
receiver_roles :source_maintainer, :target_maintainer, :creator, :reviewer, :source_watcher, :target_watcher,
:source_package_watcher, :target_package_watcher, :request_watcher

Expand All @@ -17,6 +17,18 @@ def set_payload(attribs, keys)
attribs['files'] = attribs['files'][0..800] if attribs['files'].present?
super(attribs, keys)
end

def metric_measurement
'comment'
end

def metric_tags
{ diff_ref: payload['diff_ref'].present? }
end

def metric_fields
{ value: 1 }
end
end
end

Expand Down

0 comments on commit 5f0889a

Please sign in to comment.