-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global error handler cleanup - Metrics SDK #2185
Changes from 11 commits
704b848
b8cb6af
a0b6eee
acf97fa
7b48f14
ac61b79
a42d516
dbaa7f5
73fca4d
ee5c5f5
3aa97cf
de54afe
e62de04
bda9faa
4a34922
0087c24
115e73f
56682a4
7e48cbf
d81b374
4b09c92
949930e
6dcc9eb
4b42fe8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
}; | ||
|
||
use opentelemetry::{ | ||
global, | ||
metrics::{MetricsError, Result}, | ||
otel_error, | ||
}; | ||
|
||
use super::{ | ||
|
@@ -84,9 +84,7 @@ | |
if inner.sdk_producer.is_none() { | ||
inner.sdk_producer = Some(pipeline); | ||
} else { | ||
global::handle_error(MetricsError::Config( | ||
"duplicate reader registration, did not register manual reader".into(), | ||
)) | ||
otel_error!(name: "ManualReader.RegisterPipeline.DuplicateRegistration"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. info/debug only. Even if a user gets this message, they won't know what to do. Its helpful to us only. |
||
} | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ | |
use std::{borrow::Cow, sync::Arc}; | ||
|
||
use opentelemetry::{ | ||
global, | ||
metrics::{ | ||
noop::{NoopAsyncInstrument, NoopSyncInstrument}, | ||
AsyncInstrumentBuilder, Counter, Gauge, Histogram, HistogramBuilder, InstrumentBuilder, | ||
InstrumentProvider, MetricsError, ObservableCounter, ObservableGauge, | ||
ObservableUpDownCounter, Result, UpDownCounter, | ||
}, | ||
otel_error, | ||
}; | ||
|
||
use crate::instrumentation::Scope; | ||
|
@@ -74,7 +74,7 @@ | |
{ | ||
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: "SdkMeter.CreateCounter.ValidationError", error = format!("{}", err)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree Error is the right severity for this, but this is still not so user-friendly. Name: InstrumentCreationFailed |
||
return Ok(Counter::new(Arc::new(NoopSyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -90,7 +90,7 @@ | |
{ | ||
Ok(counter) => Ok(counter), | ||
Err(err) => { | ||
global::handle_error(err); | ||
otel_error!(name: "SdkMeter.CreateCounter.Error", error = format!("{}", err)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as https://github.com/open-telemetry/opentelemetry-rust/pull/2185/files#r1796240076 |
||
Ok(Counter::new(Arc::new(NoopSyncInstrument::new()))) | ||
} | ||
} | ||
|
@@ -106,7 +106,7 @@ | |
{ | ||
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: "SdkMeter.CreateObservableCounter.ValidationError", error = format!("{}", err)); | ||
return Ok(ObservableCounter::new(Arc::new(NoopAsyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -119,6 +119,7 @@ | |
)?; | ||
|
||
if ms.is_empty() { | ||
otel_error!(name: "SdkMeter.CreateObservableCounter.Error", error = format!("{}", MetricsError::Other("no measures found".into()))); | ||
return Ok(ObservableCounter::new(Arc::new(NoopAsyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -143,7 +144,7 @@ | |
{ | ||
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: "SdkMeter.CreateObservableUpDownCounter.ValidationError", error = format!("{}", err)); | ||
return Ok(ObservableUpDownCounter::new(Arc::new( | ||
NoopAsyncInstrument::new(), | ||
))); | ||
|
@@ -158,6 +159,7 @@ | |
)?; | ||
|
||
if ms.is_empty() { | ||
otel_error!(name: "SdkMeter.CreateObservableUpDownCounter.Error", error = format!("{}",MetricsError::Other("no measures found".into()))); | ||
return Ok(ObservableUpDownCounter::new(Arc::new( | ||
NoopAsyncInstrument::new(), | ||
))); | ||
|
@@ -184,7 +186,7 @@ | |
{ | ||
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: "SdkMeter.CreateObservableGauge.ValidationError", error = format!("{}", err)); | ||
return Ok(ObservableGauge::new(Arc::new(NoopAsyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -197,6 +199,7 @@ | |
)?; | ||
|
||
if ms.is_empty() { | ||
otel_error!(name: "SdkMeter.CreateObservableGauge.Error",error = format!("{}", MetricsError::Other("no measures found".into()))); | ||
return Ok(ObservableGauge::new(Arc::new(NoopAsyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -221,7 +224,7 @@ | |
{ | ||
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: "SdkMeter.CreateUpDownCounter.ValidationError", error = format!("{}",err)); | ||
return Ok(UpDownCounter::new(Arc::new(NoopSyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -237,7 +240,7 @@ | |
{ | ||
Ok(updown_counter) => Ok(updown_counter), | ||
Err(err) => { | ||
global::handle_error(err); | ||
otel_error!(name: "SdkMeter.CreateUpDownCounter.Error", error = format!("{}", err)); | ||
Ok(UpDownCounter::new(Arc::new(NoopSyncInstrument::new()))) | ||
} | ||
} | ||
|
@@ -253,7 +256,7 @@ | |
{ | ||
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: "SdkMeter.CreateGauge.ValidationError", error = format!("{}", err)); | ||
return Ok(Gauge::new(Arc::new(NoopSyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -269,7 +272,7 @@ | |
{ | ||
Ok(gauge) => Ok(gauge), | ||
Err(err) => { | ||
global::handle_error(err); | ||
otel_error!(name: "SdkMeter.CreateGauge.Error", error = format!("{}",err)); | ||
Ok(Gauge::new(Arc::new(NoopSyncInstrument::new()))) | ||
} | ||
} | ||
|
@@ -285,7 +288,7 @@ | |
{ | ||
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: "SdkMeter.CreateHistogram.ValidationError", error = format!("{}", err)); | ||
return Ok(Histogram::new(Arc::new(NoopSyncInstrument::new()))); | ||
} | ||
|
||
|
@@ -301,7 +304,7 @@ | |
{ | ||
Ok(histogram) => Ok(histogram), | ||
Err(err) => { | ||
global::handle_error(err); | ||
otel_error!(name: "SdkMeter.CreateHistogram.Error", error = format!("{}",err)); | ||
Ok(Histogram::new(Arc::new(NoopSyncInstrument::new()))) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,8 @@ | |
}; | ||
|
||
use opentelemetry::{ | ||
global, | ||
metrics::{MetricsError, Result}, | ||
KeyValue, | ||
otel_warn, KeyValue, | ||
}; | ||
|
||
use crate::{ | ||
|
@@ -414,15 +413,18 @@ | |
if existing == id { | ||
return; | ||
} | ||
|
||
global::handle_error(MetricsError::Other(format!( | ||
"duplicate metric stream definitions, names: ({} and {}), descriptions: ({} and {}), kinds: ({:?} and {:?}), units: ({:?} and {:?}), and numbers: ({} and {})", | ||
existing.name, id.name, | ||
existing.description, id.description, | ||
existing.kind, id.kind, | ||
existing.unit, id.unit, | ||
existing.number, id.number, | ||
))) | ||
otel_warn!(name: "Instrument.DuplicateMetricStreamDefinitions", | ||
name = format!("{}",id.name), | ||
description = format!("{}", id.description), | ||
kind = format!("{:?}", id.kind), | ||
unit = format!("{}",id.unit), | ||
number = format!("{}", id.number), | ||
existing_name = format!("{}", existing.name), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can skip logging this set of attributes twice. The event name says that we have a duplicate stream so it should already be understood that we have two identical sets of attributes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not very sure of the logic here. Can you check once. As we return at line 414 if they are same. |
||
existing_desc = format!("{}", existing.description), | ||
existing_kind = format!("{:?}", existing.kind), | ||
existing_unit = format!("{}", existing.unit), | ||
existing_number = format!("{}", existing.number), | ||
); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the inner workings enough to give a strong opinion - but unless this is a auto recoverable error, this can flood the error log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As what I can understand this part of code, this error occurs with restrictive
max_size
configuration, while the application is recording measurements with values that are far apart than what allowed bymax_size
. And error would be logged whenever the faulty measurement is recorded. If these faulty measurements are not frequent, the error log won't be flooded, else it can. Again, either some kind of throttling or simply flag to log only once need to be added. Let me know what you suggest, else I can keep TODO to revisit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we are 100% sure this cannot cause flooding of logs, lets remove the log from here, and leave a TODO to add logging once we understand more.