Skip to content

Commit cf4e826

Browse files
committed
feat: add support for OTLP headers and protocol in telemetry configuration
Signed-off-by: André Silva <[email protected]>
1 parent 1623d8a commit cf4e826

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

core/pkg/telemetry/builder.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ type CollectorConfig struct {
3838
KeyPath string
3939
ReloadInterval time.Duration
4040
CAPath string
41+
Headers string
42+
Protocol string
4143
}
4244

4345
// Config of the telemetry runtime. These are expected to be mapped to start-up arguments

flagd/cmd/start.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ func overrideOtelUri() string {
146146
return collectorUri
147147
}
148148

149+
func getOtelHeaders() string {
150+
return os.Getenv("OTEL_EXPORTER_OTLP_HEADERS")
151+
}
152+
153+
func getOtelProtocol() string {
154+
return os.Getenv("OTEL_EXPORTER_OTLP_PROTOCOL")
155+
}
156+
149157
// startCmd represents the start command
150158
var startCmd = &cobra.Command{
151159
Use: "start",
@@ -200,6 +208,8 @@ var startCmd = &cobra.Command{
200208

201209
var metricsExporter = overrideMetricsExporter()
202210
var collectorUri = overrideOtelUri()
211+
var otelHeaders = getOtelHeaders()
212+
var otelProtocol = getOtelProtocol()
203213

204214
// Build Runtime -----------------------------------------------------------
205215
rt, err := runtime.FromConfig(logger, Version, runtime.Config{
@@ -211,6 +221,8 @@ var startCmd = &cobra.Command{
211221
OtelCertPath: viper.GetString(otelCertPathFlagName),
212222
OtelKeyPath: viper.GetString(otelKeyPathFlagName),
213223
OtelReloadInterval: viper.GetDuration(otelReloadIntervalFlagName),
224+
OtelHeaders: otelHeaders,
225+
OtelProtocol: otelProtocol,
214226
OtelCAPath: viper.GetString(otelCAPathFlagName),
215227
ServiceCertPath: viper.GetString(serverCertPathFlagName),
216228
ServiceKeyPath: viper.GetString(serverKeyPathFlagName),

flagd/pkg/runtime/from_config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type Config struct {
3131
OtelCertPath string
3232
OtelKeyPath string
3333
OtelCAPath string
34+
OtelHeaders string
35+
OtelProtocol string
3436
OtelReloadInterval time.Duration
3537
ServiceCertPath string
3638
ServiceKeyPath string
@@ -59,6 +61,8 @@ func FromConfig(logger *logger.Logger, version string, config Config) (*Runtime,
5961
KeyPath: config.OtelKeyPath,
6062
CAPath: config.OtelCAPath,
6163
ReloadInterval: config.OtelReloadInterval,
64+
Headers: config.OtelHeaders,
65+
Protocol: config.OtelProtocol,
6266
},
6367
}
6468

@@ -105,9 +109,9 @@ func FromConfig(logger *logger.Logger, version string, config Config) (*Runtime,
105109

106110
// ofrep service
107111
ofrepService, err := ofrep.NewOfrepService(jsonEvaluator, config.CORS, ofrep.SvcConfiguration{
108-
Logger: logger.WithFields(zap.String("component", "OFREPService")),
109-
Port: config.OfrepServicePort,
110-
ServiceName: svcName,
112+
Logger: logger.WithFields(zap.String("component", "OFREPService")),
113+
Port: config.OfrepServicePort,
114+
ServiceName: svcName,
111115
MetricsRecorder: recorder,
112116
},
113117
config.ContextValues,

0 commit comments

Comments
 (0)