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 - ObservableUpDownCounter, ObservableGauge #2240

Merged
merged 7 commits into from
Oct 25, 2024
Merged
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 @@
{
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));

Check warning on line 187 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L184-L187

Added lines #L184 - L187 were not covered by tests
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!(

Check warning on line 200 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L200

Added line #L200 was not covered by tests
name: "InstrumentCreationFailed",
meter_name = self.scope.name.as_ref(),
instrument_name = builder.name.as_ref(),

Check warning on line 203 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L202-L203

Added lines #L202 - L203 were not covered by tests
message = "Callbacks for this observable updown counter will not be invoked. Check View Configuration."
);
return ObservableUpDownCounter::new();
}

Expand All @@ -206,7 +217,12 @@
ObservableUpDownCounter::new()
}
Err(err) => {
global::handle_error(err);
otel_error!(

Check warning on line 220 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L220

Added line #L220 was not covered by tests
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));

Check warning on line 225 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L222-L225

Added lines #L222 - L225 were not covered by tests
ObservableUpDownCounter::new()
}
}
Expand All @@ -222,19 +238,30 @@
{
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));

Check warning on line 246 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L243-L246

Added lines #L243 - L246 were not covered by tests
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!(

Check warning on line 259 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L259

Added line #L259 was not covered by tests
name: "InstrumentCreationFailed",
meter_name = self.scope.name.as_ref(),
instrument_name = builder.name.as_ref(),

Check warning on line 262 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L261-L262

Added lines #L261 - L262 were not covered by tests
message = "Callbacks for this observable gauge will not be invoked. Check View Configuration."
);
return ObservableGauge::new();
}

Expand All @@ -249,7 +276,12 @@
ObservableGauge::new()
}
Err(err) => {
global::handle_error(err);
otel_error!(

Check warning on line 279 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L279

Added line #L279 was not covered by tests
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));

Check warning on line 284 in opentelemetry-sdk/src/metrics/meter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/metrics/meter.rs#L281-L284

Added lines #L281 - L284 were not covered by tests
ObservableGauge::new()
}
}
Expand Down
Loading