diff --git a/opentelemetry-sdk/src/metrics/meter.rs b/opentelemetry-sdk/src/metrics/meter.rs index 8cab6e1b68..17ce802e91 100644 --- a/opentelemetry-sdk/src/metrics/meter.rs +++ b/opentelemetry-sdk/src/metrics/meter.rs @@ -179,19 +179,30 @@ impl SdkMeter { { let validation_result = validate_instrument_config(builder.name.as_ref(), &builder.unit); if let Err(err) = validation_result { - global::handle_error(err); + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable updown counter will not be invoked.", + reason = format!("{}", err)); return ObservableUpDownCounter::new(); } match resolver.measures( InstrumentKind::ObservableUpDownCounter, - builder.name, + builder.name.clone(), builder.description, builder.unit, None, ) { Ok(ms) => { if ms.is_empty() { + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable updown counter will not be invoked. Check View Configuration." + ); return ObservableUpDownCounter::new(); } @@ -206,7 +217,12 @@ impl SdkMeter { ObservableUpDownCounter::new() } Err(err) => { - global::handle_error(err); + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable updown counter will not be invoked.", + reason = format!("{}", err)); ObservableUpDownCounter::new() } } @@ -222,19 +238,30 @@ impl SdkMeter { { let validation_result = validate_instrument_config(builder.name.as_ref(), &builder.unit); if let Err(err) = validation_result { - global::handle_error(err); + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable gauge will not be invoked.", + reason = format!("{}", err)); return ObservableGauge::new(); } match resolver.measures( InstrumentKind::ObservableGauge, - builder.name, + builder.name.clone(), builder.description, builder.unit, None, ) { Ok(ms) => { if ms.is_empty() { + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable gauge will not be invoked. Check View Configuration." + ); return ObservableGauge::new(); } @@ -249,7 +276,12 @@ impl SdkMeter { ObservableGauge::new() } Err(err) => { - global::handle_error(err); + otel_error!( + name: "InstrumentCreationFailed", + meter_name = self.scope.name.as_ref(), + instrument_name = builder.name.as_ref(), + message = "Callbacks for this observable gauge will not be invoked.", + reason = format!("{}", err)); ObservableGauge::new() } }