Draft
Conversation
Implement trace metrics per the Sentry SDK telemetry spec, enabling SDKs to capture and transmit quantitative performance data (counters, gauges, distributions) associated with traces. The implementation mirrors the existing structured logs architecture: - TraceMetric/TraceMetricType protocol types in sentry-types - TraceMetrics envelope item container with serialization/deserialization - MetricsBatcher with background worker thread (100-item / 5s flush) - Feature-gated behind `metrics` feature flag - Public API: metrics_count(), metrics_gauge(), metrics_distribution() - before_send_metric callback and enable_metrics client option - Trace context (trace_id, span_id) and user attributes from scope Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Add trace metrics support ([#997](https://github.com/getsentry/sentry-rust/pull/997))If none of the above apply, you can opt out of this check by adding |
Replace the duplicate LogsBatcher and MetricsBatcher with a single generic Batcher<T> that handles both log and metric batching using a function pointer for envelope item conversion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only the configured fraction of metrics is submitted. Sampled metrics are annotated with a `sentry.client_sample_rate` attribute so the server can extrapolate. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A sample rate of 0.0 now disables metrics entirely, removing the need for a separate enable_metrics boolean. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement trace metrics per the Sentry SDK telemetry spec, enabling SDKs to capture and transmit quantitative performance data (counters, gauges, distributions) associated with traces.
The implementation mirrors the existing structured logs architecture:
metricsfeature flagDescription
Issues
Reminders
feat:,fix:,ref:,meta:, etc.)