@@ -10,7 +10,40 @@ import (
10
10
"github.com/gitpod-io/observability/installer/pkg/common"
11
11
)
12
12
13
- var configMapData = `receivers:
13
+ const extraAttributesProcessor = "extraAttributes"
14
+
15
+ func configMap (ctx * common.RenderContext ) ([]runtime.Object , error ) {
16
+ var receiversConfig = buildReceiversConfig (ctx )
17
+ var processorsConfig = buildProcessorsConfig (ctx )
18
+ var exportersConfig = buildExportersConfig (ctx )
19
+ var extensionsConfig = buildExtensionsConfig (ctx )
20
+ var serviceConfig = buildServiceConfig (ctx )
21
+ var config = fmt .Sprintf (`%s
22
+ %s
23
+ %s
24
+ %s
25
+ %s` , receiversConfig , processorsConfig , exportersConfig , extensionsConfig , serviceConfig )
26
+
27
+ return []runtime.Object {
28
+ & corev1.ConfigMap {
29
+ TypeMeta : metav1.TypeMeta {
30
+ APIVersion : "v1" ,
31
+ Kind : "ConfigMap" ,
32
+ },
33
+ ObjectMeta : metav1.ObjectMeta {
34
+ Name : Name ,
35
+ Namespace : Namespace ,
36
+ Labels : common .Labels (Name , Component , App , Version ),
37
+ },
38
+ Data : map [string ]string {
39
+ "collector.yaml" : config ,
40
+ },
41
+ },
42
+ }, nil
43
+ }
44
+
45
+ func buildReceiversConfig (ctx * common.RenderContext ) string {
46
+ return `receivers:
14
47
jaeger:
15
48
protocols:
16
49
thrift_http:
@@ -19,44 +52,62 @@ var configMapData = `receivers:
19
52
protocols:
20
53
grpc: # on port 4317
21
54
http: # on port 4318
22
- exporters:
55
+ `
56
+ }
57
+
58
+ func buildProcessorsConfig (ctx * common.RenderContext ) string {
59
+ var processorsConfig = ""
60
+ if ctx .Config .Tracing .ExtraSpanAttributes != nil {
61
+ processorsConfig = fmt .Sprintf (`processors:
62
+ %s:
63
+ actions:` , extraAttributesProcessor )
64
+
65
+ var keyValueAttributeTemplate = `
66
+ - key: '%s'
67
+ value: %s
68
+ action: insert`
69
+ for key , value := range ctx .Config .Tracing .ExtraSpanAttributes {
70
+ processorsConfig += fmt .Sprintf (keyValueAttributeTemplate , key , value )
71
+ }
72
+ }
73
+
74
+ return processorsConfig
75
+ }
76
+
77
+ func buildExportersConfig (ctx * common.RenderContext ) string {
78
+ return fmt .Sprintf (`exporters:
23
79
otlp:
24
80
endpoint: "api.honeycomb.io:443"
25
81
headers:
26
82
"x-honeycomb-team": "%s"
27
- "x-honeycomb-dataset": "%s"
83
+ "x-honeycomb-dataset": "%s"` ,
84
+ ctx .Config .Tracing .HoneycombAPIKey , ctx .Config .Tracing .HoneycombDataset )
85
+ }
28
86
29
- extensions:
87
+ func buildExtensionsConfig (ctx * common.RenderContext ) string {
88
+ return `extensions:
30
89
health_check:
31
90
pprof:
32
- zpages:
33
- service:
91
+ zpages:`
92
+ }
93
+
94
+ func buildServiceConfig (ctx * common.RenderContext ) string {
95
+ var serviceTemplate = `service:
34
96
telemetry:
35
97
logs:
36
98
level: "debug"
37
99
extensions: [health_check, pprof, zpages]
38
100
pipelines:
39
101
traces:
40
- receivers: [jaeger, otlp]
41
- processors: [ ]
42
- exporters: ["otlp"]
102
+ receivers: [jaeger, otlp]
103
+ processors: [%s ]
104
+ exporters: ["otlp"]
43
105
`
106
+ var processors = ""
44
107
45
- func configMap (ctx * common.RenderContext ) ([]runtime.Object , error ) {
46
- return []runtime.Object {
47
- & corev1.ConfigMap {
48
- TypeMeta : metav1.TypeMeta {
49
- APIVersion : "v1" ,
50
- Kind : "ConfigMap" ,
51
- },
52
- ObjectMeta : metav1.ObjectMeta {
53
- Name : Name ,
54
- Namespace : Namespace ,
55
- Labels : common .Labels (Name , Component , App , Version ),
56
- },
57
- Data : map [string ]string {
58
- "collector.yaml" : fmt .Sprintf (configMapData , ctx .Config .Tracing .HoneycombAPIKey , ctx .Config .Tracing .HoneycombDataset ),
59
- },
60
- },
61
- }, nil
108
+ if ctx .Config .Tracing .ExtraSpanAttributes != nil {
109
+ processors = extraAttributesProcessor
110
+ }
111
+
112
+ return fmt .Sprintf (serviceTemplate , processors )
62
113
}
0 commit comments