feat(metrics): Trace-connected Metrics (Analyzers)#4840
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Trace-connected Metrics (Analyzers) ([#4840](https://github.com/getsentry/sentry-dotnet/pull/4840))If none of the above apply, you can opt out of this check by adding |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4840 +/- ##
==========================================
+ Coverage 73.71% 73.95% +0.24%
==========================================
Files 497 499 +2
Lines 17966 18017 +51
Branches 3516 3527 +11
==========================================
+ Hits 13244 13325 +81
+ Misses 3858 3829 -29
+ Partials 864 863 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Provides hierarchical constants for metric units supported by Sentry Relay, organized into Duration, Information, and Fraction categories. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…-metrics-analyzers
…-metrics-analyzers
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Breaking Changes 🛠
Features ✨
Dependencies ⬆️Deps
🤖 This preview updates automatically when you update the PR. |
jamescrosswell
left a comment
There was a problem hiding this comment.
LGTM - nice work @Flash0ver !
Add references/metrics.md documenting: - EmitCounter, EmitGauge, EmitDistribution API - Supported numeric types (byte, short, int, long, float, double) - SENTRY1001 Roslyn diagnostic analyzer - SetBeforeSendMetric callback - SentryMetric.TryGetValue<T> - EnableMetrics config option Update SKILL.md to include Metrics in feature recommendations and reference file table. Addresses getsentry/sentry-dotnet#4840 Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: HazAT <363802+HazAT@users.noreply.github.com> Agent-Logs-Url: https://github.com/getsentry/sentry-for-ai/sessions/a7f23faf-52d2-4883-89e9-a8846d16dd40
#80) * Initial plan * fix(dotnet-sdk): add metrics reference with SENTRY1001 analyzer docs Add references/metrics.md documenting: - EmitCounter, EmitGauge, EmitDistribution API - Supported numeric types (byte, short, int, long, float, double) - SENTRY1001 Roslyn diagnostic analyzer - SetBeforeSendMetric callback - SentryMetric.TryGetValue<T> - EnableMetrics config option Update SKILL.md to include Metrics in feature recommendations and reference file table. Addresses getsentry/sentry-dotnet#4840 Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: HazAT <363802+HazAT@users.noreply.github.com> Agent-Logs-Url: https://github.com/getsentry/sentry-for-ai/sessions/a7f23faf-52d2-4883-89e9-a8846d16dd40 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: HazAT <363802+HazAT@users.noreply.github.com>
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [Sentry.Maui](https://sentry.io/) ([source](https://github.com/getsentry/sentry-dotnet)) | nuget | minor | `6.2.0` -> `6.3.0` | --- ### Release Notes <details> <summary>getsentry/sentry-dotnet (Sentry.Maui)</summary> ### [`v6.3.0`](https://github.com/getsentry/sentry-dotnet/blob/HEAD/CHANGELOG.md#630) [Compare Source](getsentry/sentry-dotnet@6.2.0...6.3.0) ##### Features - The *Metrics* APIs are now stable: removed `Experimental` from `SentrySdk`, `SentryOptions` and `IHub` ([#​5023](getsentry/sentry-dotnet#5023)) - Report a new *Diagnostic* (`SENTRY1001`) when a Metrics-API is invoked with an unsupported numeric type ([#​4840](getsentry/sentry-dotnet#4840)) ##### Fixes - Common tags such as `Environment` and `Release` and custom event processors are all now correctly applied to CaptureFeedback events ([#​4942](getsentry/sentry-dotnet#4942)) - Include `Data` set via `ITransactionTracer` in `SentryTransaction` ([#​4148](getsentry/sentry-dotnet#4148)) ##### Dependencies - Bump Cocoa SDK from v9.5.0 to v9.7.0 ([#​4958](getsentry/sentry-dotnet#4958), [#​5015](getsentry/sentry-dotnet#5015)) - Bump CLI from v3.3.0 to v3.3.3 ([#​5002](getsentry/sentry-dotnet#5002)) - Bump Java SDK from v8.34.1 to v8.35.0 ([#​5017](getsentry/sentry-dotnet#5017)) - Bump Native SDK from v0.13.2 to v0.13.3 ([#​5045](getsentry/sentry-dotnet#5045)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!". 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
based on (but to be merged to
mainindividually)feat(metrics): Trace-connected Metrics #4834Summary
My little weekend-project:
Add a Diagnostic-Analyzer to our Compiler-Extensions, that warn users when a metric would not be emitted due to an unsupported numeric value type -or- likewise, a
SentryMetric.TryGetValue<>invocation with an unsupported numeric value type is detected.Changelog Entry
Report a new Diagnostic (
SENTRY1001) when a Metrics-API is invoked with an unsupported numeric typeRemarks
For the numeric type of a Metric, we currently allow 64-bit sized integral (signed) and floating-point numbers.
That means that e.g.
ulong,System.Int128, ordecimalare currently not supported by Sentry.The compile-time constraint of
Sentry.SentryMetric<T>only constrains to non-nullable value types.Alternatively, we could have implemented respectively types overloads for the method groups:
To avoid this explosion of overloads per method group,
and be similar to the implementation of System.Diagnostics.Metrics,
we are not compile-time constraining unsupported types,
but are instead run-time constraining unsupported types (no-op and Debug-Diagnostic-Logging).
To still warn users unfamiliar with the System.Diagnostics.Metrics.Meter-based APIs,
I built an Analyzer over some weekends to guide new users.
Examples