-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Expand file tree
/
Copy pathconfig.go
More file actions
36 lines (30 loc) · 1.08 KB
/
config.go
File metadata and controls
36 lines (30 loc) · 1.08 KB
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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package ntpreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/ntpreceiver"
import (
"errors"
"fmt"
"net"
"time"
"go.opentelemetry.io/collector/scraper/scraperhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/ntpreceiver/internal/metadata"
)
// Config is the configuration for the NSX receiver
type Config struct {
scraperhelper.ControllerConfig `mapstructure:",squash"`
metadata.MetricsBuilderConfig `mapstructure:",squash"`
Version int `mapstructure:"version"`
Endpoint string `mapstructure:"endpoint"`
}
func (c *Config) Validate() error {
var errs []error
_, _, err := net.SplitHostPort(c.Endpoint)
if err != nil {
errs = append(errs, err)
}
// respect terms of service https://www.pool.ntp.org/tos.html
if c.CollectionInterval < 30*time.Minute {
errs = append(errs, fmt.Errorf("collection interval %v is less than minimum 30m", c.CollectionInterval))
}
return errors.Join(errs...)
}