Debian Codegraph @

exporter/debugexporter/config.go

raw symbols SCIP
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package debugexporter // import "go.opentelemetry.io/collector/exporter/debugexporter"
5
6 import (
7 "fmt"
8
9 "go.opentelemetry.io/collector/component"
10 "go.opentelemetry.io/collector/config/configtelemetry"
11 "go.opentelemetry.io/collector/exporter/exporterhelper"
12 )
13
14 // supportedLevels in this exporter's configuration.
15 // configtelemetry.LevelNone and other future values are not supported.
16 var supportedLevels map[configtelemetry.Level]struct{} = map[configtelemetry.Level]struct{}{
17 configtelemetry.LevelBasic: {},
18 configtelemetry.LevelNormal: {},
19 configtelemetry.LevelDetailed: {},
20 }
21
22 // Config defines configuration for debug exporter.
23 type Config struct {
24 // Verbosity defines the debug exporter verbosity.
25 Verbosity configtelemetry.Level `mapstructure:"verbosity,omitempty"`
26
27 // SamplingInitial defines how many samples are initially logged during each second.
28 SamplingInitial int `mapstructure:"sampling_initial"`
29
30 // SamplingThereafter defines the sampling rate after the initial samples are logged.
31 SamplingThereafter int `mapstructure:"sampling_thereafter"`
32
33 // UseInternalLogger defines whether the exporter sends the output to the collector's internal logger.
34 UseInternalLogger bool `mapstructure:"use_internal_logger"`
35
36 QueueConfig exporterhelper.QueueBatchConfig `mapstructure:"sending_queue"`
37
38 // prevent unkeyed literal initialization
39 _ struct{}
40 }
41
42 var _ component.Config = (*Config)(nil)
43
44 // Validate checks if the exporter configuration is valid
45 func (cfg *Config) Validate() error {
46 if _, ok := supportedLevels[cfg.Verbosity]; !ok {
47 return fmt.Errorf("verbosity level %q is not supported", cfg.Verbosity)
48 }
49
50 return nil
51 }