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