chore: Refactor SentryAttributes into a separate class#4936
chore: Refactor SentryAttributes into a separate class#4936jamescrosswell wants to merge 5 commits intomainfrom
Conversation
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4936 +/- ##
==========================================
- Coverage 73.90% 73.86% -0.04%
==========================================
Files 496 497 +1
Lines 17951 17938 -13
Branches 3516 3511 -5
==========================================
- Hits 13266 13250 -16
- Misses 3824 3831 +7
+ Partials 861 857 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| return false; | ||
| } | ||
| internal bool TryGetAttribute(string key, [NotNullWhen(true)] out string? value) => | ||
| _attributes.TryGetAttribute(key, out value); |
There was a problem hiding this comment.
Dropped Type metadata check in SentryLog.TryGetAttribute
Low Severity
The internal SentryLog.TryGetAttribute(string, out string?) previously checked attribute.Type == "string" (metadata-based), but the new delegation to SentryAttributes.TryGetAttribute<string> only checks attribute.Value is string (runtime type). This means attributes stored via the public SetAttribute(string, object) with a string value (which sets Type = null) will now be returned by the string overload, where before they would not. While likely an improvement, it's a silent semantic change that could affect callers relying on the stricter Type-based filtering.
Additional Locations (1)
There was a problem hiding this comment.
@Flash0ver what do you think about this? Do you want to restore the previous code/behaviour or OK with this?


Before closing #4912 I figured we could extract some of the refactorings that might be useful in other PRs dealing with Attributes. Basically there's some functionality that is only accessible in the
SentryMetricsclass at the moment, but which will be needed by any other classes that also have Attributes.#skip-changelog