Skip to content

Commit

Permalink
Merge branch 'main' into pipeline-metrics-internal-log
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Oct 25, 2024
2 parents 96c3328 + 4c7bf58 commit 31b738b
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions opentelemetry-sdk/src/metrics/meter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,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 @@ -205,7 +216,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 @@ -221,19 +237,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 @@ -248,7 +275,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

0 comments on commit 31b738b

Please sign in to comment.