-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[ENH]: add metrics for span & metric exporters #5223
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
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
Add Metrics for Span & Metric Exporters with Success/Error Segmentation This PR introduces new OpenTelemetry metrics to track the total number of span and metric batches exported, segmented by success and error status. Two wrapper structs ( Key Changes• Added Affected Areas• rust/tracing/src/ This summary was automatically generated by @propel-code-bot |
8161297
to
d8de3e1
Compare
d8de3e1
to
1426081
Compare
Err(err) => { | ||
let error_name = match err { | ||
opentelemetry_sdk::metrics::MetricError::Other(_) => "other", | ||
opentelemetry_sdk::metrics::MetricError::Config(_) => "config", | ||
opentelemetry_sdk::metrics::MetricError::ExportErr(_) => "export_failed", | ||
opentelemetry_sdk::metrics::MetricError::InvalidInstrumentConfiguration(_) => { | ||
"invalid_instrument_configuration" | ||
} | ||
_ => "unknown", | ||
}; | ||
counter.add( | ||
1, | ||
&[ | ||
KeyValue::new("status", "error"), | ||
KeyValue::new("error", error_name.to_string()), | ||
], | ||
); | ||
} |
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.
[PerformanceOptimization]
A couple of small improvements here:
- The braces around
"invalid_instrument_configuration"
are not necessary. error_name
is a&'static str
, which can be converted into anopentelemetry::Value
directly. Calling.to_string()
creates an unnecessary heap allocation. You can passerror_name
toKeyValue::new
directly.
This reverts commit a0c352b.
Description of changes
This adds new metrics for the total # of span & metric batches exported and segments the metrics based on success/error. This will help us be aware of when services drop spans/metrics.
Test plan
How are these changes tested?
I tested locally in Tilt by adding a 8MB test span and observing that the counter for span export errors was incremented.
Migration plan
Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?
Observability plan
What is the plan to instrument and monitor this change?
Documentation Changes
Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?