-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
config.go
32 lines (24 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 flinkmetricsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/flinkmetricsreceiver"
import (
"fmt"
"net/url"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/receiver/scraperhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/flinkmetricsreceiver/internal/metadata"
)
const defaultEndpoint = "http://localhost:8081"
// Config defines the configuration for the various elements of the receiver agent.
type Config struct {
scraperhelper.ControllerConfig `mapstructure:",squash"`
confighttp.ClientConfig `mapstructure:",squash"`
metadata.MetricsBuilderConfig `mapstructure:",squash"`
}
// Validate validates the configuration by checking for missing or invalid fields
func (cfg *Config) Validate() error {
if _, err := url.Parse(cfg.Endpoint); err != nil {
return fmt.Errorf("\"endpoint\" must be in the form of <scheme>://<hostname>:<port>: %w", err)
}
return nil
}