-
-
Notifications
You must be signed in to change notification settings - Fork 166
feat(logs): add macro-based API #827
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
@codecov-ai-reviewer review |
On it! We are reviewing the PR and will provide feedback shortly. |
PR DescriptionThis pull request introduces a macro-based API for capturing structured logs within the Sentry Rust SDK. The primary goal is to provide a convenient and expressive way for developers to record log messages with associated attributes, enabling richer context and improved debugging capabilities within the Sentry platform. Click to see moreKey Technical ChangesThe key technical changes include: 1) Creation of a new Architecture DecisionsThe architectural decisions involve using a macro-based API to provide a user-friendly logging interface. The macros leverage the Dependencies and InteractionsThis pull request depends on the Risk ConsiderationsPotential risks include: 1) The Notable Implementation DetailsThe |
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.
I only reviewed the API, not the macro implementation. I left some comments – I highly recommend you follow my suggestions, but I am also okay with merging this PR without changes as it is guarded by an unstable feature flag
Co-authored-by: Daniel Szoke <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #827 +/- ##
=======================================
Coverage 72.61% 72.61%
=======================================
Files 63 63
Lines 7598 7598
=======================================
Hits 5517 5517
Misses 2081 2081 🚀 New features to boost your workflow:
|
Adds logging macros.
As described in the doc strings, there are technically 4 variants:
format!
tracing
, but we only support the values that can be converted to aserde_json::Value
.Full example:
Attributes containing a
.
will be nested in the UI.The biggest difference with this and the
tracing
API is that we don't currently support an arbitrary struct as attribute. The way it works there is that it will work with any type implementingDisplay
, calling it to get a string representation of the value, or with the special syntax?
it will call theDebug
impl.Initially I split this into various internal macros but then they would be exported too, so I've refactored it to only export the needed APIs. This leads to some repetition in the various branches.
The spec says the logging API should be available under a
logger namespace
.However it doesn't look there's a way to re-export the macros only under a specific
mod
, it seems that withmacro_export
they will always be exported at the crate level too (e.g.sentry::error!
).So for now I'm just exporting them at top level.