Skip to content

Commit

Permalink
Support otlp trace exporter and current otel libraries (#102)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
greed42 committed Jan 20, 2023
1 parent bdac5b6 commit 1fd686a
Show file tree
Hide file tree
Showing 7 changed files with 662 additions and 463 deletions.
34 changes: 15 additions & 19 deletions cmd/geras/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"flag"
"fmt"
"net"
Expand All @@ -21,12 +22,13 @@ import (
"github.com/thanos-io/thanos/pkg/store/storepb"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
"golang.org/x/net/trace"
"google.golang.org/grpc"

"github.com/G-Research/geras/pkg/store"
"github.com/G-Research/geras/pkg/tracing"
"github.com/G-Research/opentsdb-goclient/config"

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

grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"

jaeger_propagator "go.opentelemetry.io/contrib/propagators/jaeger"
jaeger_exporter "go.opentelemetry.io/otel/exporters/trace/jaeger"
)

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

func initTracer() func() {
flush, err := jaeger_exporter.InstallNewPipeline(
jaeger_exporter.WithCollectorEndpoint(""),
jaeger_exporter.WithProcess(jaeger_exporter.Process{
ServiceName: "geras",
}),
jaeger_exporter.WithDisabled(true),
jaeger_exporter.WithDisabledFromEnv(),
ctx := context.Background()

shutdownTracing, err := tracing.SetProviderFromEnv(
ctx,
resource.WithAttributes(
semconv.ServiceNameKey.String("geras"),
semconv.ServiceNamespaceKey.String("github.com/G-Research"),
),
)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not initialize tracer: %s", err)
os.Exit(1)
}

otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(
jaeger_propagator.Jaeger{},
propagation.TraceContext{},
propagation.Baggage{},
))

return flush
return func() {
shutdownTracing(ctx)
}
}

func main() {
Expand Down
98 changes: 64 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,44 +1,74 @@
module github.com/G-Research/geras

go 1.17
go 1.18

require (
github.com/G-Research/opentsdb-goclient v0.0.0-20221228100032-d7678fe103e6
github.com/go-kit/kit v0.9.0
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/prometheus/prometheus v1.8.2-0.20190913102521-8ab628b35467 // v1.8.2 is misleading as Prometheus does not have v2 module.
github.com/thanos-io/thanos v0.7.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.16.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.16.0
go.opentelemetry.io/contrib/propagators v0.16.0
go.opentelemetry.io/otel v0.16.0
go.opentelemetry.io/otel/exporters/trace/jaeger v0.16.0
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102
google.golang.org/grpc v1.34.0
github.com/go-kit/kit v0.12.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.39.0
github.com/prometheus/prometheus v0.41.0
github.com/thanos-io/thanos v0.30.1
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.37.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.37.0
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/exporters/jaeger v1.8.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.11.2
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.11.2
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.11.2
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.11.2
go.opentelemetry.io/otel/sdk v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
golang.org/x/exp v0.0.0-20221212164502-fae10dda9338
golang.org/x/net v0.4.0
google.golang.org/grpc v1.51.0
)

require (
github.com/apache/thrift v0.13.0 // indirect
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/aws/aws-sdk-go v1.44.159 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 // indirect
github.com/prometheus/procfs v0.0.3 // indirect
go.opentelemetry.io/contrib v0.16.0 // indirect
go.opentelemetry.io/otel/sdk v0.16.0 // indirect
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 // indirect
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 // indirect
golang.org/x/text v0.3.4 // indirect
google.golang.org/api v0.36.0 // indirect
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e // indirect
google.golang.org/protobuf v1.25.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dennwc/varint v1.0.0 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/grafana/regexp v0.0.0-20221122212121-6b5c0a4cb7fd // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/stretchr/testify v1.8.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.11.2 // indirect
go.opentelemetry.io/otel/metric v0.34.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/goleak v1.2.0 // indirect
golang.org/x/oauth2 v0.3.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221207170731-23e4bf6bdc37 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 1fd686a

Please sign in to comment.