Skip to content

Enable crashtracking without profiler#3826

Merged
TonyCTHsu merged 17 commits into
masterfrom
tonycthsu/crashtracking
Aug 15, 2024
Merged

Enable crashtracking without profiler#3826
TonyCTHsu merged 17 commits into
masterfrom
tonycthsu/crashtracking

Conversation

@TonyCTHsu

@TonyCTHsu TonyCTHsu commented Aug 6, 2024

Copy link
Copy Markdown
Collaborator

What does this PR do?

This PR extracts crash tracking capabilities from profiler. This means crash tracking could be enabled without profiler.

@github-actions github-actions Bot added core Involves Datadog core libraries profiling Involves Datadog profiling labels Aug 6, 2024
@pr-commenter

pr-commenter Bot commented Aug 6, 2024

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2024-08-15 10:38:12

Comparing candidate commit 6f3c5fe in PR branch tonycthsu/crashtracking with baseline commit d2498fb in branch master.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 19 metrics, 2 unstable metrics.

scenario:profiler - Allocations ()

  • 🟥 throughput [-483315.522op/s; -476309.493op/s] or [-11.829%; -11.657%]

scenario:profiler - Allocations (profiling disabled)

  • 🟥 throughput [-734428.822op/s; -728066.018op/s] or [-12.525%; -12.416%]

scenario:profiler - Allocations (profiling enabled)

  • 🟥 throughput [-707964.939op/s; -641404.889op/s] or [-12.299%; -11.143%]

scenario:profiler - sample timeline=false

  • 🟥 throughput [-0.767op/s; -0.732op/s] or [-10.601%; -10.117%]

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a few quick notes!

Comment thread lib/datadog/core/crashtracking/agent_base_url.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
@codecov-commenter

codecov-commenter commented Aug 7, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.16495% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.84%. Comparing base (d2498fb) to head (85bd6b8).
⚠️ Report is 3116 commits behind head on master.

Files with missing lines Patch % Lines
spec/datadog/core/crashtracking/component_spec.rb 95.55% 8 Missing ⚠️
spec/support/crashtracking_helpers.rb 77.77% 2 Missing ⚠️
lib/datadog/core/crashtracking/component.rb 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3826      +/-   ##
==========================================
+ Coverage   97.83%   97.84%   +0.01%     
==========================================
  Files        1264     1269       +5     
  Lines       75725    75869     +144     
  Branches     3729     3736       +7     
==========================================
+ Hits        74084    74233     +149     
+ Misses       1641     1636       -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread spec/datadog/core/utils/at_fork_monkey_patch_spec.rb Outdated
Comment thread spec/datadog/core/crashtracking/tag_builder_spec.rb Outdated
@TonyCTHsu
TonyCTHsu force-pushed the tonycthsu/crashtracking branch 3 times, most recently from c7defa4 to c59c4f3 Compare August 12, 2024 15:20
@TonyCTHsu
TonyCTHsu marked this pull request as ready for review August 13, 2024 11:32
@TonyCTHsu
TonyCTHsu requested review from a team as code owners August 13, 2024 11:32
@TonyCTHsu TonyCTHsu self-assigned this Aug 13, 2024

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I ran out of time for now, here's 1/3 of a review, I'll come back for the other files soon :)

Comment thread .gitlab-ci.yml Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/core/crashtracking/tag_builder.rb Outdated
Comment thread lib/datadog/profiling/component.rb Outdated
@TonyCTHsu
TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 3ada1aa to 6cb7c4c Compare August 14, 2024 09:21
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
@TonyCTHsu
TonyCTHsu enabled auto-merge August 14, 2024 10:42

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I got through the whole set of changes now, here's a few notes :)

Comment thread spec/datadog/core/crashtracking/tag_builder_spec.rb Outdated
Comment thread sig/datadog/core/configuration/settings.rbs
Comment thread sig/datadog/core/crashtracking/agent_base_url.rbs Outdated
Comment thread sig/datadog/core/crashtracking/component.rbs Outdated
Comment thread lib/datadog/core/configuration/components.rb
Comment thread spec/datadog/core/crashtracking/component_spec.rb
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
Comment thread spec/datadog/core/crashtracking/component_spec.rb
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
@TonyCTHsu
TonyCTHsu disabled auto-merge August 14, 2024 15:13

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 LGTM

Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
Comment thread spec/support/crashtracking_helpers.rb
Comment thread lib/datadog/core/crashtracking/component.rb Outdated
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
Comment thread spec/datadog/core/crashtracking/component_spec.rb Outdated
end
end

def build_crashtracker(options = {})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation


let(:agent_base_url) { "http://#{hostname}:#{port}" }

[:fiddle, :signal].each do |trigger|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Quality Violation

Suggested change
[:fiddle, :signal].each do |trigger|
%i[fiddle signal].each do |trigger|
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.

View in Datadog  Leave us feedback  Documentation

@TonyCTHsu
TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 0d915c6 to 11ee87c Compare August 15, 2024 09:53
@TonyCTHsu
TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 11ee87c to 6f3c5fe Compare August 15, 2024 10:00
Comment on lines +111 to +115
datadog_gem_path = versioned_path.join("gems/datadog-#{ENV.fetch('RUBY_PACKAGE_VERSION')}")
libdatadog_so_file = "libdatadog_api.#{RUBY_VERSION[/\d+.\d+/]}_#{RUBY_PLATFORM}.so"
unless File.exist?("#{datadog_gem_path}/lib/#{libdatadog_so_file}")
raise "Missing #{libdatadog_so_file} in #{datadog_gem_path}."
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can also get this check by setting the DD_FAIL_INSTALL_IF_MISSING_EXTENSION env variable to "true" when calling gem install :)

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍 LGTM

'version' => settings.version,
'git.repository_url' => Environment::Git.git_repository_url,
'git.commit.sha' => Environment::Git.git_commit_sha,
'is_crash' => true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice catch! I was talking with @sanchda about this yesterday and he mentioned libdatadog wasn't adding these automatically.

In Python we also add severity:crash (see DataDog/dd-trace-py#10199 ). I was planning on doing a PR to add this one as well, but in case you want to go ahead ;)

@TonyCTHsu
TonyCTHsu merged commit 1402a32 into master Aug 15, 2024
@TonyCTHsu
TonyCTHsu deleted the tonycthsu/crashtracking branch August 15, 2024 10:46
@github-actions github-actions Bot added this to the 2.3.0 milestone Aug 15, 2024
@TonyCTHsu TonyCTHsu mentioned this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries profiling Involves Datadog profiling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants