forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
61 lines (49 loc) · 2.06 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package rabbitmqexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/rabbitmqexporter"
import (
"errors"
"time"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/config/configtls"
)
type Config struct {
Connection ConnectionConfig `mapstructure:"connection"`
Routing RoutingConfig `mapstructure:"routing"`
EncodingExtensionID *component.ID `mapstructure:"encoding_extension"`
Durable bool `mapstructure:"durable"`
RetrySettings configretry.BackOffConfig `mapstructure:"retry_on_failure"`
}
type ConnectionConfig struct {
Endpoint string `mapstructure:"endpoint"`
VHost string `mapstructure:"vhost"`
TLSConfig *configtls.ClientConfig `mapstructure:"tls"`
Auth AuthConfig `mapstructure:"auth"`
ConnectionTimeout time.Duration `mapstructure:"connection_timeout"`
Heartbeat time.Duration `mapstructure:"heartbeat"`
PublishConfirmationTimeout time.Duration `mapstructure:"publish_confirmation_timeout"`
}
type RoutingConfig struct {
Exchange string `mapstructure:"exchange"`
RoutingKey string `mapstructure:"routing_key"`
}
type AuthConfig struct {
Plain PlainAuth `mapstructure:"plain"`
}
type PlainAuth struct {
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
}
var _ component.Config = (*Config)(nil)
// Validate checks if the exporter configuration is valid
func (cfg *Config) Validate() error {
if cfg.Connection.Endpoint == "" {
return errors.New("connection.endpoint is required")
}
// Password-less users are possible so only validate username
if cfg.Connection.Auth.Plain.Username == "" {
return errors.New("connection.auth.plain.username is required")
}
return nil
}