@@ -176,7 +176,7 @@ impl std::str::FromStr for MetricResourceIdentifier {
176
176
let ( raw_ty, rest) = name. split_once ( ':' ) . ok_or ( ParseMetricError ( ( ) ) ) ?;
177
177
let ty = raw_ty. parse ( ) ?;
178
178
179
- let ( raw_namespace, rest) = rest. split_once ( '/' ) . ok_or ( ParseMetricError ( ( ) ) ) ? ;
179
+ let ( raw_namespace, rest) = rest. split_once ( '/' ) . unwrap_or ( ( "custom" , rest ) ) ;
180
180
let namespace = raw_namespace. to_owned ( ) ;
181
181
182
182
let ( name, unit) = parse_name_unit ( rest) . ok_or ( ParseMetricError ( ( ) ) ) ?;
@@ -552,12 +552,12 @@ mod tests {
552
552
553
553
#[ test]
554
554
fn test_parse_counter ( ) {
555
- let s = "transactions/ foo:42|c" ;
555
+ let s = "foo:42|c" ;
556
556
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
557
557
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
558
558
insta:: assert_debug_snapshot!( metric, @r###"
559
559
Metric {
560
- name: "c:transactions/ foo",
560
+ name: "c:foo",
561
561
unit: None,
562
562
value: Counter(
563
563
42.0,
@@ -570,12 +570,12 @@ mod tests {
570
570
571
571
#[ test]
572
572
fn test_parse_distribution ( ) {
573
- let s = "transactions/ foo:17.5|d" ;
573
+ let s = "foo:17.5|d" ;
574
574
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
575
575
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
576
576
insta:: assert_debug_snapshot!( metric, @r###"
577
577
Metric {
578
- name: "d:transactions/ foo",
578
+ name: "d:foo",
579
579
unit: None,
580
580
value: Distribution(
581
581
17.5,
@@ -588,20 +588,20 @@ mod tests {
588
588
589
589
#[ test]
590
590
fn test_parse_histogram ( ) {
591
- let s = "transactions/ foo:17.5|h" ; // common alias for distribution
591
+ let s = "foo:17.5|h" ; // common alias for distribution
592
592
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
593
593
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
594
594
assert_eq ! ( metric. value, MetricValue :: Distribution ( 17.5 ) ) ;
595
595
}
596
596
597
597
#[ test]
598
598
fn test_parse_set ( ) {
599
- let s = "transactions/ foo:e2546e4c-ecd0-43ad-ae27-87960e57a658|s" ;
599
+ let s = "foo:e2546e4c-ecd0-43ad-ae27-87960e57a658|s" ;
600
600
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
601
601
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
602
602
insta:: assert_debug_snapshot!( metric, @r###"
603
603
Metric {
604
- name: "s:transactions/ foo",
604
+ name: "s:foo",
605
605
unit: None,
606
606
value: Set(
607
607
4267882815,
@@ -614,12 +614,12 @@ mod tests {
614
614
615
615
#[ test]
616
616
fn test_parse_gauge ( ) {
617
- let s = "transactions/ foo:42|g" ;
617
+ let s = "foo:42|g" ;
618
618
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
619
619
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
620
620
insta:: assert_debug_snapshot!( metric, @r###"
621
621
Metric {
622
- name: "g:transactions/ foo",
622
+ name: "g:foo",
623
623
unit: None,
624
624
value: Gauge(
625
625
42.0,
@@ -632,23 +632,23 @@ mod tests {
632
632
633
633
#[ test]
634
634
fn test_parse_unit ( ) {
635
- let s = "transactions/ foo@second:17.5|d" ;
635
+ let s = "foo@second:17.5|d" ;
636
636
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
637
637
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
638
638
assert_eq ! ( metric. unit, MetricUnit :: Duration ( DurationUnit :: Second ) ) ;
639
639
}
640
640
641
641
#[ test]
642
642
fn test_parse_unit_regression ( ) {
643
- let s = "transactions/ foo@s:17.5|d" ;
643
+ let s = "foo@s:17.5|d" ;
644
644
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
645
645
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
646
646
assert_eq ! ( metric. unit, MetricUnit :: Duration ( DurationUnit :: Second ) ) ;
647
647
}
648
648
649
649
#[ test]
650
650
fn test_parse_tags ( ) {
651
- let s = "transactions/ foo:17.5|d|#foo,bar:baz" ;
651
+ let s = "foo:17.5|d|#foo,bar:baz" ;
652
652
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
653
653
let metric = Metric :: parse ( s. as_bytes ( ) , timestamp) . unwrap ( ) ;
654
654
insta:: assert_debug_snapshot!( metric. tags, @r###"
@@ -745,7 +745,7 @@ mod tests {
745
745
746
746
#[ test]
747
747
fn test_parse_all ( ) {
748
- let s = "transactions/ foo:42|c\n bar:17|c" ;
748
+ let s = "foo:42|c\n bar:17|c" ;
749
749
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
750
750
751
751
let metrics: Vec < Metric > = Metric :: parse_all ( s. as_bytes ( ) , timestamp)
@@ -757,7 +757,7 @@ mod tests {
757
757
758
758
#[ test]
759
759
fn test_parse_all_crlf ( ) {
760
- let s = "transactions/ foo:42|c\r \n bar:17|c" ;
760
+ let s = "foo:42|c\r \n bar:17|c" ;
761
761
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
762
762
763
763
let metrics: Vec < Metric > = Metric :: parse_all ( s. as_bytes ( ) , timestamp)
@@ -769,7 +769,7 @@ mod tests {
769
769
770
770
#[ test]
771
771
fn test_parse_all_empty_lines ( ) {
772
- let s = "transactions/ foo:42|c\n \n \n bar:17|c" ;
772
+ let s = "foo:42|c\n \n \n bar:17|c" ;
773
773
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
774
774
775
775
let metric_count = Metric :: parse_all ( s. as_bytes ( ) , timestamp) . count ( ) ;
@@ -778,7 +778,7 @@ mod tests {
778
778
779
779
#[ test]
780
780
fn test_parse_all_trailing ( ) {
781
- let s = "transactions/ foo:42|c\n bar:17|c\n " ;
781
+ let s = "foo:42|c\n bar:17|c\n " ;
782
782
let timestamp = UnixTimestamp :: from_secs ( 4711 ) ;
783
783
784
784
let metric_count = Metric :: parse_all ( s. as_bytes ( ) , timestamp) . count ( ) ;
0 commit comments