-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
config.go
142 lines (122 loc) · 6.38 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package resourcedetectionprocessor // import "github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor"
import (
"go.opentelemetry.io/collector/config/confighttp"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/ec2"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/ecs"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/eks"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/elasticbeanstalk"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/aws/lambda"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/azure"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/azure/aks"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/consul"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/docker"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/gcp"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/heroku"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/k8snode"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/openshift"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/resourcedetectionprocessor/internal/system"
)
// Config defines configuration for Resource processor.
type Config struct {
// Detectors is an ordered list of named detectors that should be
// run to attempt to detect resource information.
Detectors []string `mapstructure:"detectors"`
// Override indicates whether any existing resource attributes
// should be overridden or preserved. Defaults to true.
Override bool `mapstructure:"override"`
// DetectorConfig is a list of settings specific to all detectors
DetectorConfig DetectorConfig `mapstructure:",squash"`
// HTTP client settings for the detector
// Timeout default is 5s
confighttp.ClientConfig `mapstructure:",squash"`
// Attributes is an allowlist of attributes to add.
// If a supplied attribute is not a valid attribute of a supplied detector it will be ignored.
// Deprecated: Please use detector's resource_attributes config instead
Attributes []string `mapstructure:"attributes"`
}
// DetectorConfig contains user-specified configurations unique to all individual detectors
type DetectorConfig struct {
// EC2Config contains user-specified configurations for the EC2 detector
EC2Config ec2.Config `mapstructure:"ec2"`
// ECSConfig contains user-specified configurations for the ECS detector
ECSConfig ecs.Config `mapstructure:"ecs"`
// EKSConfig contains user-specified configurations for the EKS detector
EKSConfig eks.Config `mapstructure:"eks"`
// Elasticbeanstalk contains user-specified configurations for the elasticbeanstalk detector
ElasticbeanstalkConfig elasticbeanstalk.Config `mapstructure:"elasticbeanstalk"`
// Lambda contains user-specified configurations for the lambda detector
LambdaConfig lambda.Config `mapstructure:"lambda"`
// Azure contains user-specified configurations for the azure detector
AzureConfig azure.Config `mapstructure:"azure"`
// Aks contains user-specified configurations for the aks detector
AksConfig aks.Config `mapstructure:"aks"`
// ConsulConfig contains user-specified configurations for the Consul detector
ConsulConfig consul.Config `mapstructure:"consul"`
// DockerConfig contains user-specified configurations for the docker detector
DockerConfig docker.Config `mapstructure:"docker"`
// GcpConfig contains user-specified configurations for the gcp detector
GcpConfig gcp.Config `mapstructure:"gcp"`
// HerokuConfig contains user-specified configurations for the heroku detector
HerokuConfig heroku.Config `mapstructure:"heroku"`
// SystemConfig contains user-specified configurations for the System detector
SystemConfig system.Config `mapstructure:"system"`
// OpenShift contains user-specified configurations for the Openshift detector
OpenShiftConfig openshift.Config `mapstructure:"openshift"`
// K8SNode contains user-specified configurations for the K8SNode detector
K8SNodeConfig k8snode.Config `mapstructure:"k8snode"`
}
func detectorCreateDefaultConfig() DetectorConfig {
return DetectorConfig{
EC2Config: ec2.CreateDefaultConfig(),
ECSConfig: ecs.CreateDefaultConfig(),
EKSConfig: eks.CreateDefaultConfig(),
ElasticbeanstalkConfig: elasticbeanstalk.CreateDefaultConfig(),
LambdaConfig: lambda.CreateDefaultConfig(),
AzureConfig: azure.CreateDefaultConfig(),
AksConfig: aks.CreateDefaultConfig(),
ConsulConfig: consul.CreateDefaultConfig(),
DockerConfig: docker.CreateDefaultConfig(),
GcpConfig: gcp.CreateDefaultConfig(),
HerokuConfig: heroku.CreateDefaultConfig(),
SystemConfig: system.CreateDefaultConfig(),
OpenShiftConfig: openshift.CreateDefaultConfig(),
K8SNodeConfig: k8snode.CreateDefaultConfig(),
}
}
func (d *DetectorConfig) GetConfigFromType(detectorType internal.DetectorType) internal.DetectorConfig {
switch detectorType {
case ec2.TypeStr:
return d.EC2Config
case ecs.TypeStr:
return d.ECSConfig
case eks.TypeStr:
return d.EKSConfig
case elasticbeanstalk.TypeStr:
return d.ElasticbeanstalkConfig
case lambda.TypeStr:
return d.LambdaConfig
case azure.TypeStr:
return d.AzureConfig
case aks.TypeStr:
return d.AksConfig
case consul.TypeStr:
return d.ConsulConfig
case docker.TypeStr:
return d.DockerConfig
case gcp.TypeStr:
return d.GcpConfig
case heroku.TypeStr:
return d.HerokuConfig
case system.TypeStr:
return d.SystemConfig
case openshift.TypeStr:
return d.OpenShiftConfig
case k8snode.TypeStr:
return d.K8SNodeConfig
default:
return nil
}
}