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

Add config support for "on_error" in Elasticsearch tracing #4066

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bill-kolokithas
Copy link

This mirrors the functionality that is already present in many other instrumenters.

Reasons for wanting this:

One might want to ignore some errors in some expected scenarios such as

Elasticsearch::Transport::Transport::Errors::NotFound
or
Elasticsearch::Transport::Transport::Errors::Conflict

What does this PR do?
Adds on_error configuration support for Elasticsearch tracing and forwards it to Tracing.trace

Motivation:
We have flows where NotFound exceptions are expected and we make sure to handle them in the application.
We don't want them to show up as errors in the dashboard though.

How to test the change?
Run provided tests with bundle exec rake test:elasticsearch

@bill-kolokithas bill-kolokithas requested review from a team as code owners November 5, 2024 10:55
@github-actions github-actions bot added integrations Involves tracing integrations tracing labels Nov 5, 2024
This mirrors the functionality that is already present in many other
instrumenters.

Reasons for wanting this:

You might want to ignore some errors in some expected scenarios such as

Elasticsearch::Transport::Transport::Errors::NotFound
or
Elasticsearch::Transport::Transport::Errors::Conflict
@codecov-commenter
Copy link

codecov-commenter commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.72%. Comparing base (2cbd6a1) to head (1dc216f).
Report is 24 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4066   +/-   ##
=======================================
  Coverage   97.72%   97.72%           
=======================================
  Files        1338     1338           
  Lines       80248    80269   +21     
  Branches     4016     4018    +2     
=======================================
+ Hits        78420    78442   +22     
+ Misses       1828     1827    -1     

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

Copy link

@rtrieu rtrieu left a comment

Choose a reason for hiding this comment

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

Minor feedback on tense.

@@ -677,6 +677,7 @@ Datadog.configure_onto(client.transport, **options)
| `service_name` | `DD_TRACE_ELASTICSEARCH_SERVICE_NAME` | `String` | Name of application running the `elasticsearch` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `elasticsearch` |
| `peer_service` | `DD_TRACE_ELASTICSEARCH_PEER_SERVICE` | `String` | Name of external service the application connects to | `nil` |
| `quantize` | | `Hash` | Hash containing options for quantization. May include `:show` with an Array of keys to not quantize (or `:all` to skip quantization), or `:exclude` with Array of keys to exclude entirely. | `{}` |
| `on_error` | | `Proc` | Custom error handler invoked when a request raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
Copy link

Choose a reason for hiding this comment

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

Suggested change
| `on_error` | | `Proc` | Custom error handler invoked when a request raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
| `on_error` | | `Proc` | Custom error handler invoked when a request raises an error. Provides `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring transient errors. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! fixup: 1dc216f

@ivoanjo ivoanjo requested a review from a team November 6, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations tracing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants