Skip to content

Commit 51d21d7

Browse files
committed
refactor: use promexporter ApplyGenericEnvVars for shared config
1 parent 25f3eef commit 51d21d7

4 files changed

Lines changed: 8 additions & 16 deletions

File tree

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/gosnmp/gosnmp v1.42.1
1010
github.com/prometheus/client_golang v1.23.2
1111
github.com/stretchr/testify v1.11.1

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
@@ -106,22 +106,14 @@ func loadFromEnv() (*Config, error) {
106106
baseConfig.Metrics.Collection.DefaultInterval = promexporter_config.Duration{Duration: time.Second * 30}
107107
}
108108

109-
// Tracing configuration
110-
if enabledStr := os.Getenv("TRACING_ENABLED"); enabledStr != "" {
111-
enabled := enabledStr == "true"
112-
baseConfig.Tracing.Enabled = &enabled
113-
}
114-
115-
if serviceName := os.Getenv("TRACING_SERVICE_NAME"); serviceName != "" {
116-
baseConfig.Tracing.ServiceName = serviceName
117-
}
109+
config.BaseConfig = *baseConfig
118110

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

123-
config.BaseConfig = *baseConfig
124-
125117
// Printer configuration
126118
if host := os.Getenv("BROTHER_EXPORTER_PRINTER_HOST"); host != "" {
127119
config.Printer.Host = host

main

922 KB
Binary file not shown.

0 commit comments

Comments
 (0)