feat: opentracing in query execution runtime

pull/16444/head
Yiqun Zhang 2020-01-08 11:16:13 -05:00 committed by GitHub
parent 578f97d0b7
commit 74ba877cb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"strings"
"time"
"github.com/influxdata/flux"
"github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/cmd/influxd/generate"
"github.com/influxdata/influxdb/cmd/influxd/inspect"
@ -45,6 +46,11 @@ func init() {
rootCmd.AddCommand(launcher.NewCommand())
rootCmd.AddCommand(generate.Command)
rootCmd.AddCommand(inspect.NewCommand())
// TODO: this should be removed in the future: https://github.com/influxdata/influxdb/issues/16220
if os.Getenv("QUERY_TRACING") == "1" {
flux.EnableExperimentalTracing()
}
}
// find determines the default behavior when running influxd.

View File

@ -45,7 +45,14 @@ type Source struct {
func (s *Source) Run(ctx context.Context) {
labelValues := s.m.getLabelValues(ctx, s.orgID, s.op)
start := time.Now()
err := s.runner.run(ctx)
var err error
if flux.IsExperimentalTracingEnabled() {
span, ctxWithSpan := tracing.StartSpanFromContextWithOperationName(ctx, "source-"+s.op)
err = s.runner.run(ctxWithSpan)
span.Finish()
} else {
err = s.runner.run(ctx)
}
s.m.recordMetrics(labelValues, start)
for _, t := range s.ts {
t.Finish(s.id, err)