Skip to content

Support valkey-go tracing#3081

Merged
rarguelloF merged 29 commits into
mainfrom
keisku/valkey-go-support
Jan 28, 2025
Merged

Support valkey-go tracing#3081
rarguelloF merged 29 commits into
mainfrom
keisku/valkey-go-support

Conversation

@keisku

@keisku keisku commented Jan 12, 2025

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

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

pr-commenter Bot commented Jan 12, 2025

Copy link
Copy Markdown

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
Comment thread contrib/valkey-go/valkey.go Outdated
@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

darccio commented Jan 17, 2025

Copy link
Copy Markdown
Member

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

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

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

@rarguelloF rarguelloF Jan 22, 2025

Copy link
Copy Markdown
Contributor

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)

Comment thread contrib/valkey-go/valkey.go Outdated
Comment thread contrib/valkey-go/valkey.go Outdated
opts = append(opts, []tracer.StartSpanOption{
// valkeyotel tags
tracer.Tag("db.stmt_size", input.size),
tracer.Tag("db.operation", input.command),

Copy link
Copy Markdown
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

@rarguelloF rarguelloF left a comment

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

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
@rarguelloF
rarguelloF deleted the keisku/valkey-go-support branch January 28, 2025 15:32
@keisku keisku mentioned this pull request Feb 26, 2025
7 tasks
@keisku keisku mentioned this pull request Mar 5, 2025
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