1+ /// The unit of measurement of a metric value.
2+ /// Units augment metric values by giving them a magnitude and semantics.
3+ /// Units and their precisions are uniquely represented by a string identifier.
4+ ///
5+ /// This is a singe enum because Enhanced Enums in Dart is only available
6+ /// in newer versions.
17enum SentryMeasurementUnit {
8+ /// Duration units
9+
210 /// Nanosecond (`"nanosecond"` ), 10^-9 seconds.
311 nanoSecond,
412
@@ -23,13 +31,66 @@ enum SentryMeasurementUnit {
2331 /// Week (`"week"` ), 604,800 seconds.
2432 week,
2533
34+ /// Information units
35+
36+ /// Bit (`"bit"` ), corresponding to 1/8 of a byte.
37+ bit,
38+
39+ /// Byte (`"byte"` ).
40+ byte,
41+
42+ /// Kilobyte (`"kilobyte"` ), 10^3 bytes.
43+ kiloByte,
44+
45+ /// Kibibyte (`"kibibyte"` ), 2^10 bytes.
46+ kibiByte,
47+
48+ /// Megabyte (`"megabyte"` ), 10^6 bytes.
49+ megaByte,
50+
51+ /// Mebibyte (`"mebibyte"` ), 2^20 bytes.
52+ mebiByte,
53+
54+ /// Gigabyte (`"gigabyte"` ), 10^9 bytes.
55+ gigaByte,
56+
57+ /// Gibibyte (`"gibibyte"` ), 2^30 bytes.
58+ gibiByte,
59+
60+ /// Terabyte (`"terabyte"` ), 10^12 bytes.
61+ teraByte,
62+
63+ /// Tebibyte (`"tebibyte"` ), 2^40 bytes.
64+ tebiByte,
65+
66+ /// Petabyte (`"petabyte"` ), 10^15 bytes.
67+ petaByte,
68+
69+ /// Pebibyte (`"pebibyte"` ), 2^50 bytes.
70+ pebiByte,
71+
72+ /// Exabyte (`"exabyte"` ), 10^18 bytes.
73+ exaByte,
74+
75+ /// Exbibyte (`"exbibyte"` ), 2^60 bytes.
76+ exbiByte,
77+
78+ /// Fraction units
79+
80+ /// Floating point fraction of `1` .
81+ ratio,
82+
83+ /// Ratio expressed as a fraction of `100` . `100%` equals a ratio of `1.0` .
84+ percent,
85+
2686 /// Untyped value without a unit.
2787 none,
2888}
2989
3090extension SentryMeasurementUnitExtension on SentryMeasurementUnit {
3191 String toStringValue () {
3292 switch (this ) {
93+ // Duration units
3394 case SentryMeasurementUnit .nanoSecond:
3495 return 'nanosecond' ;
3596 case SentryMeasurementUnit .microSecond:
@@ -46,6 +107,44 @@ extension SentryMeasurementUnitExtension on SentryMeasurementUnit {
46107 return 'day' ;
47108 case SentryMeasurementUnit .week:
48109 return 'week' ;
110+
111+ // Information units
112+ case SentryMeasurementUnit .bit:
113+ return 'bit' ;
114+ case SentryMeasurementUnit .byte:
115+ return 'byte' ;
116+ case SentryMeasurementUnit .kiloByte:
117+ return 'kilobyte' ;
118+ case SentryMeasurementUnit .kibiByte:
119+ return 'kibibyte' ;
120+ case SentryMeasurementUnit .megaByte:
121+ return 'megabyte' ;
122+ case SentryMeasurementUnit .mebiByte:
123+ return 'mebibyte' ;
124+ case SentryMeasurementUnit .gigaByte:
125+ return 'gigabyte' ;
126+ case SentryMeasurementUnit .gibiByte:
127+ return 'gibibyte' ;
128+ case SentryMeasurementUnit .teraByte:
129+ return 'terabyte' ;
130+ case SentryMeasurementUnit .tebiByte:
131+ return 'tebibyte' ;
132+ case SentryMeasurementUnit .petaByte:
133+ return 'petabyte' ;
134+ case SentryMeasurementUnit .pebiByte:
135+ return 'pebibyte' ;
136+ case SentryMeasurementUnit .exaByte:
137+ return 'exabyte' ;
138+ case SentryMeasurementUnit .exbiByte:
139+ return 'exbibyte' ;
140+
141+ // Fraction units
142+ case SentryMeasurementUnit .ratio:
143+ return 'ratio' ;
144+ case SentryMeasurementUnit .percent:
145+ return 'percent' ;
146+
147+ // Untyped value
49148 case SentryMeasurementUnit .none:
50149 return 'none' ;
51150 }
0 commit comments