Skip to content

Commit 1fd686a

Browse files
authored
Support otlp trace exporter and current otel libraries (#102)
Configuration diverges from the environment specification, https://opentelemetry.io/docs/reference/specification/sdk-environment-variables/#exporter-selection, in that the default OTEL_TRACES_EXPORTER is none. This is to provide compatibility with the previous default and to avoid surprising infrastructure dependencies. Other changes in configuration are due to changes in the OpenTelemetry Jaeger exporter as of v0.20.0: https://github.com/open-telemetry/opentelemetry-go/releases/tag/v0.20.0. As it is deprecated, we will remove support for the Jaeger exporter in a future version. This is intended as a migration-enabling version to allow people to convert from jaeger to the otlp exporter.
1 parent bdac5b6 commit 1fd686a

File tree

7 files changed

+662
-463
lines changed

7 files changed

+662
-463
lines changed

cmd/geras/main.go

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"flag"
56
"fmt"
67
"net"
@@ -21,12 +22,13 @@ import (
2122
"github.com/thanos-io/thanos/pkg/store/storepb"
2223
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
2324
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
24-
"go.opentelemetry.io/otel"
25-
"go.opentelemetry.io/otel/propagation"
25+
"go.opentelemetry.io/otel/sdk/resource"
26+
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
2627
"golang.org/x/net/trace"
2728
"google.golang.org/grpc"
2829

2930
"github.com/G-Research/geras/pkg/store"
31+
"github.com/G-Research/geras/pkg/tracing"
3032
"github.com/G-Research/opentsdb-goclient/config"
3133

3234
_ "net/http/pprof"
@@ -36,9 +38,6 @@ import (
3638
opentsdb "github.com/G-Research/opentsdb-goclient/client"
3739

3840
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
39-
40-
jaeger_propagator "go.opentelemetry.io/contrib/propagators/jaeger"
41-
jaeger_exporter "go.opentelemetry.io/otel/exporters/trace/jaeger"
4241
)
4342

4443
func NewConfiguredLogger(format string, logLevel string) (log.Logger, error) {
@@ -107,26 +106,23 @@ func (i *multipleStringFlags) Set(value string) error {
107106
}
108107

109108
func initTracer() func() {
110-
flush, err := jaeger_exporter.InstallNewPipeline(
111-
jaeger_exporter.WithCollectorEndpoint(""),
112-
jaeger_exporter.WithProcess(jaeger_exporter.Process{
113-
ServiceName: "geras",
114-
}),
115-
jaeger_exporter.WithDisabled(true),
116-
jaeger_exporter.WithDisabledFromEnv(),
109+
ctx := context.Background()
110+
111+
shutdownTracing, err := tracing.SetProviderFromEnv(
112+
ctx,
113+
resource.WithAttributes(
114+
semconv.ServiceNameKey.String("geras"),
115+
semconv.ServiceNamespaceKey.String("github.com/G-Research"),
116+
),
117117
)
118118
if err != nil {
119119
fmt.Fprintf(os.Stderr, "Could not initialize tracer: %s", err)
120120
os.Exit(1)
121121
}
122122

123-
otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
124-
jaeger_propagator.Jaeger{},
125-
propagation.TraceContext{},
126-
propagation.Baggage{},
127-
))
128-
129-
return flush
123+
return func() {
124+
shutdownTracing(ctx)
125+
}
130126
}
131127

132128
func main() {

go.mod

+64-34
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,74 @@
11
module github.com/G-Research/geras
22

3-
go 1.17
3+
go 1.18
44

55
require (
66
github.com/G-Research/opentsdb-goclient v0.0.0-20221228100032-d7678fe103e6
7-
github.com/go-kit/kit v0.9.0
8-
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
9-
github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117
10-
github.com/pkg/errors v0.8.1
11-
github.com/prometheus/client_golang v1.1.0
12-
github.com/prometheus/common v0.6.0
13-
github.com/prometheus/prometheus v1.8.2-0.20190913102521-8ab628b35467 // v1.8.2 is misleading as Prometheus does not have v2 module.
14-
github.com/thanos-io/thanos v0.7.0
15-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.16.0
16-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0
17-
go.opentelemetry.io/contrib/propagators v0.16.0
18-
go.opentelemetry.io/otel v0.16.0
19-
go.opentelemetry.io/otel/exporters/trace/jaeger v0.16.0
20-
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102
21-
google.golang.org/grpc v1.34.0
7+
github.com/go-kit/kit v0.12.0
8+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
9+
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
10+
github.com/pkg/errors v0.9.1
11+
github.com/prometheus/client_golang v1.14.0
12+
github.com/prometheus/common v0.39.0
13+
github.com/prometheus/prometheus v0.41.0
14+
github.com/thanos-io/thanos v0.30.1
15+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0
16+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0
17+
go.opentelemetry.io/otel v1.11.2
18+
go.opentelemetry.io/otel/exporters/jaeger v1.8.0
19+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2
20+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2
21+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2
22+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2
23+
go.opentelemetry.io/otel/sdk v1.11.2
24+
go.opentelemetry.io/otel/trace v1.11.2
25+
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338
26+
golang.org/x/net v0.4.0
27+
google.golang.org/grpc v1.51.0
2228
)
2329

2430
require (
25-
github.com/apache/thrift v0.13.0 // indirect
31+
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
32+
github.com/aws/aws-sdk-go v1.44.159 // indirect
2633
github.com/beorn7/perks v1.0.1 // indirect
27-
github.com/cespare/xxhash v1.1.0 // indirect
28-
github.com/felixge/httpsnoop v1.0.1 // indirect
29-
github.com/go-logfmt/logfmt v0.4.0 // indirect
30-
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 // indirect
31-
github.com/golang/protobuf v1.4.3 // indirect
32-
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
33-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
34-
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
35-
github.com/prometheus/procfs v0.0.3 // indirect
36-
go.opentelemetry.io/contrib v0.16.0 // indirect
37-
go.opentelemetry.io/otel/sdk v0.16.0 // indirect
38-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
39-
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 // indirect
40-
golang.org/x/text v0.3.4 // indirect
41-
google.golang.org/api v0.36.0 // indirect
42-
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e // indirect
43-
google.golang.org/protobuf v1.25.0 // indirect
34+
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
35+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
36+
github.com/davecgh/go-spew v1.1.1 // indirect
37+
github.com/dennwc/varint v1.0.0 // indirect
38+
github.com/edsrzf/mmap-go v1.1.0 // indirect
39+
github.com/felixge/httpsnoop v1.0.3 // indirect
40+
github.com/go-kit/log v0.2.1 // indirect
41+
github.com/go-logfmt/logfmt v0.5.1 // indirect
42+
github.com/go-logr/logr v1.2.3 // indirect
43+
github.com/go-logr/stdr v1.2.2 // indirect
44+
github.com/gogo/protobuf v1.3.2 // indirect
45+
github.com/golang/protobuf v1.5.2 // indirect
46+
github.com/golang/snappy v0.0.4 // indirect
47+
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
48+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 // indirect
49+
github.com/jmespath/go-jmespath v0.4.0 // indirect
50+
github.com/jpillora/backoff v1.0.0 // indirect
51+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
52+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
53+
github.com/oklog/ulid v1.3.1 // indirect
54+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
55+
github.com/prometheus/client_model v0.3.0 // indirect
56+
github.com/prometheus/common/sigv4 v0.1.0 // indirect
57+
github.com/prometheus/procfs v0.8.0 // indirect
58+
github.com/rogpeppe/go-internal v1.9.0 // indirect
59+
github.com/stretchr/testify v1.8.1 // indirect
60+
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
61+
go.opentelemetry.io/otel/metric v0.34.0 // indirect
62+
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
63+
go.uber.org/atomic v1.10.0 // indirect
64+
go.uber.org/goleak v1.2.0 // indirect
65+
golang.org/x/oauth2 v0.3.0 // indirect
66+
golang.org/x/sync v0.1.0 // indirect
67+
golang.org/x/sys v0.3.0 // indirect
68+
golang.org/x/text v0.5.0 // indirect
69+
google.golang.org/appengine v1.6.7 // indirect
70+
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
71+
google.golang.org/protobuf v1.28.1 // indirect
72+
gopkg.in/yaml.v2 v2.4.0 // indirect
73+
gopkg.in/yaml.v3 v3.0.1 // indirect
4474
)

0 commit comments

Comments
 (0)