Skip to content

Commit

Permalink
feat: add Authorization header to OTEL config (CORE-2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
splaunov committed Aug 2, 2023
1 parent d608f03 commit 130acbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
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

0 comments on commit 130acbc

Please sign in to comment.