Skip to content

Commit

Permalink
feat(tracing): add OTLP headers config
Browse files Browse the repository at this point in the history
  • Loading branch information
rudineirk committed Sep 19, 2023
1 parent dc15e40 commit f44b815
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/flipt.schema.cue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ import "strings"

otlp?: {
endpoint?: string | *"localhost:4317"
headers?: [string]: string
}
}

Expand Down
4 changes: 4 additions & 0 deletions config/flipt.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,10 @@
"endpoint": {
"type": "string",
"default": "localhost:4317"
},
"headers": {
"type": "object",
"additionalProperties": { "type": "string" }
}
},
"title": "OTLP"
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func NewGRPCServer(
// TODO: support additional configuration options
client := otlptracegrpc.NewClient(
otlptracegrpc.WithEndpoint(cfg.Tracing.OTLP.Endpoint),
otlptracegrpc.WithHeaders(cfg.Tracing.OTLP.Headers),
// TODO: support TLS
otlptracegrpc.WithInsecure())
exp, err = otlptrace.New(ctx, client)
Expand Down
12 changes: 12 additions & 0 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ func TestLoad(t *testing.T) {
return cfg
},
},
{
name: "tracing otlp",
path: "./testdata/tracing/otlp.yml",
expected: func() *Config {
cfg := Default()
cfg.Tracing.Enabled = true
cfg.Tracing.Exporter = TracingOTLP
cfg.Tracing.OTLP.Endpoint = "http://localhost:9999"
cfg.Tracing.OTLP.Headers = map[string]string{"api-key": "test-key"}
return cfg
},
},
{
name: "database key/value",
path: "./testdata/database.yml",
Expand Down
7 changes: 7 additions & 0 deletions internal/config/testdata/tracing/otlp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tracing:
enabled: true
exporter: otlp
otlp:
endpoint: http://localhost:9999
headers:
api-key: test-key
3 changes: 2 additions & 1 deletion internal/config/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@ type ZipkinTracingConfig struct {
// OTLPTracingConfig contains fields, which configure
// OTLP span and tracing output destination.
type OTLPTracingConfig struct {
Endpoint string `json:"endpoint,omitempty" mapstructure:"endpoint"`
Endpoint string `json:"endpoint,omitempty" mapstructure:"endpoint"`
Headers map[string]string `json:"headers,omitempty" mapstructure:"headers"`
}

0 comments on commit f44b815

Please sign in to comment.