Skip to content

Commit 4c4dbd6

Browse files
authored
[FSSDK-8823] sync with open telemetry go-sdk changes (#410)
* sync with otel sdk changes * sync with otel sdk changes * update license header * update otel changes * update go dep * add trace context * fix license header * only pass traceconfig while trace enabled * refactor code
1 parent f7dd7e2 commit 4c4dbd6

File tree

14 files changed

+157
-139
lines changed

14 files changed

+157
-139
lines changed

cmd/optimizely/main.go

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/****************************************************************************
2-
* Copyright 2019,2022-2023 Optimizely, Inc. and contributors *
2+
* Copyright 2019,2022-2024 Optimizely, Inc. and contributors *
33
* *
44
* Licensed under the Apache License, Version 2.0 (the "License"); *
55
* you may not use this file except in compliance with the License. *
@@ -26,27 +26,9 @@ import (
2626
"strings"
2727
"syscall"
2828

29-
"gopkg.in/yaml.v2"
30-
3129
"github.com/rs/zerolog"
3230
"github.com/rs/zerolog/log"
3331
"github.com/spf13/viper"
34-
35-
"github.com/optimizely/agent/config"
36-
"github.com/optimizely/agent/pkg/handlers"
37-
"github.com/optimizely/agent/pkg/metrics"
38-
"github.com/optimizely/agent/pkg/optimizely"
39-
"github.com/optimizely/agent/pkg/routers"
40-
"github.com/optimizely/agent/pkg/server"
41-
42-
// Initiate the loading of the interceptor plugins
43-
_ "github.com/optimizely/agent/plugins/interceptors/all"
44-
45-
// Initiate the loading of the userprofileservice plugins
46-
_ "github.com/optimizely/agent/plugins/userprofileservice/all"
47-
// Initiate the loading of the odpCache plugins
48-
_ "github.com/optimizely/agent/plugins/odpcache/all"
49-
"github.com/optimizely/go-sdk/pkg/logging"
5032
"go.opentelemetry.io/otel"
5133
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
5234
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
@@ -56,6 +38,19 @@ import (
5638
"go.opentelemetry.io/otel/sdk/resource"
5739
sdktrace "go.opentelemetry.io/otel/sdk/trace"
5840
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
41+
"go.opentelemetry.io/otel/trace"
42+
"gopkg.in/yaml.v2"
43+
44+
"github.com/optimizely/agent/config"
45+
"github.com/optimizely/agent/pkg/handlers"
46+
"github.com/optimizely/agent/pkg/metrics"
47+
"github.com/optimizely/agent/pkg/optimizely"
48+
"github.com/optimizely/agent/pkg/routers"
49+
"github.com/optimizely/agent/pkg/server"
50+
_ "github.com/optimizely/agent/plugins/interceptors/all" // Initiate the loading of the userprofileservice plugins
51+
_ "github.com/optimizely/agent/plugins/odpcache/all" // Initiate the loading of the odpCache plugins
52+
_ "github.com/optimizely/agent/plugins/userprofileservice/all" // Initiate the loading of the interceptor plugins
53+
"github.com/optimizely/go-sdk/pkg/logging"
5954
)
6055

6156
// Version holds the admin version
@@ -271,7 +266,11 @@ func main() {
271266
ctx = context.WithValue(ctx, handlers.LoggerKey, &log.Logger)
272267

273268
sg := server.NewGroup(ctx, conf.Server) // Create a new server group to manage the individual http listeners
274-
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry)
269+
var tracer trace.Tracer
270+
if conf.Tracing.Enabled {
271+
tracer = otel.GetTracerProvider().Tracer(conf.Tracing.OpenTelemetry.ServiceName)
272+
}
273+
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry, tracer)
275274
optlyCache.Init(conf.SDKKeys)
276275

277276
// goroutine to check for signals to gracefully shutdown listeners

go.mod

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/optimizely/agent
22

3-
go 1.21.0
3+
go 1.21.6
44

55
require (
66
github.com/go-chi/chi/v5 v5.0.8
@@ -10,44 +10,44 @@ require (
1010
github.com/go-kit/kit v0.12.0
1111
github.com/go-redis/redis/v8 v8.11.5
1212
github.com/golang-jwt/jwt/v4 v4.5.0
13-
github.com/google/uuid v1.3.0
13+
github.com/google/uuid v1.3.1
1414
github.com/lestrrat-go/jwx v0.9.0
15-
github.com/optimizely/go-sdk v1.8.4-0.20230911163718-b10e161e39b8
15+
github.com/optimizely/go-sdk v1.8.4-0.20240118173841-4adb1affdb93
1616
github.com/orcaman/concurrent-map v1.0.0
1717
github.com/prometheus/client_golang v1.11.0
1818
github.com/rakyll/statik v0.1.7
1919
github.com/rs/zerolog v1.29.0
2020
github.com/spf13/viper v1.15.0
2121
github.com/stretchr/testify v1.8.4
22-
go.opentelemetry.io/otel v1.19.0
23-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
24-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0
25-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
26-
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0
27-
go.opentelemetry.io/otel/sdk v1.19.0
28-
go.opentelemetry.io/otel/trace v1.19.0
29-
golang.org/x/crypto v0.11.0
22+
go.opentelemetry.io/otel v1.21.0
23+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0
24+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0
25+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0
26+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0
27+
go.opentelemetry.io/otel/sdk v1.21.0
28+
go.opentelemetry.io/otel/trace v1.21.0
29+
golang.org/x/crypto v0.14.0
3030
golang.org/x/sync v0.3.0
3131
gopkg.in/yaml.v2 v2.4.0
3232
)
3333

3434
require (
3535
github.com/beorn7/perks v1.0.1 // indirect
3636
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
37-
github.com/go-logr/logr v1.2.4 // indirect
37+
github.com/go-logr/logr v1.3.0 // indirect
3838
github.com/go-logr/stdr v1.2.2 // indirect
3939
github.com/golang/protobuf v1.5.3 // indirect
4040
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
4141
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
4242
github.com/prometheus/client_model v0.2.0 // indirect
4343
github.com/prometheus/common v0.30.0 // indirect
4444
github.com/prometheus/procfs v0.7.3 // indirect
45-
go.opentelemetry.io/otel/metric v1.19.0 // indirect
45+
go.opentelemetry.io/otel/metric v1.21.0 // indirect
4646
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
47-
golang.org/x/net v0.12.0 // indirect
48-
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
49-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
50-
google.golang.org/grpc v1.58.2 // indirect
47+
golang.org/x/net v0.17.0 // indirect
48+
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
49+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
50+
google.golang.org/grpc v1.59.0 // indirect
5151
google.golang.org/protobuf v1.31.0 // indirect
5252
)
5353

@@ -79,8 +79,8 @@ require (
7979
github.com/stretchr/objx v0.5.0 // indirect
8080
github.com/subosito/gotenv v1.4.2 // indirect
8181
github.com/twmb/murmur3 v1.1.6 // indirect
82-
golang.org/x/sys v0.12.0 // indirect
83-
golang.org/x/text v0.11.0 // indirect
82+
golang.org/x/sys v0.14.0 // indirect
83+
golang.org/x/text v0.13.0 // indirect
8484
gopkg.in/ini.v1 v1.67.0 // indirect
8585
gopkg.in/yaml.v3 v3.0.1 // indirect
8686
)

0 commit comments

Comments
 (0)