-
Notifications
You must be signed in to change notification settings - Fork 812
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
#4147 added tenant_id
tag to tracing spans
#4186
#4147 added tenant_id
tag to tracing spans
#4186
Conversation
1. added logic to add tag `tenant_id` to tracing spans if tenant is defined in context. 2. added additional tracing spans to merge_querier's methods Signed-off-by: Vladyslav Diachenko <[email protected]>
5b465ff
to
3a3cb4b
Compare
Signed-off-by: Vladyslav Diachenko <[email protected]>
62a9c87
to
acef697
Compare
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.
Thanks this looks already quite good. 👍
See my comments in-line and feel free to ping me when things are unclear
// TODO: it's necessary to think how to override context inside querier | ||
// to mark spans created inside querier as child of a span created inside | ||
// methods of merged querier. |
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 think it would make sense to create a span during the creation of the queriers and the finish the span once Close()
of the resulting mergeQuerier is called.
I have played with that 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.
This feels at least like it can group the same tenants nicely together. Obvisouly for a real fix we need context propagation as a part of LabelValues,LabelName, Select.
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, it will help to group spans by tenant_id . thanks, i will implement it
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.
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.
To be honest I agree partly with your point, but I am not too sure, how to fix this properly.
I guess part of the problem is that the a query is only finished once Close()
is called, which happens at the same time for underlying queriers.
I think the most confusing part of not grouping spans by tenant_id is seeing all (and even unrelated) spans together. I think until we implement context passing in those methods, we won't be able to solve that properly.
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.
You could instantiate the queriers (call the callback inside LabelValues, etc.) and the right context will be applied.
pkg/util/spanlogger/spanlogger.go
Outdated
@@ -34,6 +39,9 @@ func New(ctx context.Context, method string, kvps ...interface{}) (*SpanLogger, | |||
// retrieved with FromContext or FromContextWithFallback. | |||
func NewWithLogger(ctx context.Context, l log.Logger, method string, kvps ...interface{}) (*SpanLogger, context.Context) { | |||
span, ctx := opentracing.StartSpanFromContext(ctx, method) | |||
if ids, _ := tenant.TenantIDs(ctx); ids != nil { |
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 am not too sure what other side effects this could have, but I think in general it is a good idea to always have the context's tenant_id(s) in the tracing span.
1.changed value of tenant_id tag in tracing span from string value to array 2. removed import alias for spanlogger Signed-off-by: Vladyslav Diachenko <[email protected]>
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.
LGTM, I only have minor comments
(note that I'm not a maintainer, so this approval doesn't count towards the required approval count)
1. fixed tests 2. fixed name of the spans in mergeQuerier Signed-off-by: Vladyslav Diachenko <[email protected]>
Signed-off-by: Vladyslav Diachenko <[email protected]>
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.
LGTM, and I wonder how bad is creating the queriers
inside Select
, LabelValues
, etc.
…gSlice function to create inner spans under this context Signed-off-by: Vladyslav Diachenko <[email protected]>
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.
LGTM
I think there is still a go mod vendor
necessary to make the CI/CD work
I think with |
Signed-off-by: Vladyslav Diachenko <[email protected]>
54b81ba
to
669b8d2
Compare
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.
LGTM modulo a couple of nits I would be glad to see fixed before merging. Thanks!
…am that is not used in callback function Signed-off-by: Vladyslav Diachenko <[email protected]>
Signed-off-by: Vladyslav Diachenko <[email protected]>
What this PR does:
tenant_ids
to tracing spans if tenant is defined in context.Which issue(s) this PR fixes:
Fixes #4147
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]