Skip to content
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 Jaeger tracer #1030 #1147

Merged
merged 40 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0f2a463
Add jaeger tracing feature.
May 8, 2019
0e3f2eb
Remove comments
May 8, 2019
39e9bcb
Remove comments
May 8, 2019
304f4da
Refactoring tracing
May 13, 2019
bb5fa34
Implementing jaeger logger.
May 13, 2019
a97415a
Add jaeger force tracing header.
May 13, 2019
38d252c
Use debugName for tracing service-name
May 13, 2019
4c03137
RemoveFactory config
May 13, 2019
3869ce4
Formatting fix; Use io.Closer intead func() error
May 14, 2019
cede9a4
Rename gcloud => stackdriver
May 14, 2019
27f3ef0
Refactoring google tracing testing.
May 14, 2019
3d12afe
Delete comments.
May 14, 2019
d24e376
Rename gcloud flags => stackdriver.
May 14, 2019
eed06c6
Update tracing docs.
May 14, 2019
eb405ce
Fix ..traceType to ..tracerType
May 14, 2019
c745171
Refactoring NoopTracer; Comments for exported functions.
May 15, 2019
331a929
Remove noop tracer. Fix docs.
May 15, 2019
47f3fd1
Remove noop tracer. Fix docs.
May 15, 2019
ff1b837
Merge remote-tracking branch 'improbable/master' into feature/jaeger-…
May 15, 2019
ff5a2aa
Config tracing same as objstore.
May 22, 2019
2d74602
Configure jaeger tracing from YAML. Some small fixes.
May 23, 2019
72eaca4
Fix errcheck
May 23, 2019
1a9b83d
Add X-Thanos-Trace-Id HTTP header for simplified search traces
May 24, 2019
27be8ea
Cleanup
May 24, 2019
e46fae6
make docs
May 24, 2019
2596e11
Add store addr to tracing tags.
May 24, 2019
0d9af01
Tracing refactoring.
May 27, 2019
b60a536
Fix noop tracing closer.
May 27, 2019
c7b67ca
Add few tracing spans.
May 28, 2019
2e942f1
Pass prometheus registry to jaeger.
May 28, 2019
d31bafa
Merge branch 'imaster' into feature/jaeger-tracing
May 29, 2019
5642771
go.mod
May 29, 2019
9ced678
Merge branch 'imaster' into feature/jaeger-tracing
May 31, 2019
72d5559
Refactoring
May 31, 2019
ff15def
Merge branch 'imaster' into feature/jaeger-tracing
May 31, 2019
94aabb3
Resolve go mod conflicts
May 31, 2019
4e98096
Remove comments.
May 31, 2019
6b9f48f
Merge branch 'imaster' into feature/jaeger-tracing
Jun 4, 2019
b70f05a
PR refactoring for review.
Jun 4, 2019
847cc91
Format files.
Jun 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions cmd/thanos/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,24 @@ func regCommonObjStoreFlags(cmd *kingpin.CmdClause, suffix string, required bool
content: bucketConf,
}
}


func regCommonTracingFlags(app *kingpin.Application) *pathOrContent {
fileFlagName := fmt.Sprintf("tracing.config-file")
contentFlagName := fmt.Sprintf("tracing.config")

help := fmt.Sprintf("Path to YAML file that contains tracing configuration.")
tracingConfFile := app.Flag(fileFlagName, help).PlaceHolder("<tracing.config-yaml-path>").String()

help = fmt.Sprintf("Alternative to '%s' flag. Tracing configuration in YAML.", fileFlagName)
tracingConf := app.Flag(contentFlagName, help).PlaceHolder("<tracing.config-yaml>").String()

return &pathOrContent{
fileFlagName: fileFlagName,
contentFlagName: contentFlagName,
required: false,

path: tracingConfFile,
content: tracingConf,
}
}
38 changes: 25 additions & 13 deletions cmd/thanos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"io/ioutil"
"math"
"net"
Expand All @@ -18,17 +19,17 @@ import (
"syscall"

gmetrics "github.com/armon/go-metrics"

gprom "github.com/armon/go-metrics/prometheus"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/grpc-ecosystem/go-grpc-middleware"
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/improbable-eng/thanos/pkg/runutil"
"github.com/improbable-eng/thanos/pkg/tracing"
"github.com/improbable-eng/thanos/pkg/tracing/client"
"github.com/oklog/run"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand All @@ -37,7 +38,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/status"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/alecthomas/kingpin.v2"
)

