15
15
package datadogexporter
16
16
17
17
import (
18
- "errors"
19
18
"fmt"
20
- "strings"
21
19
22
20
"go.opentelemetry.io/collector/config/configmodels"
23
21
)
24
22
25
- var (
26
- errUnsetAPIKey = errors .New ("the Datadog API key is unset" )
27
- )
28
-
29
- const (
30
- NoneMode = "none"
31
- AgentlessMode = "agentless"
32
- DogStatsDMode = "dogstatsd"
33
- )
34
-
35
- // APIConfig defines the API configuration options
36
- type APIConfig struct {
37
- // Key is the Datadog API key to associate your Agent's data with your organization.
38
- // Create a new API key here: https://app.datadoghq.com/account/settings
39
- Key string `mapstructure:"key"`
40
-
41
- // Site is the site of the Datadog intake to send data to.
42
- // The default value is "datadoghq.com".
43
- Site string `mapstructure:"site"`
44
- }
45
-
46
23
// DogStatsDConfig defines the DogStatsd related configuration
47
24
type DogStatsDConfig struct {
48
25
// Endpoint is the DogStatsD address.
@@ -54,22 +31,12 @@ type DogStatsDConfig struct {
54
31
Telemetry bool `mapstructure:"telemetry"`
55
32
}
56
33
57
- // AgentlessConfig defines the Agentless related configuration
58
- type AgentlessConfig struct {
59
- // Endpoint is the host of the Datadog intake server to send metrics to.
60
- // If unset, the value is obtained from the Site.
61
- Endpoint string `mapstructure:"endpoint"`
62
- }
63
-
64
34
// MetricsConfig defines the metrics exporter specific configuration options
65
35
type MetricsConfig struct {
66
36
// Namespace is the namespace under which the metrics are sent
67
37
// By default metrics are not namespaced
68
38
Namespace string `mapstructure:"namespace"`
69
39
70
- // Mode is the metrics sending mode: either 'dogstatsd' or 'agentless'
71
- Mode string `mapstructure:"mode"`
72
-
73
40
// Percentiles states whether to report percentiles for summary metrics,
74
41
// including the minimum and maximum
75
42
Percentiles bool `mapstructure:"report_percentiles"`
@@ -79,9 +46,6 @@ type MetricsConfig struct {
79
46
80
47
// DogStatsD defines the DogStatsD configuration options.
81
48
DogStatsD DogStatsDConfig `mapstructure:"dogstatsd"`
82
-
83
- // Agentless defines the Agentless configuration options.
84
- Agentless AgentlessConfig `mapstructure:"agentless"`
85
49
}
86
50
87
51
// TagsConfig defines the tag-related configuration
@@ -142,33 +106,12 @@ type Config struct {
142
106
143
107
TagsConfig `mapstructure:",squash"`
144
108
145
- // API defines the Datadog API configuration.
146
- API APIConfig `mapstructure:"api"`
147
-
148
109
// Metrics defines the Metrics exporter specific configuration
149
110
Metrics MetricsConfig `mapstructure:"metrics"`
150
111
}
151
112
152
113
// Sanitize tries to sanitize a given configuration
153
114
func (c * Config ) Sanitize () error {
154
-
155
- if c .Metrics .Mode != AgentlessMode && c .Metrics .Mode != DogStatsDMode {
156
- return fmt .Errorf ("Metrics mode '%s' is not recognized" , c .Metrics .Mode )
157
- }
158
-
159
- // Exactly one configuration for metrics must be set
160
- if c .Metrics .Mode == AgentlessMode {
161
- if c .API .Key == "" {
162
- return errUnsetAPIKey
163
- }
164
-
165
- c .API .Key = strings .TrimSpace (c .API .Key )
166
-
167
- // Set the endpoint based on the Site
168
- if c .Metrics .Agentless .Endpoint == "" {
169
- c .Metrics .Agentless .Endpoint = fmt .Sprintf ("https://api.%s" , c .API .Site )
170
- }
171
- }
172
-
115
+ // This will be useful on a future PR
173
116
return nil
174
117
}
0 commit comments