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. |
src/Sentry.Compiler.Extensions/Sentry.Compiler.Extensions.csproj
Outdated
Show resolved
Hide resolved
src/Sentry.Compiler.Extensions/Analyzers/TraceConnectedMetricsAnalyzer.cs
Show resolved
Hide resolved
src/Sentry.Compiler.Extensions/Analyzers/TraceConnectedMetricsAnalyzer.cs
Show resolved
Hide resolved
src/Sentry.Compiler.Extensions/Analyzers/TraceConnectedMetricsAnalyzer.cs
Show resolved
Hide resolved
jamescrosswell
left a comment
There was a problem hiding this comment.
LGTM - nice work @Flash0ver !
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