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

ref(measurements): Update setMeasurements to only set a single measurement #4920

Merged
merged 7 commits into from Apr 13, 2022

Conversation

lforst
Copy link
Member

@lforst lforst commented Apr 12, 2022

Currently, users have to keep track of the existing measurements if they want to update them, which is a bit painful.

This updates setMeasurements to only set a single measurement similar to how @sl0thentr0py did it for the python SDK getsentry/sentry-python#1359.

We don't want to have both methods because we don't want to unnecessarily increase API surface.

Ref: https://getsentry.atlassian.net/browse/WEB-835

@github-actions
Copy link
Contributor

github-actions bot commented Apr 12, 2022

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.13 KB (-0.04% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 64.28 KB (-0.52% 🔽)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.78 KB (-0.44% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 57.83 KB (-0.25% 🔽)
@sentry/browser - Webpack (gzipped + minified) 23.37 KB (+0.56% 🔺)
@sentry/browser - Webpack (minified) 81.11 KB (-0.74% 🔽)
@sentry/react - Webpack (gzipped + minified) 23.4 KB (+0.56% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.87 KB (-0.4% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.99 KB (-0.31% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.32 KB (-0.65% 🔽)

* @hidden
*/
public setMeasurements(measurements: Measurements): void {
this._measurements = { ...measurements };
public setMeasurement(name: string, value: number, unit: MeasurementUnit = 'ms'): void {
Copy link
Member

Choose a reason for hiding this comment

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

The default should be an empty string, ms is pretty unexpected behaviour.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that I know units are basically free form text, I agree. Changed in dd9f8c8.

packages/tracing/src/browser/metrics.ts Outdated Show resolved Hide resolved
packages/types/src/transaction.ts Outdated Show resolved Hide resolved
@@ -17,7 +17,7 @@ const global = getGlobalObject<Window>();

/** Class tracking metrics */
export class MetricsInstrumentation {
private _measurements: Measurements = {};
private _measurements: Record<string, { value: number }> = {};
Copy link
Member

Choose a reason for hiding this comment

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

do we need to add units to any of these? Most vitals like LCP are in seconds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added units here: afcdaee

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

lets goooo!

@lforst lforst requested a review from AbhiPrasad April 12, 2022 15:55
@lforst lforst marked this pull request as ready for review April 12, 2022 15:55
@@ -79,14 +79,14 @@ export class MetricsInstrumentation {

if (entry.name === 'first-paint' && shouldRecord) {
IS_DEBUG_BUILD && logger.log('[Measurements] Adding FP');
this._measurements['fp'] = { value: entry.startTime };
this._measurements['mark.fp'] = { value: startTimestamp };
this._measurements['fp'] = { value: entry.startTime, unit: 'millisecond' };
Copy link
Member

Choose a reason for hiding this comment

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

wait the units are supposed to be send in full form? We can't use ms or s?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jan-auer informed me that fully written out and singular is the way to go

@jan-auer can you confirm?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the source of truth: getsentry/relay#1217

So we should use the fully written out version.

@lforst lforst merged commit 20b8c52 into 7.x Apr 13, 2022
@lforst lforst deleted the lforst-setmeasurement branch April 13, 2022 13:31
@lforst
Copy link
Member Author

lforst commented Apr 13, 2022

Merging this. We can iterate later on the whole download speed units thing. Jan is aware that this needs to be thoroughly defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants