Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/fxa-auth-server/lib/customs.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,19 @@ class CustomsClient {
}

if (this.statsd) {
const tags = { action, block: options.block, ...options };
const tags = { action };
if (options.block != null) {
tags.block = options.block;
}
if (options.suspect != null) {
tags.suspect = options.suspect;
}
if (options.unblock != null) {
tags.unblock = options.unblock;
}
if (options.blockReason != null) {
tags.blockReason = options.blockReason;
}
this.statsd.increment(`${serviceName}.${name}`, tags);
}
}
Expand Down
15 changes: 12 additions & 3 deletions packages/fxa-auth-server/test/local/customs.js
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,15 @@ describe('Customs', () => {
suspect: true,
unblock: true,
blockReason: 'other',
// Important! Values with high cardinality like retryAfter
// should be sent to statsd!
retryAfter: 1111,
};
const validTags = {
block: true,
suspect: true,
unblock: true,
blockReason: 'other',
};

beforeEach(() => {
Expand All @@ -739,10 +748,10 @@ describe('Customs', () => {
await customsWithUrl.check(request, email, action);
assert.fail('should have failed');
} catch (err) {
assert.isTrue(
assert.isTrue(
statsd.increment.calledWithExactly('customs.request.check', {
action,
...tags,
...validTags,
})
);
assert.isTrue(statsd.timing.calledWithMatch('customs.check.success'));
Expand All @@ -765,7 +774,7 @@ describe('Customs', () => {
assert.isTrue(
statsd.increment.calledWithExactly('customs.request.checkIpOnly', {
action,
...tags,
...validTags,
})
);
assert.isTrue(
Expand Down