From 3ef6fc7d1a489411b05187a5d0a7db27f065b0e8 Mon Sep 17 00:00:00 2001 From: Pablo Baeyens Date: Mon, 24 Oct 2022 17:46:54 +0200 Subject: [PATCH] Move supportedLevels out of Validate method --- exporter/loggingexporter/config.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/exporter/loggingexporter/config.go b/exporter/loggingexporter/config.go index 12fe3415160..5741d498cc0 100644 --- a/exporter/loggingexporter/config.go +++ b/exporter/loggingexporter/config.go @@ -24,6 +24,16 @@ import ( "go.opentelemetry.io/collector/confmap" ) +var ( + // supportedLevels in this exporter's configuration. + // configtelemetry.LevelNone and other future values are not supported. + supportedLevels map[configtelemetry.Level]struct{} = map[configtelemetry.Level]struct{}{ + configtelemetry.LevelBasic: {}, + configtelemetry.LevelNormal: {}, + configtelemetry.LevelDetailed: {}, + } +) + // Config defines configuration for logging exporter. type Config struct { config.ExporterSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct @@ -89,14 +99,6 @@ func (cfg *Config) Unmarshal(conf *confmap.Conf) error { // Validate checks if the exporter configuration is valid func (cfg *Config) Validate() error { - // Supported configtelemetry.Level values for this exporter. - // configtelemetry.LevelNone and future values are not supported. - supportedLevels := map[configtelemetry.Level]struct{}{ - configtelemetry.LevelBasic: {}, - configtelemetry.LevelNormal: {}, - configtelemetry.LevelDetailed: {}, - } - if _, ok := supportedLevels[cfg.Verbosity]; !ok { return fmt.Errorf("verbosity level %q is not supported", cfg.Verbosity) }