Skip to content
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 - #39

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions opentelemetry-sdk/src/metrics/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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()
}
}
Expand All @@ -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();
}

Expand All @@ -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()
}
}
Expand Down
Loading