Skip to content

Added WithErrorCheck option to redis#2040

Merged
ajgajg1134 merged 4 commits into
DataDog:mainfrom
lsgndln:redis-err-check-option
Jun 29, 2023
Merged

Added WithErrorCheck option to redis#2040
ajgajg1134 merged 4 commits into
DataDog:mainfrom
lsgndln:redis-err-check-option

Conversation

@lsgndln

@lsgndln lsgndln commented Jun 13, 2023

Copy link
Copy Markdown
Contributor

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.

@lsgndln
lsgndln requested a review from a team June 13, 2023 08:59
Comment thread contrib/redis/go-redis.v9/redis_test.go Outdated
Comment thread contrib/go-redis/redis.v8/redis_test.go Outdated
@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.

3 participants