const (
Expand Down Expand Up @@ -65,10 +66,7 @@ func main() {
logFormat := app.Flag("log.format", "Log format to use.").
Default(logFormatLogfmt).Enum(logFormatLogfmt, logFormatJson)

gcloudTraceProject := app.Flag("gcloudtrace.project", "GCP project to send Google Cloud Trace tracings to. If empty, tracing will be disabled.").
String()
gcloudTraceSampleFactor := app.Flag("gcloudtrace.sample-factor", "How often we send traces (1/<sample-factor>). If 0 no trace will be sent periodically, unless forced by baggage item. See `pkg/tracing/tracing.go` for details.").
Default("1").Uint64()
tracingConfig := regCommonTracingFlags(app)

cmds := map[string]setupFunc{}
registerSidecar(cmds, app, "sidecar")
Expand Down Expand Up @@ -143,8 +141,20 @@ func main() {
{
ctx := context.Background()

var closeFn func() error
tracer, closeFn = tracing.NewOptionalGCloudTracer(ctx, logger, *gcloudTraceProject, *gcloudTraceSampleFactor, *debugName)
var closer io.Closer
var confContentYaml []byte
confContentYaml, err = tracingConfig.Content()

if len(confContentYaml) == 0 {
level.Info(logger).Log("msg", "Tracing will be disabled")
tracer = client.NoopTracer()
} else {
tracer, closer, err = client.NewTracer(ctx, logger, metrics, confContentYaml)
if err != nil {
fmt.Fprintln(os.Stderr, errors.Wrapf(err, "tracing failed"))
os.Exit(1)
}
}

// This is bad, but Prometheus does not support any other tracer injections than just global one.
// TODO(bplotka): Work with basictracer to handle gracefully tracker mismatches, and also with Prometheus to allow
Expand All @@ -156,8 +166,10 @@ func main() {
<-ctx.Done()
return ctx.Err()
}, func(error) {
if err := closeFn(); err != nil {
level.Warn(logger).Log("msg", "closing tracer failed", "err", err)
if closer != nil {
Copy link
Member

Choose a reason for hiding this comment

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

closer is never nil in this case, right?

if err := closer.Close(); err != nil {
level.Warn(logger).Log("msg", "closing tracer failed", "err", err)
}
}
cancel()
})
Expand Down
56 changes: 24 additions & 32 deletions docs/components/bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings to.
If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>). If 0 no
trace will be sent periodically, unless forced by
baggage item. See `pkg/tracing/tracing.go` for
details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag. Tracing
configuration in YAML.
--objstore.config-file=<bucket.config-yaml-path>
Path to YAML file that contains object store
configuration.
Expand Down Expand Up @@ -92,14 +90,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings to.
If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>). If 0 no
trace will be sent periodically, unless forced by
baggage item. See `pkg/tracing/tracing.go` for
details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag. Tracing
configuration in YAML.
--objstore.config-file=<bucket.config-yaml-path>
Path to YAML file that contains object store
configuration.
Expand Down Expand Up @@ -149,14 +145,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings to.
If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>). If 0 no
trace will be sent periodically, unless forced by
baggage item. See `pkg/tracing/tracing.go` for
details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag. Tracing
configuration in YAML.
--objstore.config-file=<bucket.config-yaml-path>
Path to YAML file that contains object store
configuration.
Expand Down Expand Up @@ -190,14 +184,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings to.
If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>). If 0
no trace will be sent periodically, unless forced
by baggage item. See `pkg/tracing/tracing.go` for
details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag. Tracing
configuration in YAML.
--objstore.config-file=<bucket.config-yaml-path>
Path to YAML file that contains object store
configuration.
Expand Down
14 changes: 6 additions & 8 deletions docs/components/compact.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings
to. If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>). If
0 no trace will be sent periodically, unless
forced by baggage item. See
`pkg/tracing/tracing.go` for details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag.
Tracing configuration in YAML.
--http-address="0.0.0.0:10902"
Listen host:port for HTTP endpoints.
--data-dir="./data" Data directory in which to cache blocks and
Expand Down
14 changes: 6 additions & 8 deletions docs/components/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings
to. If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>).
If 0 no trace will be sent periodically, unless
forced by baggage item. See
`pkg/tracing/tracing.go` for details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag.
Tracing configuration in YAML.
--http-address="0.0.0.0:10902"
Listen host:port for HTTP endpoints.
--grpc-address="0.0.0.0:10901"
Expand Down
14 changes: 6 additions & 8 deletions docs/components/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings
to. If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>).
If 0 no trace will be sent periodically, unless
forced by baggage item. See
`pkg/tracing/tracing.go` for details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag.
Tracing configuration in YAML.
--http-address="0.0.0.0:10902"
Listen host:port for HTTP endpoints.
--grpc-address="0.0.0.0:10901"
Expand Down
14 changes: 6 additions & 8 deletions docs/components/sidecar.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings
to. If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>).
If 0 no trace will be sent periodically, unless
forced by baggage item. See
`pkg/tracing/tracing.go` for details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag.
Tracing configuration in YAML.
--http-address="0.0.0.0:10902"
Listen host:port for HTTP endpoints.
--grpc-address="0.0.0.0:10901"
Expand Down
14 changes: 6 additions & 8 deletions docs/components/store.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ Flags:
--version Show application version.
--log.level=info Log filtering level.
--log.format=logfmt Log format to use.
--gcloudtrace.project=GCLOUDTRACE.PROJECT
GCP project to send Google Cloud Trace tracings
to. If empty, tracing will be disabled.
--gcloudtrace.sample-factor=1
How often we send traces (1/<sample-factor>).
If 0 no trace will be sent periodically, unless
forced by baggage item. See
`pkg/tracing/tracing.go` for details.
--tracing.config-file=<tracing.config-yaml-path>
Path to YAML file that contains tracing
configuration.
--tracing.config=<tracing.config-yaml>
Alternative to 'tracing.config-file' flag.
Tracing configuration in YAML.
--http-address="0.0.0.0:10902"
Listen host:port for HTTP endpoints.
--grpc-address="0.0.0.0:10901"
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ require (
github.com/gophercloud/gophercloud v0.0.0-20181206160319-9d88c34913a9
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117
github.com/hashicorp/go-sockaddr v1.0.0
github.com/hashicorp/go-version v1.2.0
github.com/hashicorp/golang-lru v0.5.1
github.com/julienschmidt/httprouter v1.1.0 // indirect
github.com/leanovate/gopter v0.2.4
Expand All @@ -31,13 +29,17 @@ require (
github.com/olekukonko/tablewriter v0.0.1
github.com/opentracing-contrib/go-stdlib v0.0.0-20170113013457-1de4cc2120e7
github.com/opentracing/basictracer-go v1.0.0
github.com/opentracing/opentracing-go v1.0.2
github.com/opentracing/opentracing-go v1.1.0
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/common v0.0.0-20181218105931-67670fe90761
github.com/prometheus/prometheus v0.0.0-20190328180107-4d60eb36dcbe
github.com/prometheus/tsdb v0.6.1
github.com/uber-go/atomic v1.4.0 // indirect
github.com/uber/jaeger-client-go v2.16.0+incompatible
github.com/uber/jaeger-lib v2.0.0+incompatible
go.opencensus.io v0.19.0 // indirect
go.uber.org/atomic v1.4.0 // indirect
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
Expand Down
Loading