@@ -112,12 +112,6 @@ pub enum MetricNamespace {
112
112
Transactions ,
113
113
/// Metrics extracted from spans.
114
114
Spans ,
115
- /// User-defined metrics directly sent by SDKs and applications.
116
- Custom ,
117
- /// Metric stats.
118
- ///
119
- /// Metrics about metrics.
120
- Stats ,
121
115
/// An unknown and unsupported metric.
122
116
///
123
117
/// Metrics that Relay either doesn't know or recognize the namespace of will be dropped before
@@ -132,30 +126,21 @@ pub enum MetricNamespace {
132
126
133
127
impl MetricNamespace {
134
128
/// Returns all namespaces/variants of this enum.
135
- pub fn all ( ) -> [ Self ; 6 ] {
129
+ pub fn all ( ) -> [ Self ; 4 ] {
136
130
[
137
131
Self :: Sessions ,
138
132
Self :: Transactions ,
139
133
Self :: Spans ,
140
- Self :: Custom ,
141
- Self :: Stats ,
142
134
Self :: Unsupported ,
143
135
]
144
136
}
145
137
146
- /// Returns `true` if metric stats are enabled for this namespace.
147
- pub fn has_metric_stats ( & self ) -> bool {
148
- matches ! ( self , Self :: Custom )
149
- }
150
-
151
138
/// Returns the string representation for this metric type.
152
139
pub fn as_str ( & self ) -> & ' static str {
153
140
match self {
154
141
Self :: Sessions => "sessions" ,
155
142
Self :: Transactions => "transactions" ,
156
143
Self :: Spans => "spans" ,
157
- Self :: Custom => "custom" ,
158
- Self :: Stats => "metric_stats" ,
159
144
Self :: Unsupported => "unsupported" ,
160
145
}
161
146
}
@@ -169,8 +154,6 @@ impl std::str::FromStr for MetricNamespace {
169
154
"sessions" => Ok ( Self :: Sessions ) ,
170
155
"transactions" => Ok ( Self :: Transactions ) ,
171
156
"spans" => Ok ( Self :: Spans ) ,
172
- "custom" => Ok ( Self :: Custom ) ,
173
- "metric_stats" => Ok ( Self :: Stats ) ,
174
157
_ => Ok ( Self :: Unsupported ) ,
175
158
}
176
159
}
@@ -269,7 +252,7 @@ impl<'a> MetricResourceIdentifier<'a> {
269
252
270
253
let ( namespace, name) = match name_and_namespace. split_once ( '/' ) {
271
254
Some ( ( raw_namespace, name) ) => ( raw_namespace. parse ( ) ?, name) ,
272
- None => ( MetricNamespace :: Custom , name_and_namespace ) ,
255
+ None => return Err ( ParseMetricError ) ,
273
256
} ;
274
257
275
258
let name = crate :: metrics:: try_normalize_metric_name ( name) . ok_or ( ParseMetricError ) ?;
@@ -346,7 +329,7 @@ fn parse_name_unit(string: &str) -> Option<(&str, MetricUnit)> {
346
329
347
330
#[ cfg( test) ]
348
331
mod tests {
349
- use crate :: metrics:: { CustomUnit , DurationUnit } ;
332
+ use crate :: metrics:: DurationUnit ;
350
333
351
334
use super :: * ;
352
335
@@ -368,38 +351,24 @@ mod tests {
368
351
369
352
#[ test]
370
353
fn test_parse_mri_lenient ( ) {
354
+ assert ! ( MetricResourceIdentifier :: parse( "c:foo@none" ) . is_err( ) , ) ;
355
+ assert ! ( MetricResourceIdentifier :: parse( "c:foo@something" ) . is_err( ) ) ;
356
+ assert ! ( MetricResourceIdentifier :: parse( "foo" ) . is_err( ) ) ;
357
+
371
358
assert_eq ! (
372
- MetricResourceIdentifier :: parse( "c:foo@none" ) . unwrap( ) ,
373
- MetricResourceIdentifier {
374
- ty: MetricType :: Counter ,
375
- namespace: MetricNamespace :: Custom ,
376
- name: "foo" . into( ) ,
377
- unit: MetricUnit :: None ,
378
- } ,
379
- ) ;
380
- assert_eq ! (
381
- MetricResourceIdentifier :: parse( "c:foo" ) . unwrap( ) ,
382
- MetricResourceIdentifier {
383
- ty: MetricType :: Counter ,
384
- namespace: MetricNamespace :: Custom ,
385
- name: "foo" . into( ) ,
386
- unit: MetricUnit :: None ,
387
- } ,
388
- ) ;
389
- assert_eq ! (
390
- MetricResourceIdentifier :: parse( "c:custom/foo" ) . unwrap( ) ,
359
+ MetricResourceIdentifier :: parse( "c:transactions/foo" ) . unwrap( ) ,
391
360
MetricResourceIdentifier {
392
361
ty: MetricType :: Counter ,
393
- namespace: MetricNamespace :: Custom ,
362
+ namespace: MetricNamespace :: Transactions ,
394
363
name: "foo" . into( ) ,
395
364
unit: MetricUnit :: None ,
396
365
} ,
397
366
) ;
398
367
assert_eq ! (
399
- MetricResourceIdentifier :: parse( "c:custom /foo@millisecond" ) . unwrap( ) ,
368
+ MetricResourceIdentifier :: parse( "c:transactions /foo@millisecond" ) . unwrap( ) ,
400
369
MetricResourceIdentifier {
401
370
ty: MetricType :: Counter ,
402
- namespace: MetricNamespace :: Custom ,
371
+ namespace: MetricNamespace :: Transactions ,
403
372
name: "foo" . into( ) ,
404
373
unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
405
374
} ,
@@ -413,32 +382,10 @@ mod tests {
413
382
unit: MetricUnit :: None ,
414
383
} ,
415
384
) ;
416
- assert_eq ! (
417
- MetricResourceIdentifier :: parse( "c:foo@something" ) . unwrap( ) ,
418
- MetricResourceIdentifier {
419
- ty: MetricType :: Counter ,
420
- namespace: MetricNamespace :: Custom ,
421
- name: "foo" . into( ) ,
422
- unit: MetricUnit :: Custom ( CustomUnit :: parse( "something" ) . unwrap( ) ) ,
423
- } ,
424
- ) ;
425
- assert ! ( MetricResourceIdentifier :: parse( "foo" ) . is_err( ) ) ;
426
385
}
427
386
428
387
#[ test]
429
388
fn test_invalid_names_should_normalize ( ) {
430
- assert_eq ! (
431
- MetricResourceIdentifier :: parse( "c:f?o" ) . unwrap( ) . name,
432
- "f_o"
433
- ) ;
434
- assert_eq ! (
435
- MetricResourceIdentifier :: parse( "c:f??o" ) . unwrap( ) . name,
436
- "f_o"
437
- ) ;
438
- assert_eq ! (
439
- MetricResourceIdentifier :: parse( "c:föo" ) . unwrap( ) . name,
440
- "f_o"
441
- ) ;
442
389
assert_eq ! (
443
390
MetricResourceIdentifier :: parse( "c:custom/f?o" )
444
391
. unwrap( )
@@ -487,10 +434,10 @@ mod tests {
487
434
#[ test]
488
435
fn test_normalize_dash_to_underscore ( ) {
489
436
assert_eq ! (
490
- MetricResourceIdentifier :: parse( "d:foo.bar.blob-size@second" ) . unwrap( ) ,
437
+ MetricResourceIdentifier :: parse( "d:transactions/ foo.bar.blob-size@second" ) . unwrap( ) ,
491
438
MetricResourceIdentifier {
492
439
ty: MetricType :: Distribution ,
493
- namespace: MetricNamespace :: Custom ,
440
+ namespace: MetricNamespace :: Transactions ,
494
441
name: "foo.bar.blob_size" . into( ) ,
495
442
unit: MetricUnit :: Duration ( DurationUnit :: Second ) ,
496
443
} ,
@@ -506,7 +453,7 @@ mod tests {
506
453
. unwrap( ) ,
507
454
MetricResourceIdentifier {
508
455
ty: MetricType :: Counter ,
509
- namespace: MetricNamespace :: Custom ,
456
+ namespace: MetricNamespace :: Unsupported ,
510
457
name: "foo" . into( ) ,
511
458
unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
512
459
} ,
@@ -518,12 +465,12 @@ mod tests {
518
465
assert_eq ! (
519
466
serde_json:: to_string( & MetricResourceIdentifier {
520
467
ty: MetricType :: Counter ,
521
- namespace: MetricNamespace :: Custom ,
468
+ namespace: MetricNamespace :: Transactions ,
522
469
name: "foo" . into( ) ,
523
470
unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
524
471
} )
525
472
. unwrap( ) ,
526
- "\" c:custom /foo@millisecond\" " . to_owned( ) ,
473
+ "\" c:transactions /foo@millisecond\" " . to_owned( ) ,
527
474
) ;
528
475
}
529
476
}
0 commit comments