-
Notifications
You must be signed in to change notification settings - Fork 441
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
base: main
Are you sure you want to change the base?
Conversation
Datadog ReportBranch report: ❌ 8 Failed (0 Known Flaky), 5167 Passed, 70 Skipped, 2m 54.4s Total Time ❌ Failed Tests (8)
|
e41ab88
to
7c97f5b
Compare
7c97f5b
to
6aa8d69
Compare
11e7c51
to
2750600
Compare
2750600
to
fe59e6d
Compare
@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 |
Signed-off-by: keisku <keisuke.umegaki@datadoghq.com>
Signed-off-by: keisku <keisuke.umegaki@datadoghq.com>
Signed-off-by: keisku <keisuke.umegaki@datadoghq.com>
fbb2f5f
to
6d5b6f6
Compare
contrib/valkey-go/valkey.go
Outdated
skipRawCommand bool | ||
} | ||
|
||
func (c *coreClient) peerTags() []tracer.StartSpanOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't be setting peer.*
tags in this integration. You can mirror the behavior of the go-redis integration for these tags: https://github.com/DataDog/dd-trace-go/blob/main/contrib/redis/go-redis.v9/redis.go#L75-L111 (changing redis -> valkey where appropiate)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't be setting peer.* tags in this integration.
Could you explain the reason for this?
After reading the following docs, I understood peer.*
is necessary tags now. Since the last commit for go-redis.v9 was two years ago, I assumed that it was not required at that time.
I'd appreciate it if you could let me know if my understanding is incorrect.
There was a problem hiding this comment.
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
ipAddr := net.ParseIP(c.host) | ||
var peerHostKey string | ||
if ipAddr == nil { | ||
peerHostKey = ext.PeerHostname | ||
} else if ipAddr.To4() != nil { | ||
peerHostKey = ext.PeerHostIPV4 | ||
} else { | ||
peerHostKey = ext.PeerHostIPV6 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ipAddr := net.ParseIP(c.host) | |
var peerHostKey string | |
if ipAddr == nil { | |
peerHostKey = ext.PeerHostname | |
} else if ipAddr.To4() != nil { | |
peerHostKey = ext.PeerHostIPV4 | |
} else { | |
peerHostKey = ext.PeerHostIPV6 | |
} |
this is not necessary, the integration should only set out.host
when unsure whether the value is an IP address or a hostname. We already have this sort of logic in place in the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out.host
seems to be deprecated. So, should we set network.destination.name
or network.destination.ip
?
dd-trace-go/ddtrace/ext/tags.go
Lines 11 to 13 in 241a6f1
// TargetHost sets the target host address. | |
// Deprecated: Use NetworkDestinationName instead for hostname and NetworkDestinationIP for IP addresses | |
TargetHost = "out.host" |
contrib/valkey-go/valkey.go
Outdated
skipRawCommand bool | ||
} | ||
|
||
func (c *coreClient) peerTags() []tracer.StartSpanOption { |
There was a problem hiding this comment.
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
tracer.Tag(ext.ValkeyDatabaseIndex, c.option.SelectDB), | ||
tracer.Tag("db.out", c.option.SelectDB), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracer.Tag(ext.ValkeyDatabaseIndex, c.option.SelectDB), | |
tracer.Tag("db.out", c.option.SelectDB), | |
tracer.Tag("out.db", c.option.SelectDB), |
db.out
->out.db
- only one of the 2 tags (we want to avoid repeated information)
Also, if you don't mind, could you create a new constant ext.OutDB
for out.db
to prevent this kind of mistake to happen in the future? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since out.host
was deprecated, should we avoid setting out.db
?
Or should we keep setting out.db
for consistency of redis integration?
dc939eb marked it as deprecated.
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), |
There was a problem hiding this comment.
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).
787b31f
to
27b0fec
Compare
What does this PR do?
Support https://github.com/valkey-io/valkey-go
Example:
Motivation
#2920
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!