Skip to content

Commit 94c6836

Browse files
committed
refactor: use promexporter ApplyGenericEnvVars for shared config
1 parent 5183678 commit 94c6836

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.25
55
toolchain go1.25.3
66

77
require (
8-
github.com/d0ugal/promexporter v1.9.0
8+
github.com/d0ugal/promexporter v1.10.0
99
github.com/prometheus/client_golang v1.23.2
1010
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0
1111
go.opentelemetry.io/otel v1.38.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
1212
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
1313
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
1414
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
15-
github.com/d0ugal/promexporter v1.9.0 h1:QJMdv4yvxiFtWB6poGx2OCXfIscerXvtv4YiW3K18CY=
16-
github.com/d0ugal/promexporter v1.9.0/go.mod h1:432NOomztqyLDSFegVGKZshT521EI2L0POj0lrwYjig=
15+
github.com/d0ugal/promexporter v1.10.0 h1:WFZkEH3vNa7QHM/vUAvXSOIPBi/mBdUH8fwzkA8a83c=
16+
github.com/d0ugal/promexporter v1.10.0/go.mod h1:rs9hxA+4myUhhygHnu70IerD8p0Ym6UHPdAnk8n4+00=
1717
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1818
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1919
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

internal/config/config.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,14 @@ func loadFromEnv() (*Config, error) {
114114
baseConfig.Metrics.Collection.DefaultInterval = promexporter_config.Duration{Duration: time.Second * 30}
115115
}
116116

117-
// Tracing configuration
118-
if enabledStr := os.Getenv("TRACING_ENABLED"); enabledStr != "" {
119-
enabled := enabledStr == "true"
120-
baseConfig.Tracing.Enabled = &enabled
121-
}
122-
123-
if serviceName := os.Getenv("TRACING_SERVICE_NAME"); serviceName != "" {
124-
baseConfig.Tracing.ServiceName = serviceName
125-
}
117+
config.BaseConfig = *baseConfig
126118

127-
if endpoint := os.Getenv("TRACING_ENDPOINT"); endpoint != "" {
128-
baseConfig.Tracing.Endpoint = endpoint
119+
// Apply generic environment variables (TRACING_ENABLED, PROFILING_ENABLED, etc.)
120+
// These are handled by promexporter and are shared across all exporters
121+
if err := promexporter_config.ApplyGenericEnvVars(&config.BaseConfig); err != nil {
122+
return nil, fmt.Errorf("failed to apply generic environment variables: %w", err)
129123
}
130124

131-
config.BaseConfig = *baseConfig
132-
133125
// GitHub configuration
134126
if token := os.Getenv("GHCR_EXPORTER_GITHUB_TOKEN"); token != "" {
135127
config.GitHub.Token = promexporter_config.NewSensitiveString(token)

0 commit comments

Comments
 (0)