Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Authorization header to OTEL config (CORE-2291) #708

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configx/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ func (p *Provider) TracingConfig(serviceName string) *otelx.Config {
Sampling: otelx.OTLPSampling{
SamplingRatio: p.Float64("tracing.providers.otlp.sampling.sampling_ratio"),
},
AuthorizationHeader: p.String("tracing.providers.otlp.authorization_header"),
},
},
}
Expand Down
7 changes: 4 additions & 3 deletions otelx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ type ZipkinConfig struct {
}

type OTLPConfig struct {
ServerURL string `json:"server_url"`
Insecure bool `json:"insecure"`
Sampling OTLPSampling `json:"sampling"`
ServerURL string `json:"server_url"`
Insecure bool `json:"insecure"`
Sampling OTLPSampling `json:"sampling"`
AuthorizationHeader string `json:"authorization_header"`
}

type JaegerSampling struct {
Expand Down
4 changes: 4 additions & 0 deletions otelx/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
"examples": [0.4]
}
}
},
"authorization_header": {
"type": "string",
"examples": ["Bearer 2389s8fs9d8fus9f"]
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions otelx/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func SetupOTLP(t *Tracer, tracerName string, c *Config) (trace.Tracer, error) {
clientOpts = append(clientOpts, otlptracehttp.WithInsecure())
}

if c.Providers.OTLP.AuthorizationHeader != "" {
clientOpts = append(clientOpts,
otlptracehttp.WithHeaders(map[string]string{"Authorization": c.Providers.OTLP.AuthorizationHeader}),
)
}

exp, err := otlptrace.New(
ctx, otlptracehttp.NewClient(clientOpts...),
)
Expand Down
Loading