Skip to content

Added WithErrorCheck option to redis #2040

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

Merged
merged 4 commits into from
Jun 29, 2023

Conversation

lsgndln
Copy link
Contributor

@lsgndln lsgndln commented Jun 13, 2023

What does this PR do?

This PR adds a WithErrorCheck to the redis packages. I originally created an issue here that was accepted.

Motivation

The goal of this option is to have a way to define which error should be marked as a datadog error.

For example, a context.Canceled error could be ignored in datadog.

redistrace.WithErrorCheck(func(err error) bool {
    return err != nil && !errors.Is(err, context.Canceled)
})

Describe how to test/QA your changes

I added tests in the different packages, they can be checked to see how to test the changes.

The custom error check function can be added to the client as an option :

errCheckFn := func(err error) bool {
    return err != nil && !errors.Is(err, context.Canceled)
}
		
client := NewClient(opts, WithServiceName("my-redis"), WithErrorCheck(errCheckFn))

Reviewer's Checklist

  • Changed code has unit tests for its functionality.
  • If this interacts with the agent in a new way, a system test has been added.

Sorry, something went wrong.

@lsgndln lsgndln requested a review from a team June 13, 2023 08:59
Co-authored-by: Andrew Glaude <ajgajg1134@gmail.com>
@ajgajg1134 ajgajg1134 merged commit 5ea746b into DataDog:main Jun 29, 2023
@lsgndln lsgndln deleted the redis-err-check-option branch June 29, 2023 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants