-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.go
65 lines (55 loc) · 1.43 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
61
62
63
64
65
package otel
type Exporter string
const (
zipkinExp Exporter = "zipkin"
jaegerExp Exporter = "jaeger"
jaegerAgent Exporter = "jaeger_agent"
stdout Exporter = "stdout"
otlp Exporter = "otlp"
)
type Client string
const (
grpcClient Client = "grpc"
httpClient Client = "http"
)
type Config struct {
// Insecure endpoint (http)
Insecure bool `mapstructure:"insecure"`
// Compress - use gzip compression
Compress bool `mapstructure:"compress"`
// Exporter type, can be zipkin,stdout or otlp
Exporter Exporter `mapstructure:"exporter"`
// CustomURL to use to send spans, has effect only for the HTTP exporter
CustomURL string `mapstructure:"custom_url"`
// Client
Client Client `mapstructure:"client"`
// Endpoint to connect
Endpoint string `mapstructure:"endpoint"`
// ServiceName describes the service in the attributes
ServiceName string `mapstructure:"service_name"`
// ServiceVersion in semver format
ServiceVersion string `mapstructure:"service_version"`
// Headers for the otlp protocol
Headers map[string]string `mapstructure:"headers"`
}
func (c *Config) InitDefault() {
if c.Exporter == "" {
c.Exporter = otlp
}
if c.ServiceName == "" {
c.ServiceName = "RoadRunner"
}
if c.ServiceVersion == "" {
c.ServiceVersion = "1.0.0"
}
if c.Endpoint == "" {
// otlp default
c.Endpoint = "localhost:4318"
}
switch c.Client {
case grpcClient:
case httpClient:
default:
c.Client = httpClient
}
}