-
Notifications
You must be signed in to change notification settings - Fork 445
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 sending custom tags when using pollDBStats #3067
Conversation
statsd.Gauge(MaxOpenConnections, float64(stat.MaxOpenConnections), tags, 1) | ||
statsd.Gauge(OpenConnections, float64(stat.OpenConnections), tags, 1) | ||
statsd.Gauge(InUse, float64(stat.InUse), tags, 1) | ||
statsd.Gauge(Idle, float64(stat.Idle), tags, 1) | ||
statsd.Gauge(WaitCount, float64(stat.WaitCount), tags, 1) | ||
statsd.Timing(WaitDuration, stat.WaitDuration, tags, 1) | ||
statsd.Gauge(MaxIdleClosed, float64(stat.MaxIdleClosed), tags, 1) | ||
statsd.Gauge(MaxIdleTimeClosed, float64(stat.MaxIdleTimeClosed), tags, 1) | ||
statsd.Gauge(MaxLifetimeClosed, float64(stat.MaxLifetimeClosed), tags, 1) |
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.
@mtoffl01 Was there any reason behind not allowing tags from the beginning?
Checking the code, I see that for the purpose of this PR, it should be enough to set DD_TAGS
or OTEL_PROPAGATORS
(if using OTel) to set these global tags.
WDYT @KaibutsuX?
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.
I don't have enough context or documentation to know what DD_TAGS
is or how I would set it as an end-user.
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.
DD_TAGS
is properly explained in our Go tracer public documentation.
We understand this should be enough to achieve what you are trying with this PR.
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.
That links says: "A list of default tags to be added to every span and profile." From my tracing through the code, I could not see that this same list of user-supplied tags was included in these metrics used in pollDBStats
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.
Yes, we understand it may not that be clear from the code. Sorry about that. It inherits the global tags from the tracer config, set by globalconfig.SetStatsTags
, which is initialized by newConfig
, and retrieved when setting up the DB statsd client.
We'll update the public documentation to make sure it reflects this detail.
Hi @KaibutsuX , As @darccio pointed out, tags set in Are you trying to pass your global tags down to DBStats metrics, or are you looking to apply a unique set of tags specifically to those metrics? If the former, Thank you! |
@mtoffl01 I will see if using DD_TAGS works as expected. You may want to also update the documentation for DD_TAGS as it is marked as an array, but in go code it accepts a |
Hi @KaibutsuX , Thanks for the tip! We will change the |
@KaibutsuX Is everything solved with the tips we shared? Do you want to still push this into the codebase? Thanks! |
Using the alternative suggestion does not allow me to set the metrics namespace. Instead all tags are sent to the default namespace, which in my use-case makes the tagging unhelpful and results in just more noise. For the time being, I'm still using a local version of this PR to support my own |
@KaibutsuX , If you would like to configure tags to apply only to your DB Stats metrics, please tell us some more about how you use these tags. If I've not understood the "namespace" term, please expand. Thank you! |
Since absolutely everything is being sent to the same namespace, if I'm only interested in 30 / 1000 tags is makes it hard to filter and use.
|
|
||
func WithDBStatsTags(tags []string) Option { |
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.
func WithDBStatsTags(tags []string) Option { | |
// WithDBStatsTags enables DBStats metrics collection and sets the given tags for those metrics. | |
func WithDBStatsTags(tags map[string]string) Option { |
Could we make this a map[string]string
? Since this is how we model tags generally everywhere else.
We can keep cfg.statsTags
as a []string
and do the transformation here.
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.
func statsTags(c *config) []string { |
dd-trace-go/internal/statsd.go
Line 16 in c345adb
type StatsdClient interface { |
That does make more sense, but since your public interfaces accept []string
with an only an expected convention of using :
as the delimiter between keys/values, I think it's probably better to address those public places first and/or update documentation.
I'm closing this as I no longer have the time to spend on it.
@KaibutsuX , Upon revisiting this request I noticed that we already support tag customization at the integration level (that is, not global) via the
Key differences between this option and the
Are these differences significant enough to you to warrant a new API? Please let us know and we will consider this further. By the way, the documentation for the existing WithCustomTag option predates the DBStats feature, so it misleadingly implies that the tags provided will apply only to spans, not metrics. To address this, I've opened this PR to clarify the documentation: #3246 |
What does this PR do?
Motivation
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!