MSFT sync: fix bug in pagination metrics tagging

refs INTEROP-6798
flag=microsoft_group_enrollments_syncing

Test plan:
- specs should be enough

Change-Id: Ie848d0844a4966c3ed6c14e313e10f102eb4b7c8
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/267808
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ryan Hawkins <ryan.hawkins@instructure.com>
QA-Review: Ryan Hawkins <ryan.hawkins@instructure.com>
Product-Review: Evan Battaglia <ebattaglia@instructure.com>
This commit is contained in:
Evan Battaglia 2021-06-24 15:14:38 -06:00
parent 7d3a6e0512
commit 0efe16d746
2 changed files with 12 additions and 2 deletions

View File

@ -202,7 +202,10 @@ module MicrosoftSync
end
end
def statsd_tags_for_request(method, path)
def statsd_tags_for_request(method, path_or_url)
# Strip https, hostname, "v1.0"
path = path_or_url.gsub(%r{^https?://[^/]*/[^/]*/}, '')
{
msft_endpoint: InstStatsd::Statsd.escape("#{method.to_s.downcase}_#{path.split('/').first}")
}

View File

@ -104,7 +104,14 @@ describe MicrosoftSync::GraphServiceHttp do
end
end
# it 'uses the correct msft_endpoint when passed in a url' TODO this bug hasn't been fixed yet
it 'uses the correct msft_endpoint when passed in a url' do
# pagination "next" links are complete URLs
subject.request(:get, 'https://graph.microsoft.com/v1.0/foo/bar', quota: [1, 0])
expect(InstStatsd::Statsd).to have_received(:count)
.with("microsoft_sync.graph_service.quota_read", 1, tags: {msft_endpoint: 'get_foo'})
expect(InstStatsd::Statsd).to have_received(:increment)
.with("microsoft_sync.graph_service.success", tags: {msft_endpoint: 'get_foo'})
end
end
describe '#expand_options' do