@@ -112,12 +112,6 @@ pub enum MetricNamespace {
112112 Transactions ,
113113 /// Metrics extracted from spans.
114114 Spans ,
115- /// User-defined metrics directly sent by SDKs and applications.
116- Custom ,
117- /// Metric stats.
118- ///
119- /// Metrics about metrics.
120- Stats ,
121115 /// An unknown and unsupported metric.
122116 ///
123117 /// Metrics that Relay either doesn't know or recognize the namespace of will be dropped before
@@ -132,30 +126,21 @@ pub enum MetricNamespace {
132126
133127impl MetricNamespace {
134128 /// Returns all namespaces/variants of this enum.
135- pub fn all ( ) -> [ Self ; 6 ] {
129+ pub fn all ( ) -> [ Self ; 4 ] {
136130 [
137131 Self :: Sessions ,
138132 Self :: Transactions ,
139133 Self :: Spans ,
140- Self :: Custom ,
141- Self :: Stats ,
142134 Self :: Unsupported ,
143135 ]
144136 }
145137
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-
151138 /// Returns the string representation for this metric type.
152139 pub fn as_str ( & self ) -> & ' static str {
153140 match self {
154141 Self :: Sessions => "sessions" ,
155142 Self :: Transactions => "transactions" ,
156143 Self :: Spans => "spans" ,
157- Self :: Custom => "custom" ,
158- Self :: Stats => "metric_stats" ,
159144 Self :: Unsupported => "unsupported" ,
160145 }
161146 }
@@ -169,8 +154,6 @@ impl std::str::FromStr for MetricNamespace {
169154 "sessions" => Ok ( Self :: Sessions ) ,
170155 "transactions" => Ok ( Self :: Transactions ) ,
171156 "spans" => Ok ( Self :: Spans ) ,
172- "custom" => Ok ( Self :: Custom ) ,
173- "metric_stats" => Ok ( Self :: Stats ) ,
174157 _ => Ok ( Self :: Unsupported ) ,
175158 }
176159 }
@@ -269,7 +252,7 @@ impl<'a> MetricResourceIdentifier<'a> {
269252
270253 let ( namespace, name) = match name_and_namespace. split_once ( '/' ) {
271254 Some ( ( raw_namespace, name) ) => ( raw_namespace. parse ( ) ?, name) ,
272- None => ( MetricNamespace :: Custom , name_and_namespace ) ,
255+ None => return Err ( ParseMetricError ) ,
273256 } ;
274257
275258 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)> {
346329
347330#[ cfg( test) ]
348331mod tests {
349- use crate :: metrics:: { CustomUnit , DurationUnit } ;
332+ use crate :: metrics:: DurationUnit ;
350333
351334 use super :: * ;
352335
@@ -368,38 +351,24 @@ mod tests {
368351
369352 #[ test]
370353 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+
371358 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( ) ,
391360 MetricResourceIdentifier {
392361 ty: MetricType :: Counter ,
393- namespace: MetricNamespace :: Custom ,
362+ namespace: MetricNamespace :: Transactions ,
394363 name: "foo" . into( ) ,
395364 unit: MetricUnit :: None ,
396365 } ,
397366 ) ;
398367 assert_eq ! (
399- MetricResourceIdentifier :: parse( "c:custom /foo@millisecond" ) . unwrap( ) ,
368+ MetricResourceIdentifier :: parse( "c:transactions /foo@millisecond" ) . unwrap( ) ,
400369 MetricResourceIdentifier {
401370 ty: MetricType :: Counter ,
402- namespace: MetricNamespace :: Custom ,
371+ namespace: MetricNamespace :: Transactions ,
403372 name: "foo" . into( ) ,
404373 unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
405374 } ,
@@ -413,32 +382,10 @@ mod tests {
413382 unit: MetricUnit :: None ,
414383 } ,
415384 ) ;
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( ) ) ;
426385 }
427386
428387 #[ test]
429388 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- ) ;
442389 assert_eq ! (
443390 MetricResourceIdentifier :: parse( "c:custom/f?o" )
444391 . unwrap( )
@@ -487,10 +434,10 @@ mod tests {
487434 #[ test]
488435 fn test_normalize_dash_to_underscore ( ) {
489436 assert_eq ! (
490- MetricResourceIdentifier :: parse( "d:foo.bar.blob-size@second" ) . unwrap( ) ,
437+ MetricResourceIdentifier :: parse( "d:transactions/ foo.bar.blob-size@second" ) . unwrap( ) ,
491438 MetricResourceIdentifier {
492439 ty: MetricType :: Distribution ,
493- namespace: MetricNamespace :: Custom ,
440+ namespace: MetricNamespace :: Transactions ,
494441 name: "foo.bar.blob_size" . into( ) ,
495442 unit: MetricUnit :: Duration ( DurationUnit :: Second ) ,
496443 } ,
@@ -506,7 +453,7 @@ mod tests {
506453 . unwrap( ) ,
507454 MetricResourceIdentifier {
508455 ty: MetricType :: Counter ,
509- namespace: MetricNamespace :: Custom ,
456+ namespace: MetricNamespace :: Unsupported ,
510457 name: "foo" . into( ) ,
511458 unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
512459 } ,
@@ -518,12 +465,12 @@ mod tests {
518465 assert_eq ! (
519466 serde_json:: to_string( & MetricResourceIdentifier {
520467 ty: MetricType :: Counter ,
521- namespace: MetricNamespace :: Custom ,
468+ namespace: MetricNamespace :: Transactions ,
522469 name: "foo" . into( ) ,
523470 unit: MetricUnit :: Duration ( DurationUnit :: MilliSecond ) ,
524471 } )
525472 . unwrap( ) ,
526- "\" c:custom /foo@millisecond\" " . to_owned( ) ,
473+ "\" c:transactions /foo@millisecond\" " . to_owned( ) ,
527474 ) ;
528475 }
529476}
0 commit comments