Skip to content

feat: add automatic reporting of handled errors#4604

Merged
dubloom merged 25 commits into
masterfrom
dubloom/feat/handled-errors-reporting
May 16, 2025
Merged

feat: add automatic reporting of handled errors#4604
dubloom merged 25 commits into
masterfrom
dubloom/feat/handled-errors-reporting

Conversation

@dubloom

@dubloom dubloom commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?
The PR adds the automatic reporting of handled errors. Whenever an error is handled, it will be attached (if not re-thrown) as a span event to a span_operation. By adding a specific tag to the span as well, Error Tracking will be able to fingerprint the span event to report the errors in its product.
Brief specification can be found on this link

Motivation:
Error Tracking released Error Tracking Standalone. This allows a user to get all the errors without using tracing. Error Tracking wants a user to be able to get handled and unhandled errors on Error Tracking without any manual instrumentation

Change log entry
Yes. ErrorTracking: Add automatic reporting of handled errors.

How to test the change?

  • The feature is extensively tested in spec/error_tracking/component_spec.rb
  • As the feature is using two global tracepoints, two benchmarks were added:
    • One to test the overhead of the feature alone
    • One to test the overhead of the feature in context.

@github-actions

github-actions Bot commented Apr 24, 2025

Copy link
Copy Markdown

Thank you for updating Change log entry section 👏

Visited at: 2025-05-14 18:18:28 UTC

@github-actions github-actions Bot added core Involves Datadog core libraries tracing labels Apr 24, 2025
@codecov-commenter

codecov-commenter commented Apr 24, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 90.35639% with 46 lines in your changes missing coverage. Please review.

Project coverage is 97.72%. Comparing base (853b4f0) to head (2e52462).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
lib/datadog/error_tracking/component.rb 60.93% 25 Missing ⚠️
lib/datadog/error_tracking/filters.rb 56.25% 14 Missing ⚠️
spec/datadog/error_tracking/spec_helper.rb 60.00% 4 Missing ⚠️
lib/datadog/error_tracking/collector.rb 94.11% 2 Missing ⚠️
spec/datadog/error_tracking/component_spec.rb 99.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4604      +/-   ##
==========================================
- Coverage   97.76%   97.72%   -0.04%     
==========================================
  Files        1422     1441      +19     
  Lines       86719    87195     +476     
  Branches     4405     4469      +64     
==========================================
+ Hits        84783    85214     +431     
- Misses       1936     1981      +45     

☔ 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.

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Apr 24, 2025

Copy link
Copy Markdown
Contributor

Datadog Report

Branch report: dubloom/feat/handled-errors-reporting
Commit report: 2e52462
Test service: dd-trace-rb

✅ 0 Failed, 21293 Passed, 1373 Skipped, 3m 45.52s Total Time

@pr-commenter

pr-commenter Bot commented Apr 24, 2025

Copy link
Copy Markdown

Benchmarks

Benchmark execution time: 2025-05-16 11:24:33

Comparing candidate commit 2e52462 in PR branch dubloom/feat/handled-errors-reporting with baseline commit 853b4f0 in branch master.

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

Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread Rakefile Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/errortracking/collector.rb Outdated
Comment thread lib/datadog/core/errortracking/collector.rb Outdated
Comment thread lib/datadog/core/errortracking/component.rb Outdated
Comment thread lib/datadog/core/errortracking/component.rb Outdated
Comment thread lib/datadog/core/errortracking/component.rb Outdated
Comment thread lib/datadog/core/errortracking/filters.rb Outdated
Comment thread lib/datadog/core/errortracking/filters.rb Outdated
@dubloom
dubloom force-pushed the dubloom/feat/handled-errors-reporting branch from 493c7ee to 6fb24d9 Compare April 25, 2025 14:34
Comment thread lib/datadog/core/configuration/components.rb Outdated

@p-datadog p-datadog 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 think error tracking needs to be a top-level module (moved out of core). Core means functionality used by products, and my understanding is error tracking is a product.

Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/configuration/settings.rb Outdated
Comment thread lib/datadog/core/error_tracking/component.rb Outdated
Comment thread lib/datadog/core/error_tracking/component.rb Outdated

@marcotc marcotc 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.

