Skip to content

Commit

Permalink
chore(otel): support OTEL_SDK_DISABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant committed Nov 4, 2024
1 parent 45b7084 commit abe8028
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/relayproxy/api/opentelemetry/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewOtelService() OtelService {
func (s *OtelService) Init(ctx context.Context, zapLog *zap.Logger, config config.Config) error {
// Require the endpoint to be set either by the openTelemetryOtlpEndpoint
// config element or otel.exporter.otlp.endpoint
if config.OpenTelemetryOtlpEndpoint == "" && config.OtelConfig.Exporter.Otlp.Endpoint == "" {
if (config.OpenTelemetryOtlpEndpoint == "" && config.OtelConfig.Exporter.Otlp.Endpoint == "") || config.OtelConfig.SDK.Disabled {
otel.SetTracerProvider(noop.NewTracerProvider())
return nil
}
Expand Down
1 change: 1 addition & 0 deletions cmd/relayproxy/api/opentelemetry/otel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func TestInit(t *testing.T) {

t.Run("disabled", func(t *testing.T) {
t.Setenv("OTEL_SDK_DISABLED", "true")
t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "https://example.com:4318")
f := pflag.NewFlagSet("config", pflag.ContinueOnError)
c, errC := config.New(f, zap.L(), "1.X.X")
require.NoError(t, errC)
Expand Down

0 comments on commit abe8028

Please sign in to comment.