Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,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 @@ -1189,7 +1198,7 @@ func NewTeleport(cfg *servicecfg.Config) (*TeleportProcess, error) {
logger: cfg.Logger,
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 @@ -523,10 +523,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