Skip to content

Add tracing spans to promql#4436

Merged
gouthamve merged 2 commits intoprometheus:masterfrom
gouthamve:promql-spans
Aug 16, 2018
Merged

Add tracing spans to promql#4436
gouthamve merged 2 commits intoprometheus:masterfrom
gouthamve:promql-spans

Conversation

@gouthamve
Copy link
Member

@tomwilkie @bboreham This'll help in prometheus when we add proper tracing support, but currently we'd like to use this for Cortex.

screen shot 2018-07-30 at 15 32 33

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
@gouthamve gouthamve changed the title Add spans to promql Add tracing spans to promql Jul 30, 2018

queueTimer.Stop()
ng.metrics.queryQueueTime.Observe(queueTimer.ElapsedTime().Seconds())
queueSpanTimer.Finish()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a problem that the if the gate.Start fails, this won't be stopped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, yep. But it wasn't stopped before either....

promql/engine.go Outdated
// spanTimer unifies tracing and timing, to reduce repetition.
type spanTimer struct {
timer *stats.Timer
observers []prometheus.Summary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type of this []prometheus.Observer or []prometheus.ObserverFunc.

promql/engine.go Outdated
span opentracing.Span
}

func newSpanTimer(ctx context.Context, operation string, timer *stats.Timer, observers ...prometheus.Summary) (*spanTimer, context.Context) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are no counter stats that we do not want to trace, how about moving all the tracing code directly into query_stats.go in the stats package? Then you can also associate span names with the existing counter type constants there instead of having the caller determine that in the engine.

promql/engine.go Outdated
defer querier.Close()
}
{
// New block because we want to throw away this ctx. Propagating it further makes every call a child of prepare in traces.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just call it ctxPrepare / prepareCtx?

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
@gouthamve
Copy link
Member Author

@juliusv Done. Could you take another look?

@juliusv
Copy link
Member

juliusv commented Aug 3, 2018

👍 Thanks.

(I think in the long term it'd make sense to move the promql-specific timer names back to the promql package, but keep the generic timer code in a separate package)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants