@@ -2,12 +2,14 @@ use std::result;
2
2
use std:: sync:: PoisonError ;
3
3
use thiserror:: Error ;
4
4
5
- use crate :: ExportError ;
6
-
7
5
/// A specialized `Result` type for metric operations.
6
+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
8
7
pub 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 > ;
9
10
10
11
/// Errors returned by the metrics API.
12
+ #[ cfg( feature = "spec_unstable_metrics_views" ) ]
11
13
#[ derive( Error , Debug ) ]
12
14
#[ non_exhaustive]
13
15
pub enum MetricError {
@@ -17,20 +19,27 @@ pub enum MetricError {
17
19
/// Invalid configuration
18
20
#[ error( "Config error {0}" ) ]
19
21
Config ( String ) ,
20
- /// Fail to export metrics
21
- #[ error( "Metrics exporter {0} failed with {name}" , name = . 0 . exporter_name( ) ) ]
22
- ExportErr ( Box < dyn ExportError > ) ,
23
22
/// Invalid instrument configuration such invalid instrument name, invalid instrument description, invalid instrument unit, etc.
24
23
/// See [spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#general-characteristics)
25
24
/// for full list of requirements.
26
25
#[ error( "Invalid instrument configuration: {0}" ) ]
27
26
InvalidInstrumentConfiguration ( & ' static str ) ,
28
27
}
29
28
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 ) ,
34
43
}
35
44
36
45
impl < T > From < PoisonError < T > > for MetricError {
0 commit comments