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

Support valkey-go tracing #3081

Merged
merged 29 commits into from
Jan 28, 2025
Merged

Support valkey-go tracing #3081

merged 29 commits into from
Jan 28, 2025

Conversation

keisku
Copy link
Contributor

@keisku keisku commented Jan 12, 2025

What does this PR do?

Support https://github.com/valkey-io/valkey-go

Example:

2025-01-24_00-08-27

Motivation

#2920

Reviewer's Checklist

  • Changed code has unit tests for its functionality at or near 100% coverage.
  • System-Tests covering this feature have been added and enabled with the va.b.c-dev version tag.
  • There is a benchmark for any new code, or changes to existing code.
  • If this interacts with the agent in a new way, a system test has been added.
  • Add an appropriate team label so this PR gets put in the right place for the release notes.
  • Non-trivial go.mod changes, e.g. adding new modules, are reviewed by @DataDog/dd-trace-go-guild.
  • For internal contributors, a matching PR should be created to the v2-dev branch and reviewed by @DataDog/apm-go.

Unsure? Have a question? Request a review!

@github-actions github-actions bot added the apm:ecosystem contrib/* related feature requests or bugs label Jan 12, 2025
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jan 12, 2025

Datadog Report

Branch report: keisku/valkey-go-support
Commit report: 3939a5a
Test service: dd-trace-go

❌ 8 Failed (0 Known Flaky), 5167 Passed, 70 Skipped, 2m 54.4s Total Time

❌ Failed Tests (8)

This report shows up to 5 failed tests.

  • TestNewClient - gopkg.in/DataDog/dd-trace-go.v1/contrib/valkey-go - Details

    Expand for error
     Failed
     
     === RUN   TestNewClient
     --- FAIL: TestNewClient (0.11s)
    
  • TestNewClient/Test_GET_command_with_stream_with_env_vars - gopkg.in/DataDog/dd-trace-go.v1/contrib/valkey-go - Details

    Expand for error
     Failed
     
     === RUN   TestNewClient/Test_GET_command_with_stream_with_env_vars
         valkey_test.go:287: 
             	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:287
             	Error:      	Received unexpected error:
             	            	dial tcp 127.0.0.1:6380: connect: connection refused
             	Test:       	TestNewClient/Test_GET_command_with_stream_with_env_vars
             	Messages:   	Test GET command with stream with env vars
         --- FAIL: TestNewClient/Test_GET_command_with_stream_with_env_vars (0.02s)
    
  • TestNewClient/Test_HMGET_command_with_cache - gopkg.in/DataDog/dd-trace-go.v1/contrib/valkey-go - Details

    Expand for error
     Failed
     
     === RUN   TestNewClient/Test_HMGET_command_with_cache
         valkey_test.go:287: 
             	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:287
             	Error:      	Received unexpected error:
             	            	dial tcp 127.0.0.1:6380: connect: connection refused
             	Test:       	TestNewClient/Test_HMGET_command_with_cache
             	Messages:   	Test HMGET command with cache
         --- FAIL: TestNewClient/Test_HMGET_command_with_cache (0.01s)
    
  • TestNewClient/Test_invalid_password - gopkg.in/DataDog/dd-trace-go.v1/contrib/valkey-go - Details

    Expand for error
     Failed
     
     === RUN   TestNewClient/Test_invalid_password
         valkey_test.go:67: 
             	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:67
             	            				/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:289
             	Error:      	Error message not equal:
             	            	expected: "WRONGPASS invalid username-password pair or user is disabled."
             	            	actual  : "dial tcp 127.0.0.1:6380: connect: connection refused"
             	Test:       	TestNewClient/Test_invalid_password
     ...
    
  • TestNewClient/Test_invalid_username - gopkg.in/DataDog/dd-trace-go.v1/contrib/valkey-go - Details

    Expand for error
     Failed
     
     === RUN   TestNewClient/Test_invalid_username
         valkey_test.go:56: 
             	Error Trace:	/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:56
             	            				/home/runner/work/dd-trace-go/dd-trace-go/contrib/valkey-go/valkey_test.go:289
             	Error:      	Error message not equal:
             	            	expected: "WRONGPASS invalid username-password pair or user is disabled."
             	            	actual  : "dial tcp 127.0.0.1:6380: connect: connection refused"
             	Test:       	TestNewClient/Test_invalid_username
     ...
    

@pr-commenter
Copy link

pr-commenter bot commented Jan 12, 2025

Benchmarks

Benchmark execution time: 2025-01-28 15:21:06

Comparing candidate commit 3234dc9 in PR branch keisku/valkey-go-support with baseline commit dde97eb in branch main.

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

@keisku keisku force-pushed the keisku/valkey-go-support branch 8 times, most recently from e41ab88 to 7c97f5b Compare January 15, 2025 08:55
@keisku keisku force-pushed the keisku/valkey-go-support branch from 7c97f5b to 6aa8d69 Compare January 15, 2025 10:56
@keisku keisku marked this pull request as ready for review January 15, 2025 11:20
@keisku keisku requested review from a team as code owners January 15, 2025 11:20
contrib/valkey-go/valkey.go Outdated Show resolved Hide resolved
@keisku keisku force-pushed the keisku/valkey-go-support branch from 11e7c51 to 2750600 Compare January 16, 2025 03:33
@keisku keisku force-pushed the keisku/valkey-go-support branch from 2750600 to fe59e6d Compare January 16, 2025 03:36
@darccio
Copy link
Member

darccio commented Jan 17, 2025

@keisku Thanks for contributing this integration! Please fix the conflicts and this should be good to go.

Also remember to create the same PR against v2-dev. Keep in mind that this branch has some major differences, including an instrumentation package for contribs. Check the same integration for Redis to learn more about how to integrate a library in our contribs in our upcoming v2 version.

contrib/valkey-go/example_test.go Show resolved Hide resolved
contrib/valkey-go/valkey.go Outdated Show resolved Hide resolved
@keisku keisku requested a review from rarguelloF January 21, 2025 01:56
contrib/valkey-go/valkey.go Outdated Show resolved Hide resolved
skipRawCommand bool
}

func (c *coreClient) peerTags() []tracer.StartSpanOption {
Copy link
Contributor

@rarguelloF rarguelloF Jan 22, 2025

Choose a reason for hiding this comment

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

The agent checks a list of tags to compute peer.service, and I think both out.host and peer.hostname would be considered in this case. But for consistency with other integrations, I think its preferred to just set out.host (I am asking around if this preference has changed recently and if we have any documentation about it)

contrib/valkey-go/valkey.go Outdated Show resolved Hide resolved
opts = append(opts, []tracer.StartSpanOption{
// valkeyotel tags
tracer.Tag("db.stmt_size", input.size),
tracer.Tag("db.operation", input.command),
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to add obfuscation, since its already done in the agent (the code you linked). However I just noticed there's an issue, since that code will only run if span.type is redis, so it won't run for valkey. I will talk to the apm-agent team about this.

But basically what we want to do here is:

if !input.skipRawCommand {
	opts = append(opts, tracer.Tag(ext.ValkeyRawCommand, input.command))
}

Also it is preferred to set only the raw command tag, since its the one the agent checks for obfuscation (when the logic is updated to check for valkey as well).

@keisku keisku force-pushed the keisku/valkey-go-support branch from 787b31f to 27b0fec Compare January 23, 2025 08:51
@keisku keisku requested a review from rarguelloF January 23, 2025 15:08
Copy link
Contributor

@rarguelloF rarguelloF left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution! @keisku

@rarguelloF rarguelloF enabled auto-merge (squash) January 28, 2025 13:31
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Jan 28, 2025

Datadog Report

Branch report: keisku/valkey-go-support
Commit report: d41d7ae
Test service: dd-trace-go

✅ 0 Failed, 5216 Passed, 72 Skipped, 2m 45.95s Total Time

@rarguelloF rarguelloF merged commit f0ed584 into main Jan 28, 2025
197 checks passed
@rarguelloF rarguelloF deleted the keisku/valkey-go-support branch January 28, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants