Skip to content

Commit bebdf23

Browse files
authored
Merge pull request #18847 from mozilla/FXA-11492
task(auth-server): Don't report retryAfter to statsd on customs check events
2 parents 16fb96b + 5ba7743 commit bebdf23

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

packages/fxa-auth-server/lib/customs.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,19 @@ class CustomsClient {
175175
}
176176

177177
if (this.statsd) {
178-
const tags = { action, block: options.block, ...options };
178+
const tags = { action };
179+
if (options.block != null) {
180+
tags.block = options.block;
181+
}
182+
if (options.suspect != null) {
183+
tags.suspect = options.suspect;
184+
}
185+
if (options.unblock != null) {
186+
tags.unblock = options.unblock;
187+
}
188+
if (options.blockReason != null) {
189+
tags.blockReason = options.blockReason;
190+
}
179191
this.statsd.increment(`${serviceName}.${name}`, tags);
180192
}
181193
}

packages/fxa-auth-server/test/local/customs.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,15 @@ describe('Customs', () => {
726726
suspect: true,
727727
unblock: true,
728728
blockReason: 'other',
729+
// Important! Values with high cardinality like retryAfter
730+
// should be sent to statsd!
731+
retryAfter: 1111,
732+
};
733+
const validTags = {
734+
block: true,
735+
suspect: true,
736+
unblock: true,
737+
blockReason: 'other',
729738
};
730739

731740
beforeEach(() => {
@@ -739,10 +748,10 @@ describe('Customs', () => {
739748
await customsWithUrl.check(request, email, action);
740749
assert.fail('should have failed');
741750
} catch (err) {
742-
assert.isTrue(
751+
assert.isTrue(
743752
statsd.increment.calledWithExactly('customs.request.check', {
744753
action,
745-
...tags,
754+
...validTags,
746755
})
747756
);
748757
assert.isTrue(statsd.timing.calledWithMatch('customs.check.success'));
@@ -765,7 +774,7 @@ describe('Customs', () => {
765774
assert.isTrue(
766775
statsd.increment.calledWithExactly('customs.request.checkIpOnly', {
767776
action,
768-
...tags,
777+
...validTags,
769778
})
770779
);
771780
assert.isTrue(

0 commit comments

Comments
 (0)