-
Notifications
You must be signed in to change notification settings - Fork 15
ekump/APMSP-1827 add warnings for panics #915
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
10a0fa0 to
4eb0271
Compare
BenchmarksComparisonBenchmark execution time: 2025-03-14 16:04:23 Comparing candidate commit 60433a7 in PR branch Found 6 performance improvements and 0 performance regressions! Performance is the same for 46 metrics, 2 unstable metrics. scenario:credit_card/is_card_number/378282246310005
scenario:credit_card/is_card_number/x371413321323331
scenario:credit_card/is_card_number_no_luhn/x371413321323331
CandidateCandidate benchmark detailsGroup 1
Group 2
Group 3
Group 4
Group 5
Group 6
Group 7
Group 8
Group 9
Group 10
Group 11
Group 12
Group 13
BaselineOmitted due to size. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #915 +/- ##
==========================================
+ Coverage 72.69% 72.78% +0.09%
==========================================
Files 334 334
Lines 50498 50916 +418
==========================================
+ Hits 36709 37061 +352
- Misses 13789 13855 +66
🚀 New features to boost your workflow:
|
4eb0271 to
61a3e81
Compare
c7a8f4c to
6f5ea3a
Compare
8dea310 to
5843d48
Compare
37c1726 to
7548560
Compare
bb5d857 to
60433a7
Compare
Add clippy warnings and allows for panic macros to most crates Add an extension crate for mutex in ddcommon to isolate the unwrap to one location in code to avoid the allow annotations. We aren't going to stop unwrapping mutexes anytime soon. Replace use of lazy_static with OnceLock for ddcommon, ddtelemetry, live-debugger, tools, sidecar
Add clippy warnings and allows for panic macros to most crates Add an extension crate for mutex in ddcommon to isolate the unwrap to one location in code to avoid the allow annotations. We aren't going to stop unwrapping mutexes anytime soon. Replace use of lazy_static with OnceLock for ddcommon, ddtelemetry, live-debugger, tools, sidecar
Add clippy warnings and allows for panic macros to most crates Add an extension crate for mutex in ddcommon to isolate the unwrap to one location in code to avoid the allow annotations. We aren't going to stop unwrapping mutexes anytime soon. Replace use of lazy_static with OnceLock for ddcommon, ddtelemetry, live-debugger, tools, sidecar
What does this PR do?
Enables the following clippy warnings:
All existing calls to
panic!(),unwrap!(),expect!(),todo!(),unimplemented!()remain and a clippy allow annotation has been added.Also,
lazy_statichas been removed as a direct dependency in libdatadog. Clippy doesn't recognize allow annotations inlazy_staticblocks. lazy_static isn't really necessary anymore. We can use std::sync::OnceLock instead. Once we move the MSRV to 1.80 we can use std::sync::LazyLock which is a bit more ergonomic.A helper function has also been added to ddcommon called
lock_or_panic(). The purpose is to not clutter modules with a lot of mutex unlocking with allow annotations right now.Motivation
As the use of libdatadog within the APM SDKs increases we should do what we can to minimize the chance of a panic, and the crashing of customer applications.
What is the point of enabling warnings and then allowing all of them?
To allow for an iterative and decoupled process for code owners to reduce the possibility of their code panicking. In many cases, removing the use of these macros will require non-trivial design changes. We can also add heuristics in a follow-up PR to track allow annotations.
Can I still use these macros?
Yes, if it is necessary. Use the appropriate
allowannotation and include a meaningful comment about why the rule is being suppressed.Can I still use lazy_static?
No. lazy_static has served its purpose, but it's time to move on. Most of what it is used for can be achieved with the standard library or once_cell.
Additional Notes
How to test the change?
No functionality should change, all tests should continue to pass.