Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

feat(metrics): Log the number of stored accounts on the /signin page. #4493

Merged
merged 3 commits into from Jan 10, 2017

Conversation

shane-tomlinson
Copy link

@shane-tomlinson shane-tomlinson commented Dec 9, 2016

The User model became very complex to support allowing users to sign in
to reliers using more than one address. This is to see how many accounts
the normal user has whenever they first visit the signin page to see
how often this capability is actually being used. If a very low number
of people make use of this, I'd like to vastly simplify the User model.

@vladikoff or @rfk - r?

*/
logNumStoredAccounts () {
const numAccounts = Object.keys(this._accounts()).length;
this._metrics.logEventOnce(`num.accounts.${numAccounts}`);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with this format instead of a top level metric because top level metrics are reported on every flush and this minimizes the number of duplicate events.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's worth bucketing this in case of outliers, e.g. log everyone with more than 2 accounts into a singlenum.accounts.two_or_more bucket.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah agreed, this event should either use the .histogram feature of node-statsd or bucket the numAccounts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to make transformations as late as possible for flexibility and so we can visualize data in different ways in the future.

Yeah agreed, this event should either use the .histogram

We tried using .histogram way back in the day and had some issues, I forget what they were, but I vaguely remember .histogram being treated identically to .count items. Maybe that's been fixed, or there's an extremely high chance I'm mis-remembering. Can histograms be done with normal .count items in DD?

or bucket the numAccounts

I understand the case of outliers, though can the same be done in later stages (DD) so we still retain flexibility?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tried using .histogram way back in the day and had some issues, I forget what they were, but I vaguely remember .histogram being treated identically to .count items.

Your memory is correct. Forwarding you the email thread that we had about this with DataDog, although it was a while back (September 2015) so maybe things are different now.

@vladikoff
Copy link
Contributor

from mtg: needs update to PR

@shane-tomlinson shane-tomlinson changed the title feat(metrics): Log the number of stored accounts on the /signin page. [WIP] feat(metrics): Log the number of stored accounts on the /signin page. Dec 22, 2016
@shane-tomlinson shane-tomlinson changed the title [WIP] feat(metrics): Log the number of stored accounts on the /signin page. feat(metrics): Log the number of stored accounts on the /signin page. Jan 6, 2017
@shane-tomlinson
Copy link
Author

I'm happy with how this turned out, @rfk, and @vladikoff - mind having another r?

this._entrypoint = options.entrypoint || NOT_REPORTED_VALUE;
this._migration = options.migration || NOT_REPORTED_VALUE;
this._service = options.service || NOT_REPORTED_VALUE;
this._able = options.able;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it difficult to navigate this mess, so I sorted most items alphabetically.

Copy link
Contributor

@rfk rfk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I paged out all context on what the old version looked like, but the new version looks fine to me. I left one question about the tag format, but otherwise r+

// by tag. Convert the count to a tag so we can see which tag has
// the most values.
context.increment(
type, ['has:' + reportedNumStoredAccounts].concat(tags));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to produce a tag like has:2, right? Will there be enough other context on the events to remember what that's about when looking at the graphs 6 months from now, or should we use a more descriptive tag?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be enough other context on the events to remember what that's about when looking at the graphs 6 months from now

This was my worry as writing the PR. I have no existential problems having a tag and event name being almost identical: event name: num_stored_accounts, tag name: num_stored_accounts:0, num_stored_accounts:1 or num_stored_accounts:2

@vladikoff - seem reasonable?

Shane Tomlinson added 3 commits January 10, 2017 10:24
The User model became very complex to support allowing users to sign in
to reliers using more than one address. This is to see how many accounts
the normal user has whenever they first visit the signin page to see
how often this capability is actually being used. If a very low number
of people make use of this, I'd like to vastly simplify the User model.
Send `numStoredAccounts` as a top level metric from the client->server. The metric
will normally only be sent once.

When sending data to DataDog, increment a `num_stored_accounts` event and use 3 tags
to bucket users, `has:0`, `has:1`, and `has:2`.
@shane-tomlinson shane-tomlinson merged commit f44dcb5 into master Jan 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants