| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package 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 |
|
| 15 |
|
| 16 |
var supportedLevels map[configtelemetry.Level]struct{} = map[configtelemetry.Level]struct{}{ |
| 17 |
configtelemetry.LevelBasic: {}, |
| 18 |
configtelemetry.LevelNormal: {}, |
| 19 |
configtelemetry.LevelDetailed: {}, |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
type Config struct { |
| 24 |
|
| 25 |
Verbosity configtelemetry.Level `mapstructure:"verbosity,omitempty"` |
| 26 |
|
| 27 |
|
| 28 |
SamplingInitial int `mapstructure:"sampling_initial"` |
| 29 |
|
| 30 |
|
| 31 |
SamplingThereafter int `mapstructure:"sampling_thereafter"` |
| 32 |
|
| 33 |
|
| 34 |
UseInternalLogger bool `mapstructure:"use_internal_logger"` |
| 35 |
|
| 36 |
QueueConfig exporterhelper.QueueBatchConfig `mapstructure:"sending_queue"` |
| 37 |
|
| 38 |
|
| 39 |
_ struct{} |
| 40 |
} |
| 41 |
|
| 42 |
var _ component.Config = (*Config)(nil) |
| 43 |
|
| 44 |
|
| 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 |
} |