forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
53 lines (41 loc) · 1.87 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package redisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver"
import (
"fmt"
"net"
"go.opentelemetry.io/collector/config/confignet"
"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/receiver/scraperhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/redisreceiver/internal/metadata"
)
type Config struct {
scraperhelper.ControllerConfig `mapstructure:",squash"`
// TODO: Use one of the configs from core.
// The target endpoint.
confignet.AddrConfig `mapstructure:",squash"`
// TODO allow users to add additional resource key value pairs?
// Optional username. Use the specified Username to authenticate the current connection
// with one of the connections defined in the ACL list when connecting
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
Username string `mapstructure:"username"`
// Optional password. Must match the password specified in the
// requirepass server configuration option, or the user's password when connecting
// to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
Password configopaque.String `mapstructure:"password"`
TLS configtls.ClientConfig `mapstructure:"tls,omitempty"`
MetricsBuilderConfig metadata.MetricsBuilderConfig `mapstructure:",squash"`
}
// configInfo holds configuration information to be used as resource/metrics attributes.
type configInfo struct {
Address string
Port string
}
func newConfigInfo(cfg *Config) (configInfo, error) {
address, port, err := net.SplitHostPort(cfg.Endpoint)
if err != nil {
return configInfo{}, fmt.Errorf("invalid endpoint %q: %w", cfg.Endpoint, err)
}
return configInfo{Address: address, Port: port}, nil
}