-
Notifications
You must be signed in to change notification settings - Fork 375
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
[NO-TICKET] Fix crashtracking sending parent pid/runtime-id when child crashes #4031
[NO-TICKET] Fix crashtracking sending parent pid/runtime-id when child crashes #4031
Conversation
…d crashes **What does this PR do?** This PR fixes a bug in the crashtracking component: because it cached all of the tags from creation, if a process forked, it would use the tags from the parent, which included a (now-incorrect) pid and runtime-id. **Motivation:** This makes sure we have accurate metadata in crashtracking reports. **Additional Notes:** N/A **How to test the change?** I've added test coverage for this change. It can also be observed by using ``` $ DD_CRASHTRACKING_ENABLED=true bundle exec ruby -e 'require "datadog/auto_instrument"; puts "Parent: #{Process.pid} #{Datadog::Core::Environment::Identity.id}"; fork { puts "Child: #{Process.pid} #{Datadog::Core::Environment::Identity.id}"; Process.kill("SEGV", Process.pid) }' ``` and validating that the correct pid/runtime-id from the child is sent in the metadata.
|
||
it 'refreshes the latest settings' do | ||
expect(Datadog).to receive(:configuration).and_return(:latest_settings) | ||
expect(Datadog::Core::Crashtracking::TagBuilder).to receive(:call).with(:latest_settings).and_return([:latest_tags]) |
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.
⚪ Code Quality Violation
expect(Datadog::Core::Crashtracking::TagBuilder).to receive(:call).with(:latest_settings).and_return([:latest_tags]) | |
expect(Datadog::Core::Crashtracking::TagBuilder).to receive(:call).with(:latest_settings).and_return(%i[latest_tags]) |
Consider using the %i syntax instead (...read more)
The rule "Prefer %i
to the literal array syntax" is a guideline that encourages the use of the %i
syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.
Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the %i
syntax can make your code cleaner and easier to read.
To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz]
, use the %i
syntax like %i[foo bar baz]
. It's a good practice to consistently use %i
for arrays of symbols as it enhances code readability and maintainability.
expect(Datadog).to receive(:configuration).and_return(:latest_settings) | ||
expect(Datadog::Core::Crashtracking::TagBuilder).to receive(:call).with(:latest_settings).and_return([:latest_tags]) | ||
expect(described_class).to receive(:_native_start_or_update_on_fork).with( | ||
hash_including(tags_as_array: [:latest_tags]) |
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.
⚪ Code Quality Violation
hash_including(tags_as_array: [:latest_tags]) | |
hash_including(tags_as_array: %i[latest_tags]) |
Consider using the %i syntax instead (...read more)
The rule "Prefer %i
to the literal array syntax" is a guideline that encourages the use of the %i
syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.
Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the %i
syntax can make your code cleaner and easier to read.
To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz]
, use the %i
syntax like %i[foo bar baz]
. It's a good practice to consistently use %i
for arrays of symbols as it enhances code readability and maintainability.
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.
LGTM 💯
Use `allow` instead of `expect` for test setup Co-authored-by: Sergey Fedorov <oni.strech@gmail.com>
BenchmarksBenchmark execution time: 2024-10-25 13:35:08 Comparing candidate commit 06dfc27 in PR branch Found 2 performance improvements and 1 performance regressions! Performance is the same for 21 metrics, 2 unstable metrics. scenario:profiler - sample timeline=false
scenario:tracing - Propagation - Datadog
scenario:tracing - Propagation - Trace Context
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4031 +/- ##
==========================================
- Coverage 97.86% 97.86% -0.01%
==========================================
Files 1321 1321
Lines 79326 79329 +3
Branches 3934 3934
==========================================
+ Hits 77631 77632 +1
- Misses 1695 1697 +2 ☔ View full report in Codecov by Sentry. |
What does this PR do?
This PR fixes a bug in the crashtracking component: because it cached all of the tags from creation, if a process forked, it would use the tags from the parent, which included a (now-incorrect) pid and runtime-id.
Motivation:
This makes sure we have accurate metadata in crashtracking reports.
Change log entry
(Internal change, not relevant for changelog)
Additional Notes:
N/A
How to test the change?
I've added test coverage for this change. It can also be observed by using
and validating that the correct pid/runtime-id from the child is sent in the metadata.