Skip to content
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

GEN-68: Capture source errors when converting Error to Report #4678

Conversation

TimDiekmann
Copy link
Member

🌟 What is the purpose of this PR?

It's desired that source errors of Error are printed as part of a Report as well.

🔗 Related links

🔍 What does this change?

  • Adds a hidden __source method to Context to close the gap between Context and Error. This allows using Error::source without specialization.
  • Add contexts for sources returned from Error::source to the Report when creating it

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

@TimDiekmann TimDiekmann requested a review from indietyp July 5, 2024 15:50
@TimDiekmann TimDiekmann self-assigned this Jul 5, 2024
@github-actions github-actions bot added area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs > error-stack Affects the `error-stack` crate (library) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests labels Jul 5, 2024
Copy link

codecov bot commented Jul 5, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 28 lines in your changes missing coverage. Please review.

Project coverage is 20.19%. Comparing base (34122de) to head (eb539f3).
Report is 732 commits behind head on main.

Files with missing lines Patch % Lines
libs/error-stack/src/report.rs 13.33% 13 Missing ⚠️
libs/error-stack/src/context.rs 20.00% 12 Missing ⚠️
libs/error-stack/src/result.rs 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4678      +/-   ##
==========================================
- Coverage   20.20%   20.19%   -0.02%     
==========================================
  Files         457      457              
  Lines       15718    15747      +29     
  Branches     2378     2378              
==========================================
+ Hits         3176     3180       +4     
- Misses      12501    12526      +25     
  Partials       41       41              
Flag Coverage Δ
error-stack 75.62% <22.22%> (-0.67%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link
Contributor

github-actions bot commented Jul 5, 2024

Benchmark results

@rust/graph-benches – Integrations

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property depths: DT=0, PT=0, ET=0, E=0 $$35.8 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}-0.506 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=255, PT=255, ET=255, E=255 $$2.85 \mathrm{s} \pm 8.08 \mathrm{ms}\left({\color{gray}0.397 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=2, ET=2, E=2 $$973 \mathrm{ms} \pm 3.48 \mathrm{ms}\left({\color{gray}-2.257 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=2, E=2 $$356 \mathrm{ms} \pm 1.52 \mathrm{ms}\left({\color{gray}-2.420 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=0, PT=0, ET=0, E=2 $$39.6 \mathrm{ms} \pm 197 \mathrm{μs}\left({\color{gray}-1.583 \mathrm{\%}}\right) $$ Flame Graph
entity_by_property depths: DT=2, PT=2, ET=2, E=2 $$980 \mathrm{ms} \pm 4.28 \mathrm{ms}\left({\color{gray}0.432 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=0 $$37.6 \mathrm{ms} \pm 297 \mathrm{μs}\left({\color{gray}-0.123 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=255, PT=255, ET=255, E=255 $$1.99 \mathrm{s} \pm 10.9 \mathrm{ms}\left({\color{gray}1.24 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=2, ET=2, E=2 $$1.03 \mathrm{s} \pm 4.95 \mathrm{ms}\left({\color{gray}0.725 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=2, E=2 $$394 \mathrm{ms} \pm 1.18 \mathrm{ms}\left({\color{gray}-0.365 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=0, PT=0, ET=0, E=2 $$73.4 \mathrm{ms} \pm 490 \mathrm{μs}\left({\color{gray}-0.988 \mathrm{\%}}\right) $$ Flame Graph
link_by_source_by_property depths: DT=2, PT=2, ET=2, E=2 $$1.02 \mathrm{s} \pm 2.50 \mathrm{ms}\left({\color{gray}1.07 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$1.83 \mathrm{ms} \pm 5.83 \mathrm{μs}\left({\color{gray}0.780 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$12.9 \mathrm{ms} \pm 138 \mathrm{μs}\left({\color{gray}-2.238 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$1.84 \mathrm{ms} \pm 6.79 \mathrm{μs}\left({\color{gray}0.144 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$2.76 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}0.150 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$2.03 \mathrm{ms} \pm 9.86 \mathrm{μs}\left({\color{gray}0.340 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: d4e16033-c281-4cde-aa35-9085bf2e7579 $$1.40 \mathrm{ms} \pm 4.82 \mathrm{μs}\left({\color{gray}-0.338 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$16.3 \mathrm{ms} \pm 180 \mathrm{μs}\left({\color{red}7.26 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$16.5 \mathrm{ms} \pm 194 \mathrm{μs}\left({\color{gray}3.14 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$16.4 \mathrm{ms} \pm 181 \mathrm{μs}\left({\color{gray}0.492 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$16.1 \mathrm{ms} \pm 211 \mathrm{μs}\left({\color{gray}-0.788 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$15.4 \mathrm{ms} \pm 226 \mathrm{μs}\left({\color{lightgreen}-7.054 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$16.4 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{gray}-2.280 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$15.8 \mathrm{ms} \pm 182 \mathrm{μs}\left({\color{gray}-0.669 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$16.1 \mathrm{ms} \pm 190 \mathrm{μs}\left({\color{red}10.3 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$16.1 \mathrm{ms} \pm 159 \mathrm{μs}\left({\color{gray}-2.179 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_zero_depth

Function Value Mean Flame graphs
entity_by_id 25 entities $$2.57 \mathrm{ms} \pm 12.2 \mathrm{μs}\left({\color{lightgreen}-12.409 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$1.86 \mathrm{ms} \pm 7.94 \mathrm{μs}\left({\color{gray}0.246 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$2.01 \mathrm{ms} \pm 8.79 \mathrm{μs}\left({\color{gray}-4.957 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$3.91 \mathrm{ms} \pm 23.5 \mathrm{μs}\left({\color{lightgreen}-6.960 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$1.90 \mathrm{ms} \pm 9.55 \mathrm{μs}\left({\color{gray}0.721 \mathrm{\%}}\right) $$ Flame Graph

scaling_read_entity_complete_one_depth

Function Value Mean Flame graphs
entity_by_id 25 entities $$76.3 \mathrm{ms} \pm 496 \mathrm{μs}\left({\color{gray}0.770 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1 entities $$19.7 \mathrm{ms} \pm 82.7 \mathrm{μs}\left({\color{gray}-1.554 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$30.2 \mathrm{ms} \pm 132 \mathrm{μs}\left({\color{gray}0.008 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 50 entities $$1.55 \mathrm{s} \pm 4.63 \mathrm{ms}\left({\color{red}464 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 5 entities $$24.4 \mathrm{ms} \pm 381 \mathrm{μs}\left({\color{gray}2.15 \mathrm{\%}}\right) $$ Flame Graph

Copy link
Member

@indietyp indietyp left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@TimDiekmann TimDiekmann added this pull request to the merge queue Jul 6, 2024
Merged via the queue into main with commit cd3200d Jul 6, 2024
141 of 142 checks passed
@TimDiekmann TimDiekmann deleted the t/gen-68-track-github-issue-2127-into_report-doesnt-include-error branch July 6, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deps Relates to third-party dependencies (area) area/infra Relates to version control, CI, CD or IaC (area) area/libs > error-stack Affects the `error-stack` crate (library) area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests
Development

Successfully merging this pull request may close these issues.

GEN-68: .into_report() doesn't include error source chains
2 participants