Skip to content

chore(sdk): Log errors from EventLinkedChunk#6235

Open
Hywan wants to merge 1 commit intomatrix-org:mainfrom
Hywan:feat-sdk-event-cache-log-error-to-sentry
Open

chore(sdk): Log errors from EventLinkedChunk#6235
Hywan wants to merge 1 commit intomatrix-org:mainfrom
Hywan:feat-sdk-event-cache-log-error-to-sentry

Conversation

@Hywan
Copy link
Member

@Hywan Hywan commented Mar 3, 2026

This patch logs errors from EventLinkedChunk and send them to Sentry (if Sentry is enabled).

The trick is to use #[instrument(err)] for logging errors. Quoting the documentation:

If the function returns a Result<T, E> and E implements
std::fmt::Display, adding err or err(Display) will emit error
events when the function returns Err:

#[instrument(err)]
fn my_function(arg: usize) -> Result<(), std::io::Error> {
    Ok(())
}

The level of the error value event defaults to ERROR.

It sounds exactly what we need.


  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was made with the help of AI.

This patch logs errors from `EventLinkedChunk` and send them to Sentry
(if Sentry is enabled).

The trick is to use [`#[instrument(err)]`][0] for logging errors.
Quoting the documentation:

> If the function returns a `Result<T, E>` and `E` implements
> `std::fmt::Display`, adding `err` or `err(Display)` will emit error
> events when the function returns `Err`:
>
> ```rust
> #[instrument(err)]
> fn my_function(arg: usize) -> Result<(), std::io::Error> {
>     Ok(())
> }
> ```
>
> The level of the error value event defaults to `ERROR`.

It sounds exactly what we need.

[0]: https://docs.rs/tracing-attributes/0.1.31/tracing_attributes/attr.instrument.html#examples-2
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.96%. Comparing base (617c646) to head (619ded3).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6235      +/-   ##
==========================================
+ Coverage   89.94%   89.96%   +0.01%     
==========================================
  Files         370      370              
  Lines      101930   101917      -13     
  Branches   101930   101917      -13     
==========================================
  Hits        91685    91685              
+ Misses       6693     6687       -6     
+ Partials     3552     3545       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing Hywan:feat-sdk-event-cache-log-error-to-sentry (619ded3) with main (029148e)

Open in CodSpeed

@Hywan Hywan marked this pull request as ready for review March 3, 2026 15:29
@Hywan Hywan requested a review from a team as a code owner March 3, 2026 15:29
@Hywan Hywan requested review from stefanceriu and removed request for a team March 3, 2026 15:29
Copy link
Member

@stefanceriu stefanceriu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a cool trick, did you check that it actually works? 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants