[chore] service: register process metrics unconditionally (#13777)

#### Description

Don't check the metrics level/readers before registering process
metrics. The registrations will be no-ops if metrics level is "none" or
there are no readers, in which case the overhead is negligible.

This is also necessary as part of
https://github.com/open-telemetry/opentelemetry-collector/issues/4970,
since the telemetry config will become opaque.

#### Link to tracking issue

Part of #4970

#### Testing

N/A

#### Documentation

N/A

---------

Co-authored-by: Pablo Baeyens <pablo.baeyens@datadoghq.com>
This commit is contained in:
Andrew Wilkins 2025-09-11 17:17:08 +08:00 committed by GitHub
parent 8b3a08ca2a
commit 855622f136
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 5 deletions

View File

@ -123,7 +123,6 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {
collectorConf: set.CollectorConf,
}
mpConfig := &cfg.Telemetry.Metrics.MeterProvider
telFactory := otelconftelemetry.NewFactory()
telset := telemetry.Settings{
BuildInfo: set.BuildInfo,
@ -190,10 +189,8 @@ func New(ctx context.Context, set Settings, cfg Config) (*Service, error) {
return nil, err
}
if cfg.Telemetry.Metrics.Level != configtelemetry.LevelNone && len(mpConfig.Readers) != 0 {
if err = proctelemetry.RegisterProcessMetrics(srv.telemetrySettings); err != nil {
return nil, fmt.Errorf("failed to register process metrics: %w", err)
}
if err := proctelemetry.RegisterProcessMetrics(srv.telemetrySettings); err != nil {
return nil, fmt.Errorf("failed to register process metrics: %w", err)
}
return srv, nil
}