Because we are adding a global TracePoint, thus adding overhead to the user application that is proportional to the user code, no Datadog code, we should add some benchmarks to ensure our solution is performant.
You can see examples in the benchmarks directory, like: https://github.com/DataDog/dd-trace-rb/blob/master/benchmarks/tracing_trace.rb
You probably want to create a new file, then add it here: https://github.com/DataDog/dd-trace-rb/blob/master/benchmarks/run_all.sh

Comment thread lib/datadog/core/error_tracking/collector.rb Outdated
Comment thread lib/datadog/core/error_tracking/filters.rb Outdated
@dubloom
dubloom force-pushed the dubloom/feat/handled-errors-reporting branch 2 times, most recently from f8acde4 to 7968375 Compare May 12, 2025 08:52
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented May 12, 2025

Copy link
Copy Markdown
Contributor

Datadog Summary

❌ Code Quality    ❌ Code Security    ✅ Dependencies


Was this helpful? Give us feedback!

@dubloom
dubloom force-pushed the dubloom/feat/handled-errors-reporting branch from 6f51515 to 3804a7b Compare May 12, 2025 12:16
Comment thread docs/GettingStarted.md Outdated

@marcotc marcotc 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.

Awesome work, I just left a few documentation suggestions!

@p-datadog p-datadog 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.

Overall LGTM

Comment thread .standard_todo.yml Outdated
Comment thread lib/datadog/error_tracking.rb Outdated
Comment thread lib/datadog/error_tracking/component.rb Outdated
Comment thread lib/datadog/tracing/span_operation.rb Outdated
Comment thread lib/datadog/tracing/span_operation.rb Outdated
Comment thread lib/datadog.rb Outdated

@Strech Strech 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 think we can slightly simplify and Ruby-fy this code

Comment thread Rakefile Outdated
Comment thread lib/datadog/core/configuration/components.rb Outdated
Comment thread lib/datadog/error_tracking/collector.rb Outdated
Comment thread lib/datadog/error_tracking/collector.rb Outdated
Comment thread lib/datadog/error_tracking/collector.rb
Comment thread lib/datadog/error_tracking/component.rb Outdated
Comment thread lib/datadog/error_tracking/component.rb Outdated
Comment thread lib/datadog/error_tracking/extensions.rb
Comment thread lib/datadog/error_tracking/filters.rb
Comment thread lib/datadog/tracing/span_operation.rb Outdated
Comment thread Steepfile Outdated
Comment thread lib/datadog/error_tracking/collector.rb Outdated
Comment thread lib/datadog/error_tracking/collector.rb
Comment thread lib/datadog/error_tracking/collector.rb
Comment thread lib/datadog/error_tracking/collector.rb
Comment thread spec/datadog/error_tracking/component_spec.rb Outdated
Comment thread spec/datadog/error_tracking/component_spec.rb
Comment thread spec/datadog/error_tracking/component_spec.rb
Comment thread spec/support/errortracking_helpers.rb Outdated
Comment thread spec/datadog/error_tracking/component_spec.rb Outdated
@dubloom
dubloom requested review from Strech, p-datadog and y9v May 15, 2025 16:26
Comment thread Steepfile Outdated
Comment thread docs/GettingStarted.md Outdated
Comment thread docs/GettingStarted.md Outdated
Comment thread lib/datadog/error_tracking/component.rb Outdated

@Strech Strech 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'm fine with that changes 👍🏼

But I would like to demand the Rubocop to be enabled. First of all, I've pointed out lots of small issue which suppose to be eliminated by Rubocop. At the same time many similar issues are still present.

I'm not sure what leads to the disablement of the Rubocop, but I don't see any objective reason

Comment thread lib/datadog/error_tracking.rb
Comment thread lib/datadog/error_tracking/collector.rb Outdated
@ivoanjo

ivoanjo commented May 16, 2025

Copy link
Copy Markdown
Member

I'm not sure what leads to the disablement of the Rubocop, but I don't see any objective reason

I believe this PR is using standard, not rubocop. This is the default for any new folders -- you either opt out of standard or opt out of rubocop.

@dubloom
dubloom requested a review from Strech May 16, 2025 10:07

@Strech Strech 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'm approving this PR, but IMHO too many minor here-and-there corrections are not catched by standard-rb.

@dubloom
dubloom merged commit 5ac44e6 into master May 16, 2025
@dubloom
dubloom deleted the dubloom/feat/handled-errors-reporting branch May 16, 2025 11:30
@github-actions github-actions Bot added this to the 2.16.0 milestone May 16, 2025
@Strech Strech mentioned this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Involves Datadog core libraries tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants