Skip to content

Commit

Permalink
[FSSDK-8823] sync with open telemetry go-sdk changes (#410)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pulak-opti authored Jan 19, 2024
1 parent f7dd7e2 commit 4c4dbd6
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 139 deletions.
39 changes: 19 additions & 20 deletions cmd/optimizely/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/****************************************************************************
* Copyright 2019,2022-2023 Optimizely, Inc. and contributors *
* Copyright 2019,2022-2024 Optimizely, Inc. and contributors *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
Expand All @@ -26,27 +26,9 @@ import (
"strings"
"syscall"

"gopkg.in/yaml.v2"

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"

"github.com/optimizely/agent/config"
"github.com/optimizely/agent/pkg/handlers"
"github.com/optimizely/agent/pkg/metrics"
"github.com/optimizely/agent/pkg/optimizely"
"github.com/optimizely/agent/pkg/routers"
"github.com/optimizely/agent/pkg/server"

// Initiate the loading of the interceptor plugins
_ "github.com/optimizely/agent/plugins/interceptors/all"

// Initiate the loading of the userprofileservice plugins
_ "github.com/optimizely/agent/plugins/userprofileservice/all"
// Initiate the loading of the odpCache plugins
_ "github.com/optimizely/agent/plugins/odpcache/all"
"github.com/optimizely/go-sdk/pkg/logging"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
Expand All @@ -56,6 +38,19 @@ import (
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
"go.opentelemetry.io/otel/trace"
"gopkg.in/yaml.v2"

"github.com/optimizely/agent/config"
"github.com/optimizely/agent/pkg/handlers"
"github.com/optimizely/agent/pkg/metrics"
"github.com/optimizely/agent/pkg/optimizely"
"github.com/optimizely/agent/pkg/routers"
"github.com/optimizely/agent/pkg/server"
_ "github.com/optimizely/agent/plugins/interceptors/all" // Initiate the loading of the userprofileservice plugins
_ "github.com/optimizely/agent/plugins/odpcache/all" // Initiate the loading of the odpCache plugins
_ "github.com/optimizely/agent/plugins/userprofileservice/all" // Initiate the loading of the interceptor plugins
"github.com/optimizely/go-sdk/pkg/logging"
)

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

sg := server.NewGroup(ctx, conf.Server) // Create a new server group to manage the individual http listeners
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry)
var tracer trace.Tracer
if conf.Tracing.Enabled {
tracer = otel.GetTracerProvider().Tracer(conf.Tracing.OpenTelemetry.ServiceName)
}
optlyCache := optimizely.NewCache(ctx, *conf, sdkMetricsRegistry, tracer)
optlyCache.Init(conf.SDKKeys)

// goroutine to check for signals to gracefully shutdown listeners
Expand Down
38 changes: 19 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/optimizely/agent

go 1.21.0
go 1.21.6

require (
github.com/go-chi/chi/v5 v5.0.8
Expand All @@ -10,44 +10,44 @@ require (
github.com/go-kit/kit v0.12.0
github.com/go-redis/redis/v8 v8.11.5
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/google/uuid v1.3.0
github.com/google/uuid v1.3.1
github.com/lestrrat-go/jwx v0.9.0
github.com/optimizely/go-sdk v1.8.4-0.20230911163718-b10e161e39b8
github.com/optimizely/go-sdk v1.8.4-0.20240118173841-4adb1affdb93
github.com/orcaman/concurrent-map v1.0.0
github.com/prometheus/client_golang v1.11.0
github.com/rakyll/statik v0.1.7
github.com/rs/zerolog v1.29.0
github.com/spf13/viper v1.15.0
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0
go.opentelemetry.io/otel/sdk v1.19.0
go.opentelemetry.io/otel/trace v1.19.0
golang.org/x/crypto v0.11.0
go.opentelemetry.io/otel v1.21.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0
go.opentelemetry.io/otel/sdk v1.21.0
go.opentelemetry.io/otel/trace v1.21.0
golang.org/x/crypto v0.14.0
golang.org/x/sync v0.3.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/net v0.12.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.2 // indirect
golang.org/x/net v0.17.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

Expand Down Expand Up @@ -79,8 +79,8 @@ require (
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4c4dbd6

Please sign in to comment.