/
config.go
60 lines (50 loc) · 1.83 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package correlation // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/correlation"
import (
"errors"
"net/url"
"time"
"go.opentelemetry.io/collector/config/confighttp"
conventions "go.opentelemetry.io/collector/semconv/v1.6.1"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/apm/correlations"
)
// DefaultConfig returns default configuration correlation values.
func DefaultConfig() *Config {
return &Config{
ClientConfig: confighttp.ClientConfig{Timeout: 5 * time.Second},
StaleServiceTimeout: 5 * time.Minute,
SyncAttributes: map[string]string{
conventions.AttributeK8SPodUID: conventions.AttributeK8SPodUID,
conventions.AttributeContainerID: conventions.AttributeContainerID,
},
Config: correlations.Config{
MaxRequests: 20,
MaxBuffered: 10_000,
MaxRetries: 2,
LogUpdates: false,
RetryDelay: 30 * time.Second,
CleanupInterval: 1 * time.Minute,
},
}
}
// Config defines configuration for correlation via traces.
type Config struct {
confighttp.ClientConfig `mapstructure:",squash"`
correlations.Config `mapstructure:",squash"`
// How long to wait after a trace span's service name is last seen before
// uncorrelating that service.
StaleServiceTimeout time.Duration `mapstructure:"stale_service_timeout"`
// SyncAttributes is a key of the span attribute name to sync to the dimension as the value.
SyncAttributes map[string]string `mapstructure:"sync_attributes"`
}
func (c *Config) validate() error {
if c.ClientConfig.Endpoint == "" {
return errors.New("`correlation.endpoint` not specified")
}
_, err := url.Parse(c.ClientConfig.Endpoint)
if err != nil {
return err
}
return nil
}