@@ -2,12 +2,14 @@ use std::result;
22use std:: sync:: PoisonError ;
33use thiserror:: Error ;
44
5- use crate :: ExportError ;
6-
75/// A specialized `Result` type for metric operations.
6+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
87pub type MetricResult < T > = result:: Result < T , MetricError > ;
8+ #[ cfg( not( feature = "spec_unstable_metrics_views" ) ) ]
9+ pub ( crate ) type MetricResult < T > = result:: Result < T , MetricError > ;
910
1011/// Errors returned by the metrics API.
12+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
1113#[ derive( Error , Debug ) ]
1214#[ non_exhaustive]
1315pub enum MetricError {
@@ -17,20 +19,27 @@ pub enum MetricError {
1719 /// Invalid configuration
1820 #[ error( "Config error {0}" ) ]
1921 Config ( String ) ,
20- /// Fail to export metrics
21- #[ error( "Metrics exporter {0} failed with {name}" , name = . 0 . exporter_name( ) ) ]
22- ExportErr ( Box < dyn ExportError > ) ,
2322 /// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc.
2423 /// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics)
2524 /// for full list of requirements.
2625 #[ error( "Invalid instrument configuration: {0}" ) ]
2726 InvalidInstrumentConfiguration ( & ' static str ) ,
2827}
2928
30- impl < T : ExportError > From < T > for MetricError {
31- fn from ( err : T ) -> Self {
32- MetricError :: ExportErr ( Box :: new ( err) )
33- }
29+ #[ cfg( not( feature = "spec_unstable_metrics_views" ) ) ]
30+ #[ derive( Error , Debug ) ]
31+ pub ( crate ) enum MetricError {
32+ /// Other errors not covered by specific cases.
33+ #[ error( "Metrics error: {0}" ) ]
34+ Other ( String ) ,
35+ /// Invalid configuration
36+ #[ error( "Config error {0}" ) ]
37+ Config ( String ) ,
38+ /// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc.
39+ /// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics)
40+ /// for full list of requirements.
41+ #[ error( "Invalid instrument configuration: {0}" ) ]
42+ InvalidInstrumentConfiguration ( & ' static str ) ,
3443}
3544
3645impl < T > From < PoisonError < T > > for MetricError {
0 commit comments