-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
124 lines (104 loc) · 3.57 KB
/
options.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package telemetry
import (
"go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp"
"go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp"
"go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
"go.opentelemetry.io/otel/exporters/stdout/stdouttrace"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/sdk/metric"
"github.com/x-ethr/telemetry/types"
)
type Zipkin struct {
// URL - Zipkin collector url - defaults to "http://opentelemetry-collector.observability.svc.cluster.local:9441".
URL string
// Enabled will enable the Zipkin collector. Default is true.
Enabled bool
}
type Tracer struct {
// Options represents [otlptracehttp.Option] configurations.
//
// Defaults:
//
// - otlptracehttp.WithInsecure()
// - otlptracehttp.WithEndpoint("opentelemetry-collector.observability.svc.cluster.local:4318")
Options []otlptracehttp.Option
// Debugger configures an additional [stdouttrace.Exporter] if not nil. Defaults nil.
Debugger *stdouttrace.Exporter
// Local will prevent an external tracer from getting used as a provider. If true, forces [Tracer.Debugger] configuration. Default is false.
Local bool
}
type Metrics struct {
// Options represents [otlpmetrichttp.Option] configurations.
//
// Defaults:
//
// - otlpmetrichttp.WithInsecure()
// - otlpmetrichttp.WithEndpoint("opentelemetry-collector.observability.svc.cluster.local:4318")
Options []otlpmetrichttp.Option
// Debugger configures an additional [metric.Exporter] if not nil. Defaults nil.
Debugger metric.Exporter
// Local will prevent an external metrics provider from getting used. If true, forces [Metrics.Debugger] configuration. Default is false.
Local bool
}
type Logs struct {
// Logs represents [otlploghttp.Option] configurations.
//
// Defaults:
//
// - otlploghttp.WithInsecure()
// - otlploghttp.WithEndpoint("http://zipkin.istio-system.svc.cluster.local:9411")
Options []otlploghttp.Option
// Debugger configures an additional [stdoutlog.Exporter] if not nil. Defaults nil.
Debugger *stdoutlog.Exporter
// Local will prevent an external log exporter from getting used as a processor. If true, forces [Logs.Debugger] configuration. Default is false.
Local bool
}
type Settings struct {
// Zipkin represents a zipkin collector.
Zipkin *Zipkin
// Tracer represents [otlptracehttp.Option] configurations.
Tracer *Tracer
// Metrics represents [otlpmetrichttp.Option] configurations.
Metrics *Metrics
// Logs represents [otlploghttp.Option] configurations.
Logs *Logs
// Propagators ...
//
// Defaults:
//
// - [propagation.TraceContext]
// - [propagation.Baggage]
Propagators []propagation.TextMapPropagator
}
type Variadic types.Variadic[Settings]
func Options() *Settings {
return &Settings{
Zipkin: &Zipkin{
URL: "http://zipkin.istio-system.svc.cluster.local:9411",
Enabled: true,
},
Metrics: &Metrics{
Options: []otlpmetrichttp.Option{
otlpmetrichttp.WithInsecure(),
otlpmetrichttp.WithEndpoint("opentelemetry-collector.observability.svc.cluster.local:4318"),
},
},
Tracer: &Tracer{
Options: []otlptracehttp.Option{
otlptracehttp.WithInsecure(),
otlptracehttp.WithEndpoint("opentelemetry-collector.observability.svc.cluster.local:4318"),
},
},
Logs: &Logs{
Options: []otlploghttp.Option{
otlploghttp.WithInsecure(),
otlploghttp.WithEndpoint("opentelemetry-collector.observability.svc.cluster.local:4318"),
},
},
Propagators: []propagation.TextMapPropagator{
propagation.TraceContext{},
propagation.Baggage{},
},
}
}