forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
32 lines (27 loc) · 1.05 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package collectdreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/collectdreceiver"
import (
"fmt"
"strings"
"time"
"go.opentelemetry.io/collector/config/confighttp"
)
// Config defines configuration for Collectd receiver.
type Config struct {
confighttp.ServerConfig `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct
Timeout time.Duration `mapstructure:"timeout"`
Encoding string `mapstructure:"encoding"`
AttributesPrefix string `mapstructure:"attributes_prefix"`
}
func (c *Config) Validate() error {
// CollectD receiver only supports JSON encoding. We expose a config option
// to make it explicit and obvious to the users.
if strings.ToLower(c.Encoding) != defaultEncodingFormat {
return fmt.Errorf(
"CollectD only support JSON encoding format. %s is not supported",
c.Encoding,
)
}
return nil
}