Skip to content

Commit 1119e55

Browse files
Andrew Farriesroboquat
authored andcommitted
Add WebappTracingEnv function
Define it and WorkspaceTracingEnv in terms of a new `tracingEnv` function. `WorkspaceTracingEnv` and `WebappTracingEnv` pass the `*tracing` argument from the Workspace config and the WebApp config respectively.
1 parent 7363937 commit 1119e55

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

install/installer/pkg/common/common.go

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,32 @@ func DefaultEnv(cfg *config.Config) []corev1.EnvVar {
6363
}
6464

6565
func WorkspaceTracingEnv(context *RenderContext) (res []corev1.EnvVar) {
66+
var tracing *experimental.Tracing
67+
68+
_ = context.WithExperimental(func(cfg *experimental.Config) error {
69+
if cfg.Workspace != nil {
70+
tracing = cfg.Workspace.Tracing
71+
}
72+
return nil
73+
})
74+
75+
return tracingEnv(context, tracing)
76+
}
77+
78+
func WebappTracingEnv(context *RenderContext) (res []corev1.EnvVar) {
79+
var tracing *experimental.Tracing
80+
81+
_ = context.WithExperimental(func(cfg *experimental.Config) error {
82+
if cfg.WebApp != nil {
83+
tracing = cfg.WebApp.Tracing
84+
}
85+
return nil
86+
})
87+
88+
return tracingEnv(context, tracing)
89+
}
90+
91+
func tracingEnv(context *RenderContext, tracing *experimental.Tracing) (res []corev1.EnvVar) {
6692
if context.Config.Observability.Tracing == nil {
6793
res = append(res, corev1.EnvVar{Name: "JAEGER_DISABLED", Value: "true"})
6894
return
@@ -81,17 +107,14 @@ func WorkspaceTracingEnv(context *RenderContext) (res []corev1.EnvVar) {
81107
samplerType := experimental.TracingSampleTypeConst
82108
samplerParam := "1"
83109

84-
_ = context.WithExperimental(func(ucfg *experimental.Config) error {
85-
if ucfg.Workspace != nil && ucfg.Workspace.Tracing != nil {
86-
if ucfg.Workspace.Tracing.SamplerType != nil {
87-
samplerType = *ucfg.Workspace.Tracing.SamplerType
88-
}
89-
if ucfg.Workspace.Tracing.SamplerParam != nil {
90-
samplerParam = strconv.FormatFloat(*ucfg.Workspace.Tracing.SamplerParam, 'f', -1, 64)
91-
}
110+
if tracing != nil {
111+
if tracing.SamplerType != nil {
112+
samplerType = *tracing.SamplerType
92113
}
93-
return nil
94-
})
114+
if tracing.SamplerParam != nil {
115+
samplerParam = strconv.FormatFloat(*tracing.SamplerParam, 'f', -1, 64)
116+
}
117+
}
95118

96119
res = append(res,
97120
corev1.EnvVar{Name: "JAEGER_SAMPLER_TYPE", Value: string(samplerType)},

0 commit comments

Comments
 (0)