forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
31 lines (24 loc) · 1.03 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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package sqlserverreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver"
import (
"fmt"
"go.opentelemetry.io/collector/receiver/scraperhelper"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver/internal/metadata"
)
// Config defines configuration for a sqlserver receiver.
type Config struct {
scraperhelper.ControllerConfig `mapstructure:",squash"`
metadata.MetricsBuilderConfig `mapstructure:",squash"`
InstanceName string `mapstructure:"instance_name"`
ComputerName string `mapstructure:"computer_name"`
}
func (cfg *Config) Validate() error {
if cfg.InstanceName != "" && cfg.ComputerName == "" {
return fmt.Errorf("'instance_name' may not be specified without 'computer_name'")
}
if cfg.InstanceName == "" && cfg.ComputerName != "" {
return fmt.Errorf("'computer_name' may not be specified without 'instance_name'")
}
return nil
}