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

feat(metrics): Rename all metrics extracted by relay [INGEST-548] #30472

Merged
merged 20 commits into from
Dec 14, 2021

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Dec 7, 2021

As in getsentry/relay#1147, prefix all metric names with either sentry.sessions. or sentry.transactions..

@jjbayer
Copy link
Member Author

jjbayer commented Dec 7, 2021

@priscilawebdev or @matejminar could I please ask one of you to make the same changes on the front end? Basically just change the metric name for every API request in Performance from e.g. measurements.lcp to sentry.transactions.measurements.lcp. Feel free to push into this PR.

@priscilawebdev
Copy link
Member

sure @jjbayer I'll do it 😉

@jjbayer jjbayer requested a review from ahmedetefy December 7, 2021 17:41
src/sentry/release_health/metrics.py Show resolved Hide resolved
@@ -470,28 +471,28 @@ class SnubaField:
)

_METRICS = {
"session": {
SessionMetricKey.SESSION.value: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would recommend here not adding the .value and just using the enum

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the idea, but this dict also contains metric names that are not session metrics, so I think we should stick with strings here.

src/sentry/sentry_metrics/indexer/mock.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2021

size-limit report

Path Base Size (d7076ab) Current Size Change
src/sentry/static/sentry/dist/entrypoints/app.js 52.87 KB 52.87 KB -0.01% 🔽
src/sentry/static/sentry/dist/entrypoints/sentry.css 70.88 KB 70.88 KB 0%

@@ -258,7 +257,7 @@ def get_values(
started = int(data_points[key])
abnormal = int(data_points.get(replace(key, raw_session_status="abnormal"), 0))
crashed = int(data_points.get(replace(key, raw_session_status="crashed"), 0))
errored_key = replace(key, metric_name="session.error", raw_session_status=None)
errored_key = replace(key, metric_name=MetricKey.SESSION_ERROR, raw_session_status=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a .value ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the type of metric_name to MetricKey, but did not to rename the variable itself. Renamed to metric_key now to make it more clear.

Copy link
Member Author

@jjbayer jjbayer left a comment

Choose a reason for hiding this comment

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

@priscilawebdev Thank you for your contribution! I tested it locally and everything works as expected. Could you please review my latest commit? I accidentally added the wrong prefix to transaction.duration so I fixed that now, and renamed MeasurementMetric to TransactionMetric in the process.


export const METRICS: Readonly<Record<SessionMetric | TransactionMetric, ColumnType>> = {
// Session metrics
[TransactionMetric.TRANSACTION_DURATION]: 'duration',
Copy link
Member

Choose a reason for hiding this comment

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

@jjbayer can you confirm that the types are correct here?

Copy link
Member Author

Choose a reason for hiding this comment

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

They look correct, the tricky thing is that count(transaction.duration) is actually an integer, while avg(transaction.duration), p95(transaction.duration) etc. are durations.

@@ -710,7 +717,7 @@ describe('Performance > Widgets > WidgetContainer', function () {
'p50 Duration'
);

expect(wrapper.find('HighlightNumber').text()).toEqual('51s');
expect(wrapper.find('HighlightNumber').text()).toEqual('534ms');
Copy link
Member

Choose a reason for hiding this comment

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

Why is this assertion updated? I thought this is only renaming stuff, did some logic change?

Copy link
Member

Choose a reason for hiding this comment

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

yes this part of the code was updated

TRANSACTION_DURATION = 'sentry.transactions.transaction.duration',
}

export const METRICS: Readonly<Record<SessionMetric | TransactionMetric, ColumnType>> = {
Copy link
Member

Choose a reason for hiding this comment

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

Exported METRICS variable is very generic, can we please rename it to something more descriptive? Like METRIC_TO_COLUMN_TYPE.


export const METRICS: Readonly<Record<SessionMetric | TransactionMetric, ColumnType>> = {
// Session metrics
[TransactionMetric.TRANSACTION_DURATION]: 'duration',
Copy link
Member

Choose a reason for hiding this comment

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

Should this one be moved to the Transaction metrics group below?

Comment on lines 4 to 15
SESSION = 'sentry.sessions.session',
SESSION_DURATION = 'sentry.sessions.session.duration',
SESSION_ERROR = 'sentry.sessions.session.error',
USER = 'sentry.sessions.user',
}

export enum TransactionMetric {
MEASUREMENTS_FP = 'sentry.transactions.measurements.fp',
MEASUREMENTS_FCP = 'sentry.transactions.measurements.fcp',
MEASUREMENTS_LCP = 'sentry.transactions.measurements.lcp',
MEASUREMENTS_FID = 'sentry.transactions.measurements.fid',
MEASUREMENTS_CLS = 'sentry.transactions.measurements.cls',
Copy link
Member

Choose a reason for hiding this comment

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

nit: Would be nice to have prefixes sentry.sessions and sentry.transactions as a constant.

@@ -542,7 +539,7 @@ def _flatten_data(org_id: int, data: _SnubaDataByMetric) -> _DataPoints:
if raw_session_status is not None:
raw_session_status = _reverse_resolve_ensured(raw_session_status)
flat_key = _DataPointKey(
metric_name=metric_name,
metric_key=metric_name,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe rename here the metric_name to metric_key then

@jjbayer jjbayer merged commit 63fa2a1 into master Dec 14, 2021
@jjbayer jjbayer deleted the feat/rename-metrics branch December 14, 2021 13:45
@github-actions github-actions bot locked and limited conversation to collaborators Dec 30, 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.

5 participants