record sent messages by type and account in stats
test plan - send message to user - a stat should generate with the account and type fixes KNO-387 flag: none Change-Id: I67106f915a4fad3cf5c2100c8b495d38d77ec56b Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/233045 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Ahmad Amireh <ahmad@instructure.com> QA-Review: Ahmad Amireh <ahmad@instructure.com> Product-Review: Ahmad Amireh <ahmad@instructure.com>
This commit is contained in:
parent
5767af8ef4
commit
653b9d0ffe
|
@ -615,6 +615,11 @@ class Message < ActiveRecord::Base
|
|||
short_stat: 'message.deliver',
|
||||
tags: {path_type: path_type, notification_name: notification_name})
|
||||
|
||||
global_account_id = Shard.global_id_for(root_account_id, self.shard)
|
||||
InstStatsd::Statsd.increment("message.deliver.#{path_type}.#{global_account_id}",
|
||||
short_stat: 'message.deliver_per_account',
|
||||
tags: {path_type: path_type, root_account_id: global_account_id})
|
||||
|
||||
if check_acct.feature_enabled?(:notification_service)
|
||||
enqueue_to_sqs
|
||||
else
|
||||
|
|
|
@ -299,12 +299,26 @@ describe Message do
|
|||
end
|
||||
|
||||
it "logs stats on deliver" do
|
||||
account = account_model
|
||||
@message = message_model(dispatch_at: Time.now - 1,
|
||||
notification_name: 'my_name',
|
||||
workflow_state: 'staged',
|
||||
to: 'somebody',
|
||||
updated_at: Time.now.utc - 11.minutes,
|
||||
path_type: 'email',
|
||||
user: @user,
|
||||
root_account: account)
|
||||
|
||||
|
||||
expect(InstStatsd::Statsd).to receive(:increment).with("message.deliver.email.my_name",
|
||||
{short_stat: "message.deliver",
|
||||
tags: {path_type: "email", notification_name: 'my_name'}})
|
||||
|
||||
message = message_model(dispatch_at: Time.now - 1, notification_name: 'my_name', workflow_state: 'staged', to: 'somebody', updated_at: Time.now.utc - 11.minutes, path_type: 'email', user: @user)
|
||||
expect(message).to receive(:dispatch).and_return(true)
|
||||
expect(InstStatsd::Statsd).to receive(:increment).with("message.deliver.email.#{@message.root_account.global_id}",
|
||||
{short_stat: "message.deliver_per_account",
|
||||
tags: {path_type: "email", root_account_id: @message.root_account.global_id}})
|
||||
|
||||
expect(@message).to receive(:dispatch).and_return(true)
|
||||
@message.deliver
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue