fix: allow disabling trace export
This commit is contained in:
@@ -269,7 +269,7 @@ func Load(serviceName string) (Config, error) {
|
||||
AuthIssuerURL: stringEnv("AUTH_ISSUER_URL", "http://localhost:58180/realms/voice-local"),
|
||||
AuthJWKSURL: stringEnv("AUTH_JWKS_URL", "http://localhost:58180/realms/voice-local/protocol/openid-connect/certs"),
|
||||
AuthAudience: stringEnv("AUTH_AUDIENCE", "voice-platform-web"),
|
||||
OTLPEndpoint: stringEnv("OTEL_EXPORTER_OTLP_ENDPOINT", "localhost:54317"),
|
||||
OTLPEndpoint: stringEnvAllowEmpty("OTEL_EXPORTER_OTLP_ENDPOINT", "localhost:54317"),
|
||||
DependencyTimeout: dependencyTimeout,
|
||||
ExternalProbeInterval: externalProbeInterval,
|
||||
ShutdownTimeout: shutdownTimeout,
|
||||
@@ -703,6 +703,14 @@ func stringEnv(key, fallback string) string {
|
||||
return value
|
||||
}
|
||||
|
||||
func stringEnvAllowEmpty(key, fallback string) string {
|
||||
value, exists := os.LookupEnv(key)
|
||||
if !exists {
|
||||
return fallback
|
||||
}
|
||||
return strings.TrimSpace(value)
|
||||
}
|
||||
|
||||
func intEnv(key string, fallback int) (int, error) {
|
||||
value := strings.TrimSpace(os.Getenv(key))
|
||||
if value == "" {
|
||||
|
||||
@@ -27,6 +27,17 @@ func TestLoadUsesServicePortDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAllowsTracingExporterToBeDisabled(t *testing.T) {
|
||||
t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "")
|
||||
cfg, err := Load("api")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.OTLPEndpoint != "" {
|
||||
t.Fatalf("OTLPEndpoint = %q, want disabled exporter", cfg.OTLPEndpoint)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsInvalidDuration(t *testing.T) {
|
||||
t.Setenv("DEPENDENCY_TIMEOUT", "soon")
|
||||
if _, err := Load("api"); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user