-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Compactor: Add tracing support #4903
Conversation
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
0aea0cb
to
ae6b6d5
Compare
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
adda8bb
to
3783abd
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.
This is looking cool! I was wondering about one more thing, which I think could be particularly useful in the context of compaction and that is to also record the error in the span (we would have the error in the logs, but I think having them directly on span would be more handy).
We are using our convenience method DoInSpan
here, but that does not capture an error if it occurs. Maybe we could have another method (e.g. DoInSpanWithErr
) which could also set the error on span. Does that sound good?
Co-authored-by: Matej Gera <38492574+matej-g@users.noreply.github.com> Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
3d0dd8f
to
f12a18e
Compare
e11d776
to
7620389
Compare
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
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.
Great job @metonymic-smokey! Thanks for going above and beyond to address things. I'm wondering about one last thing, afterwards I believe this is ready.
Let's try to get a review from maintainer as well, perhaps @yeya24 as original issue reporter.
pkg/tracing/tracing.go
Outdated
span, newCtx := StartSpan(ctx, operationName, opts...) | ||
defer span.Finish() | ||
err := doFn(newCtx) | ||
span.LogFields(opentracing_log.Error(err)) |
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'm not sure about the behavior if
err
isnil
(whether it still logs error), but maybe we could checkerr != nil
before we log error? - I think we can replace this with method from the
ext
package, see https://pkg.go.dev/github.com/opentracing/opentracing-go@v1.2.0/ext#LogError. This will set all necessary things on the span for us
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.
Good point @matej-g. Thanks!
I've made the changes in a recent commit. Let me know if they're okay.
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
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.
💯
pkg/tracing/tracing.go
Outdated
defer span.Finish() | ||
err := doFn(newCtx) | ||
if err != nil { | ||
ext.LogError(span, err, opentracing_log.Error(err)) |
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 believe we do not need to pass the last value, since the method will already include the field for error.
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.
Looks good overall! Some very small nits
pkg/compact/compact.go
Outdated
err = block.Download(ctx, cg.logger, cg.bkt, meta.ULID, bdir) | ||
return err | ||
}, opentracing.Tags{"block.id": meta.ULID}) | ||
|
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.
tiny nit
pkg/compact/compact.go
Outdated
return false, ulid.ULID{}, retry(errors.Wrapf(err, "download block %s", meta.ULID)) | ||
} | ||
|
||
// Ensure all input blocks are valid. | ||
stats, err := block.GatherIndexHealthStats(cg.logger, filepath.Join(bdir, block.IndexFilename), meta.MinTime, meta.MaxTime) | ||
var stats block.HealthStats | ||
tracing.DoInSpanWithErr(ctx, "compaction_block_healthstats", func(ctx context.Context) error { |
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 the Golang name is ...HealthStats
, health
and stats
should be treated as separate words
tracing.DoInSpanWithErr(ctx, "compaction_block_healthstats", func(ctx context.Context) error { | |
tracing.DoInSpanWithErr(ctx, "compaction_block_health_stats", func(ctx context.Context) error { |
pkg/compact/compact.go
Outdated
@@ -764,7 +766,11 @@ func (cg *Group) Compact(ctx context.Context, dir string, planner Planner, comp | |||
return false, ulid.ULID{}, errors.Wrap(err, "create compaction group dir") | |||
} | |||
|
|||
shouldRerun, compID, err := cg.compact(ctx, subDir, planner, comp) | |||
var err error | |||
tracing.DoInSpanWithErr(ctx, "group_compaction", func(ctx context.Context) error { |
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.
All other spans are named compaction_<x>
, should we make this follow the same convention?
Signed-off-by: metonymic-smokey <ahuja.aditi@gmail.com>
lgtm! restarting failed jobs and we can merge :)) |
Fixes #4832
Changes
Added tracing support for the various compaction steps(similar to Querier).
Verification
Tested locally using Jaeger.