-
-
Notifications
You must be signed in to change notification settings - Fork 257
Set custom measurements on transactions #1011
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ab17dfc
Feat set custom measurement
marandaneto 9fb63ab
ref
marandaneto 2ab2e0a
fix tests
marandaneto 0770a10
fix mocks
marandaneto 5d34cae
fix test
marandaneto f79c283
add tests
marandaneto 6d8a8df
fix internal usafge
marandaneto cd867fe
Merge branch 'main' into chore/set-measurement
marandaneto fb88d9f
Merge branch 'main' into chore/set-measurement
marandaneto fc1bc4e
fix
marandaneto 2f1466b
Merge branch 'main' into chore/set-measurement
marandaneto 5ab1c11
fix conflicts
marandaneto 1ccd974
fix changelog
marandaneto a8a3c07
Update CHANGELOG.md
marandaneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,52 @@ | ||
import 'sentry_measurement_unit.dart'; | ||
|
||
class SentryMeasurement { | ||
SentryMeasurement(this.name, this.value); | ||
SentryMeasurement( | ||
this.name, | ||
this.value, { | ||
this.unit, | ||
}); | ||
|
||
/// Amount of frames drawn during a transaction | ||
SentryMeasurement.totalFrames(this.value) : name = 'frames_total'; | ||
SentryMeasurement.totalFrames(this.value) | ||
: name = 'frames_total', | ||
unit = SentryMeasurementUnit.none; | ||
marandaneto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Amount of slow frames drawn during a transaction. | ||
/// A slow frame is any frame longer than 1s / refreshrate. | ||
/// So for example any frame slower than 16ms for a refresh rate of 60hz. | ||
SentryMeasurement.slowFrames(this.value) : name = 'frames_slow'; | ||
SentryMeasurement.slowFrames(this.value) | ||
: name = 'frames_slow', | ||
unit = SentryMeasurementUnit.none; | ||
|
||
/// Amount of frozen frames drawn during a transaction. | ||
/// Typically defined as frames slower than 500ms. | ||
SentryMeasurement.frozenFrames(this.value) : name = 'frames_frozen'; | ||
SentryMeasurement.frozenFrames(this.value) | ||
: name = 'frames_frozen', | ||
unit = SentryMeasurementUnit.none; | ||
|
||
/// Duration of the Cold App start in milliseconds | ||
SentryMeasurement.coldAppStart(Duration duration) | ||
: assert(!duration.isNegative), | ||
name = 'app_start_cold', | ||
value = duration.inMilliseconds; | ||
value = duration.inMilliseconds, | ||
unit = SentryMeasurementUnit.milliSecond; | ||
|
||
/// Duration of the Warm App start in milliseconds | ||
SentryMeasurement.warmAppStart(Duration duration) | ||
: assert(!duration.isNegative), | ||
name = 'app_start_warm', | ||
value = duration.inMilliseconds; | ||
value = duration.inMilliseconds, | ||
unit = SentryMeasurementUnit.milliSecond; | ||
|
||
final String name; | ||
final num value; | ||
final SentryMeasurementUnit? unit; | ||
|
||
Map<String, dynamic> toJson() { | ||
return <String, num>{ | ||
return <String, dynamic>{ | ||
'value': value, | ||
if (unit != null) 'unit': unit?.toStringValue(), | ||
}; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
enum SentryMeasurementUnit { | ||
/// Nanosecond (`"nanosecond"`), 10^-9 seconds. | ||
nanoSecond, | ||
|
||
/// Microsecond (`"microsecond"`), 10^-6 seconds. | ||
microSecond, | ||
|
||
/// Millisecond (`"millisecond"`), 10^-3 seconds. | ||
milliSecond, | ||
|
||
/// Full second (`"second"`). | ||
second, | ||
|
||
/// Minute (`"minute"`), 60 seconds. | ||
minute, | ||
|
||
/// Hour (`"hour"`), 3600 seconds. | ||
hour, | ||
|
||
/// Day (`"day"`), 86,400 seconds. | ||
day, | ||
|
||
/// Week (`"week"`), 604,800 seconds. | ||
week, | ||
marandaneto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Untyped value without a unit. | ||
none, | ||
} | ||
|
||
extension SentryMeasurementUnitExtension on SentryMeasurementUnit { | ||
String toStringValue() { | ||
switch (this) { | ||
case SentryMeasurementUnit.nanoSecond: | ||
return 'nanosecond'; | ||
case SentryMeasurementUnit.microSecond: | ||
return 'microsecond'; | ||
case SentryMeasurementUnit.milliSecond: | ||
return 'millisecond'; | ||
case SentryMeasurementUnit.second: | ||
return 'second'; | ||
case SentryMeasurementUnit.minute: | ||
return 'minute'; | ||
case SentryMeasurementUnit.hour: | ||
return 'hour'; | ||
case SentryMeasurementUnit.day: | ||
return 'day'; | ||
case SentryMeasurementUnit.week: | ||
return 'week'; | ||
case SentryMeasurementUnit.none: | ||
return 'none'; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group('$SentryMeasurement', () { | ||
test('total frames has none unit', () { | ||
expect( | ||
SentryMeasurement.totalFrames(10).unit, SentryMeasurementUnit.none); | ||
}); | ||
|
||
test('slow frames has none unit', () { | ||
expect(SentryMeasurement.slowFrames(10).unit, SentryMeasurementUnit.none); | ||
}); | ||
|
||
test('frozen frames has none unit', () { | ||
expect( | ||
SentryMeasurement.frozenFrames(10).unit, SentryMeasurementUnit.none); | ||
}); | ||
|
||
test('warm start has milliseconds unit', () { | ||
expect(SentryMeasurement.warmAppStart(Duration(seconds: 1)).unit, | ||
SentryMeasurementUnit.milliSecond); | ||
}); | ||
|
||
test('cold start has milliseconds unit', () { | ||
expect(SentryMeasurement.coldAppStart(Duration(seconds: 1)).unit, | ||
SentryMeasurementUnit.milliSecond); | ||
}); | ||
|
||
test('toJson sets unit if given', () { | ||
final measurement = SentryMeasurement('name', 10, | ||
unit: SentryMeasurementUnit.milliSecond); | ||
final map = <String, dynamic>{ | ||
'value': 10, | ||
'unit': 'millisecond', | ||
}; | ||
|
||
expect(MapEquality().equals(measurement.toJson(), map), true); | ||
}); | ||
}); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.