Files
d04fab63ce [service] Move batchprocessor metrics to normal level and update level guidelines (#12525)
#### Description

This PR:
- requires "level: normal" before outputting batch processor metrics (in
addition to one specific metric which was already restricted to "level:
detailed")
- clarifies wording in the telemetry level guidelines and documentation,
and adds said guidelines to the requirements for stable components.

Some rationale for these changes can be found in the tracking issue and
[this
comment](https://github.com/open-telemetry/opentelemetry-collector/issues/7890#issuecomment-2684652956).

#### Link to tracking issue
Resolves #7890

#### To be discussed

Should we add a feature gate for this, in case a user relies on "level:
basic" outputting batch processor metrics? This feels like a niche use
case, so considering the "alpha" stability level of these metrics, I
don't think it's really necessary.

Considering batch processor metrics had already been switched to
"normal" once (#9767), but were turned back to basic at some later point
(not sure when), we might also want to add tests to avoid further
regressions (especially as the handling of telemetry levels is bound to
change further with #11754).

---------

Co-authored-by: Dmitrii Anoshin <[email protected]>
2025-03-04 15:57:23 +00:00

74 lines
1.7 KiB
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package configtelemetry // import "go.opentelemetry.io/collector/config/configtelemetry"
import (
"errors"
"fmt"
"strings"
)
const (
// LevelNone indicates that no telemetry should be collected.
LevelNone Level = iota - 1
// LevelBasic indicates that only core Collector telemetry should be collected.
LevelBasic
// LevelNormal indicates that all low-overhead telemetry should be collected.
LevelNormal
// LevelDetailed indicates that all available telemetry should be collected.
LevelDetailed
levelNoneStr = "None"
levelBasicStr = "Basic"
levelNormalStr = "Normal"
levelDetailedStr = "Detailed"
)
// Level is the level of internal telemetry (metrics, logs, traces about the component itself)
// that every component should generate.
type Level int32
func (l Level) String() string {
switch l {
case LevelNone:
return levelNoneStr
case LevelBasic:
return levelBasicStr
case LevelNormal:
return levelNormalStr
case LevelDetailed:
return levelDetailedStr
}
return ""
}
// MarshalText marshals Level to text.
func (l Level) MarshalText() (text []byte, err error) {
return []byte(l.String()), nil
}
// UnmarshalText unmarshalls text to a Level.
func (l *Level) UnmarshalText(text []byte) error {
if l == nil {
return errors.New("cannot unmarshal to a nil *Level")
}
str := strings.ToLower(string(text))
switch str {
case strings.ToLower(levelNoneStr):
*l = LevelNone
return nil
case strings.ToLower(levelBasicStr):
*l = LevelBasic
return nil
case strings.ToLower(levelNormalStr):
*l = LevelNormal
return nil
case strings.ToLower(levelDetailedStr):
*l = LevelDetailed
return nil
}
return fmt.Errorf("unknown metrics level %q", str)
}