Add metric count messages sent in react inbox

closes VICE-2884
flag=none

Test Plan:
 - metric gathering will be verifeid post merge
 - tests pass and make sense

Change-Id: Idc6b510a24b8de807be0dc35c63aa72e9e749950
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/301132
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Caleb Guanzon <cguanzon@instructure.com>
Product-Review: Caleb Guanzon <cguanzon@instructure.com>
QA-Review: Omar Soto-Fortuño <omar.soto@instructure.com>
This commit is contained in:
Drake Harper 2022-09-15 11:20:07 -06:00
parent ddaa87e79a
commit 0ef8f787f2
4 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,7 @@ class Mutations::AddConversationMessage < Mutations::BaseMutation
user_note: input[:user_note]
)
InstStatsd::Statsd.increment("inbox.message.sent.isReply.react")
InstStatsd::Statsd.increment("inbox.message.sent.react")
InstStatsd::Statsd.count("inbox.message.sent.recipients.react", message[:recipients_count])
if input[:media_comment_id] || ConversationMessage.where(id: message[:message]&.id).first&.has_media_objects
InstStatsd::Statsd.increment("inbox.message.sent.media.react")

View File

@ -108,6 +108,7 @@ class Mutations::CreateConversation < Mutations::BaseMutation
.order("visible_last_authored_at DESC, last_message_at DESC, id DESC")
Conversation.preload_participants(conversations.map(&:conversation))
ConversationParticipant.preload_latest_messages(conversations, @current_user)
InstStatsd::Statsd.increment("inbox.message.sent.react")
InstStatsd::Statsd.count("inbox.conversation.created.react", conversations.count)
InstStatsd::Statsd.increment("inbox.conversation.sent.react")
InstStatsd::Statsd.count("inbox.message.sent.recipients.react", recipients.count)
@ -142,6 +143,7 @@ class Mutations::CreateConversation < Mutations::BaseMutation
cc_author: true
)
InstStatsd::Statsd.increment("inbox.conversation.created.react")
InstStatsd::Statsd.increment("inbox.message.sent.react")
InstStatsd::Statsd.increment("inbox.conversation.sent.react")
InstStatsd::Statsd.count("inbox.message.sent.recipients.react", recipients.count)
if message.has_media_objects || input[:media_comment_id]

View File

@ -116,6 +116,7 @@ RSpec.describe Mutations::AddConversationMessage do
)
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.isReply.react")
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.react")
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.message.sent.recipients.react", 1)
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.media.react")
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.attachment.react")

View File

@ -137,6 +137,7 @@ RSpec.describe Mutations::CreateConversation do
@student.media_objects.where(media_id: "m-whatever", media_type: "video/mp4").first_or_create!
result = run_mutation(recipients: [new_user.id.to_s], body: "yo", context_code: @course.asset_string, media_comment_id: "m-whatever", media_comment_type: "video")
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.conversation.created.react")
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.react")
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.conversation.sent.react")
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.message.sent.recipients.react", 1)
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.media.react")
@ -327,6 +328,7 @@ RSpec.describe Mutations::CreateConversation do
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.message.sent.media.react", 2)
run_mutation(recipients: [@new_user1.id.to_s, @new_user2.id.to_s], subject: "yo 2", group_conversation: true, bulk_message: true, context_code: @course.asset_string, media_comment_id: "m-whatever", media_comment_type: "video")
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.conversation.created.react", 2).at_least(:twice)
expect(InstStatsd::Statsd).to have_received(:increment).with("inbox.message.sent.react").at_least(:twice)
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.message.sent.recipients.react", 2).at_least(:twice)
expect(InstStatsd::Statsd).to have_received(:count).with("inbox.message.sent.media.react", 2).at_least(:twice)
expect(Conversation.count).to eql(@old_count + 4)