-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathconfig.go
34 lines (26 loc) · 1.1 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package grafanacloudconnector // import "github.com/open-telemetry/opentelemetry-collector-contrib/connector/grafanacloudconnector"
import (
"fmt"
"time"
"go.opentelemetry.io/collector/component"
)
// Config defines the configuration options for the Grafana Cloud connector.
type Config struct {
// HostIdentifiers defines the list of resource attributes used to derive
// a unique `grafana.host.id` value. In most cases, this should be [ "host.id" ]
HostIdentifiers []string `mapstructure:"host_identifiers"`
MetricsFlushInterval time.Duration `mapstructure:"metrics_flush_interval"`
}
var _ component.ConfigValidator = (*Config)(nil)
// Validate checks if the configuration is valid
func (c Config) Validate() error {
if len(c.HostIdentifiers) == 0 {
return fmt.Errorf("at least one host identifier is required")
}
if c.MetricsFlushInterval > 5*time.Minute || c.MetricsFlushInterval < 15*time.Second {
return fmt.Errorf("%q is not a valid flush interval between 15s and 5m", c.MetricsFlushInterval)
}
return nil
}