diff --git a/packages/fxa-auth-server/lib/customs.js b/packages/fxa-auth-server/lib/customs.js index dabdff933bb..32ad1e777b2 100644 --- a/packages/fxa-auth-server/lib/customs.js +++ b/packages/fxa-auth-server/lib/customs.js @@ -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); } } diff --git a/packages/fxa-auth-server/test/local/customs.js b/packages/fxa-auth-server/test/local/customs.js index cf890801ba8..ec10d8c03c8 100644 --- a/packages/fxa-auth-server/test/local/customs.js +++ b/packages/fxa-auth-server/test/local/customs.js @@ -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(() => { @@ -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')); @@ -765,7 +774,7 @@ describe('Customs', () => { assert.isTrue( statsd.increment.calledWithExactly('customs.request.checkIpOnly', { action, - ...tags, + ...validTags, }) ); assert.isTrue(