Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(metrics): Write all session metrics in test [INGEST-386] #28667

Merged
merged 4 commits into from
Sep 20, 2021

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Sep 20, 2021

Write more session metrics to snuba in metrics test case, mimicking the extract_session_metrics function in relay.

This prepares for https://getsentry.atlassian.net/browse/INGEST-386.

@jjbayer jjbayer requested review from untitaker and RaduW September 20, 2021 09:04
Copy link
Contributor

@RaduW RaduW left a comment

Choose a reason for hiding this comment

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

Generally looks good.
The only think that I think is questionable is instantiating typings.DefaultDict.
Didn't follow in details the tests but the changes seem reasonable

@@ -1,4 +1,5 @@
from typing import Optional
import itertools
from typing import DefaultDict, Optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't you import defaultdict from collections rather than this, since you are not using
it as typeinfo but you are instantiating it

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops yes, this was an auto-import I did not pay attention to.

@@ -18,25 +19,43 @@
"staging": 10,
"user": 11,
"init": 12,
"session.error": 13,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit. Why a dictionary here since all the indexes are sequential, a simple array would do (and just use the index in the array as the value).


def __init__(self):
self._counter = itertools.count(start=len(_STRINGS))
self._strings = DefaultDict(self._counter.__next__)
Copy link
Contributor

Choose a reason for hiding this comment

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

As commented above I don't think typings.DefaultDict is supposed to be used like this, could we use collections.defaultdict instead ?

@jjbayer jjbayer merged commit 575932d into master Sep 20, 2021
@jjbayer jjbayer deleted the feat/session-metrics-tests branch September 20, 2021 12:34
@github-actions github-actions bot locked and limited conversation to collaborators Oct 5, 2021
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.

2 participants