Skip to content

Commit

Permalink
upgrade otel version, migrate from jaaeger to oltp
Browse files Browse the repository at this point in the history
Otel SDK is upgraded from 1.19 to 1.21
Jaeger exporter is deprecated in otel 1.20, in favor of otel exporter
Migrated jaeger to otel http exporter

Signed-off-by: Jayadeep KM <[email protected]>
  • Loading branch information
kmjayadeep committed Mar 5, 2024
1 parent a0546ed commit 987aa15
Show file tree
Hide file tree
Showing 120 changed files with 6,076 additions and 24,035 deletions.
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ require (
github.com/sigstore/sigstore/pkg/signature/kms/gcp v1.8.1
github.com/sigstore/sigstore/pkg/signature/kms/hashivault v1.8.1
go.opentelemetry.io/otel v1.24.0
go.opentelemetry.io/otel/exporters/jaeger v1.17.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0
go.opentelemetry.io/otel/sdk v1.24.0
go.opentelemetry.io/otel/trace v1.24.0
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
Expand Down Expand Up @@ -92,6 +92,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/kms v1.27.9 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.6 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand All @@ -107,7 +108,7 @@ require (
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
Expand All @@ -133,7 +134,9 @@ require (
github.com/zeebo/errs v1.3.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.1 // indirect
Expand Down
16 changes: 10 additions & 6 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 32 additions & 9 deletions pkg/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ package tracing

import (
"context"
"encoding/base64"
"fmt"
"net/url"

"github.com/tektoncd/pipeline/pkg/apis/config"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/embedded"
"go.opentelemetry.io/otel/trace/noop"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
Expand All @@ -35,15 +39,14 @@ import (
)

type tracerProvider struct {
embedded.TracerProvider

service string
provider trace.TracerProvider
cfg *config.Tracing
username string
password string
logger *zap.SugaredLogger
// (#7464)noop.TracerProvider is added to implement embedded.TracerProvider
// for bumping to go.opentelemetry.io/otel/trace/v1.21.0.TracerProvider
noop.TracerProvider
}

func init() {
Expand Down Expand Up @@ -150,12 +153,32 @@ func createTracerProvider(service string, cfg *config.Tracing, user, pass string
if !cfg.Enabled {
return noop.NewTracerProvider(), nil
}
u, err := url.Parse(cfg.Endpoint)
if err != nil {
return nil, err
}

opts := []otlptracehttp.Option{
otlptracehttp.WithEndpoint(u.Host),
otlptracehttp.WithURLPath(u.Path),
}

if u.Scheme == "http" {
opts = append(opts, otlptracehttp.WithInsecure())
}

if user != "" && pass != "" {
creds := fmt.Sprintf("%s:%s", user, pass)
enc := base64.StdEncoding.EncodeToString([]byte(creds))
o := otlptracehttp.WithHeaders(map[string]string{
"Authorization": fmt.Sprintf("Basic %s", enc),
})
opts = append(opts, o)
}

ctx := context.Background()
exp, err := otlptracehttp.New(ctx, opts...)

exp, err := jaeger.New(jaeger.WithCollectorEndpoint(
jaeger.WithEndpoint(cfg.Endpoint),
jaeger.WithUsername(user),
jaeger.WithPassword(pass),
))
if err != nil {
return nil, err
}
Expand Down
25 changes: 25 additions & 0 deletions vendor/github.com/cenkalti/backoff/v4/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/github.com/cenkalti/backoff/v4/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions vendor/github.com/cenkalti/backoff/v4/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions vendor/github.com/cenkalti/backoff/v4/backoff.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions vendor/github.com/cenkalti/backoff/v4/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 987aa15

Please sign in to comment.