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

.*: Add support for tracing with Lightstep #1678

Merged
merged 9 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Added

- [#1678](https://github.com/thanos-io/thanos/pull/1678) Add Lightstep as a tracing provider.
- [#1687](https://github.com/thanos-io/thanos/pull/1687) Add a new `--grpc-grace-period` CLI option to components which serve gRPC to set how long to wait until gRPC Server shuts down.
- [#1660](https://github.com/thanos-io/thanos/pull/1660) Add a new `--prometheus.ready_timeout` CLI option to the sidecar to set how long to wait until Prometheus starts up.
- [#1573](https://github.com/thanos-io/thanos/pull/1573) `AliYun OSS` object storage, see [documents](docs/storage.md#aliyun-oss) for further information.
Expand Down
19 changes: 19 additions & 0 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,22 @@ config:
service_version: ""
service_environment: ""
```

### Lightstep

Client for [Ligthstep](https://lightstep.com).

In order to configure Thanos to interact with Lightstep you need to provide at least an [access token](https://docs.lightstep.com/docs/create-and-use-access-tokens) in the configuration file. The `collector` key is optional and used when you have on-premise satellites.

[embedmd]:# (flags/config_tracing_lightstep.txt yaml)
```yaml
type: LIGHTSTEP
config:
access_token: ""
collector:
scheme: ""
host: ""
port: 0
plaintext: false
custom_ca_cert_file: ""
```
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/leanovate/gopter v0.2.4
github.com/lightstep/lightstep-tracer-go v0.18.0
github.com/lovoo/gcloud-opentracing v0.3.0
github.com/mattn/go-ieproxy v0.0.0-20191113090002-7c0f6868bffe // indirect
github.com/mattn/go-runewidth v0.0.6 // indirect
Expand Down
189 changes: 35 additions & 154 deletions go.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pkg/tracing/client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/thanos-io/thanos/pkg/tracing/elasticapm"
"github.com/thanos-io/thanos/pkg/tracing/jaeger"
"github.com/thanos-io/thanos/pkg/tracing/lightstep"
"github.com/thanos-io/thanos/pkg/tracing/stackdriver"
"gopkg.in/yaml.v2"
)
Expand All @@ -22,6 +23,7 @@ const (
STACKDRIVER TracingProvider = "STACKDRIVER"
JAEGER TracingProvider = "JAEGER"
ELASTIC_APM TracingProvider = "ELASTIC_APM"
LIGHTSTEP TracingProvider = "LIGHTSTEP"
)

type TracingConfig struct {
Expand Down Expand Up @@ -53,6 +55,8 @@ func NewTracer(ctx context.Context, logger log.Logger, metrics *prometheus.Regis
return jaeger.NewTracer(ctx, logger, metrics, config)
case string(ELASTIC_APM):
return elasticapm.NewTracer(config)
case string(LIGHTSTEP):
return lightstep.NewTracer(ctx, config)
default:
return nil, nil, errors.Errorf("tracing with type %s is not supported", tracingConf.Type)
}
Expand Down
57 changes: 57 additions & 0 deletions pkg/tracing/lightstep/lightstep.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package lightstep

import (
"context"
"io"

"github.com/lightstep/lightstep-tracer-go"
"github.com/opentracing/opentracing-go"
"gopkg.in/yaml.v2"
)

// Config - YAML configuration.
type Config struct {
antonio marked this conversation as resolved.
Show resolved Hide resolved
// AccessToken is the unique API key for your LightStep project. It is
// available on your account page at https://app.lightstep.com/account.
AccessToken string `yaml:"access_token"`

// Collector is the host, port, and plaintext option to use
// for the collector.
Collector lightstep.Endpoint `yaml:"collector"`
Copy link
Member

Choose a reason for hiding this comment

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

reusing config 👍 nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😄

}

// Tracer wraps the Lightstep tracer and the context.
type Tracer struct {
lightstep.Tracer
ctx context.Context
}

// Close synchronously flushes the Lightstep tracer, then terminates it.
func (t *Tracer) Close() error {
t.Tracer.Close(t.ctx)

return nil
}

// NewTracer creates a Tracer with the options present in the YAML config.
func NewTracer(ctx context.Context, yamlConfig []byte) (opentracing.Tracer, io.Closer, error) {
config := Config{}
if err := yaml.Unmarshal(yamlConfig, &config); err != nil {
return nil, nil, err
}

options := lightstep.Options{
AccessToken: config.AccessToken,
Collector: config.Collector,
}
lighstepTracer, err := lightstep.CreateTracer(options)
if err != nil {
return nil, nil, err
}

t := &Tracer{
lighstepTracer,
ctx,
}
return t, t, nil
}
2 changes: 2 additions & 0 deletions scripts/cfggen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
trclient "github.com/thanos-io/thanos/pkg/tracing/client"
"github.com/thanos-io/thanos/pkg/tracing/elasticapm"
"github.com/thanos-io/thanos/pkg/tracing/jaeger"
"github.com/thanos-io/thanos/pkg/tracing/lightstep"
"github.com/thanos-io/thanos/pkg/tracing/stackdriver"
kingpin "gopkg.in/alecthomas/kingpin.v2"
yaml "gopkg.in/yaml.v2"
Expand All @@ -42,6 +43,7 @@ var (
trclient.JAEGER: jaeger.Config{},
trclient.STACKDRIVER: stackdriver.Config{},
trclient.ELASTIC_APM: elasticapm.Config{},
trclient.LIGHTSTEP: lightstep.Config{},
}
)

Expand Down