Skip to content

Commit

Permalink
Init local registry at runtime instead of config (#51074)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoShaka committed Jan 17, 2025
1 parent e559fbf commit f718ab8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 10 additions & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,15 @@ func NewTeleport(cfg *servicecfg.Config) (*TeleportProcess, error) {
"pid", fmt.Sprintf("%v.%v", os.Getpid(), processID),
)

// Use the custom metrics registry if specified, else create a new one.
// We must create the registry in NewTeleport, as opposed to ApplyConfig(),
// because some tests are running multiple Teleport instances from the same
// config.
metricsRegistry := cfg.MetricsRegistry
if metricsRegistry == nil {
metricsRegistry = prometheus.NewRegistry()
}

// If FIPS mode was requested make sure binary is build against BoringCrypto.
if cfg.FIPS {
if !modules.GetModules().IsBoringBinary() {
Expand Down Expand Up @@ -1083,7 +1092,7 @@ func NewTeleport(cfg *servicecfg.Config) (*TeleportProcess, error) {
keyPairs: make(map[keyPairKey]KeyPair),
cloudLabels: cloudLabels,
TracingProvider: tracing.NoopProvider(),
metricsRegistry: cfg.MetricsRegistry,
metricsRegistry: metricsRegistry,
}

process.registerExpectedServices(cfg)
Expand Down
4 changes: 0 additions & 4 deletions lib/service/servicecfg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,6 @@ func ApplyDefaults(cfg *Config) {
cfg.LoggerLevel = new(slog.LevelVar)
}

if cfg.MetricsRegistry == nil {
cfg.MetricsRegistry = prometheus.NewRegistry()
}

// Remove insecure and (borderline insecure) cryptographic primitives from
// default configuration. These can still be added back in file configuration by
// users, but not supported by default by Teleport. See #1856 for more
Expand Down

0 comments on commit f718ab8

Please sign in to comment.