Skip to content

Commit 1a9093c

Browse files
authored
Enable opentelemetry support for ETOS when deployed with Cluster spec (#401)
Add a new parameter to the cluster spec called openTelemetry where it is possible to pass in an enpoint and whether the endpoint is insecure or not. This is how we use opentelemetry so this is not a complete solution, but something to start with. ETOS does not deploy an opentelemetry collector, only passes the environment variables that the services use to connect and we expect the system engineers to deploy the collectors separately. I also removed the extra configuration that we could pass to the suite starter and suite runner since they are now redundant.
1 parent 25f2e05 commit 1a9093c

File tree

5 files changed

+63
-18
lines changed

5 files changed

+63
-18
lines changed

api/v1alpha1/cluster_types.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ type EventRepository struct {
6767
Ingress Ingress `json:"ingress"`
6868
}
6969

70+
// OpenTelemetry describes a deployment of an opentelemetry collector for ETOS to use.
71+
type OpenTelemetry struct {
72+
// Enable opentelemetry support, adding the environment variables to services.
73+
// +kubebuilder:default=false
74+
// +optional
75+
Enabled bool `json:"enabled"`
76+
77+
// Sets the OTEL_EXPORTER_OTLP_ENDPOINT environment variable
78+
// +kubebuilder:default="http://localhost:4317"
79+
// +optional
80+
Endpoint string `json:"endpoint"`
81+
82+
// Sets the OTEL_EXPORTER_OTLP_INSECURE environment variable
83+
// +kubebuilder:default="true"
84+
// +optional
85+
Insecure string `json:"insecure"`
86+
}
87+
7088
// MessageBus describes the deployment of messagesbuses for ETOS.
7189
type MessageBus struct {
7290
// +optional
@@ -121,18 +139,12 @@ type ETOSSuiteStarterConfig struct {
121139
// +kubebuilder:default="3600"
122140
// +optional
123141
TTL string `json:"ttl,omitempty"`
124-
// +kubebuilder:default=""
125-
// +optional
126-
ObservabilityConfigmapName string `json:"observabilityConfigmapName,omitempty"`
127142
// +kubebuilder:default="300"
128143
// +optional
129144
GracePeriod string `json:"gracePeriod,omitempty"`
130145
// +kubebuilder:default=""
131146
// +optional
132147
SidecarImage string `json:"sidecarImage,omitempty"`
133-
// +kubebuilder:default=""
134-
// +optional
135-
OTELCollectorHost string `json:"otelCollectorHost,omitempty"`
136148
}
137149

138150
// ETOSSuiteStarter describes the deployment of an ETOS suite starter.
@@ -266,6 +278,8 @@ type ClusterSpec struct {
266278
MessageBus MessageBus `json:"messageBus"`
267279
// +kubebuilder:default={}
268280
EventRepository EventRepository `json:"eventRepository"`
281+
// +kubebuilder:default={}
282+
OpenTelemetry OpenTelemetry `json:"openTelemetry"`
269283
}
270284

271285
// ClusterStatus defines the observed state of Cluster

api/v1alpha1/zz_generated.deepcopy.go

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/etos.eiffel-community.github.io_clusters.yaml

+22-6
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,6 @@ spec:
325325
gracePeriod:
326326
default: "300"
327327
type: string
328-
observabilityConfigmapName:
329-
default: ""
330-
type: string
331-
otelCollectorHost:
332-
default: ""
333-
type: string
334328
sidecarImage:
335329
default: ""
336330
type: string
@@ -693,11 +687,33 @@ spec:
693687
type: string
694688
type: object
695689
type: object
690+
openTelemetry:
691+
default: {}
692+
description: OpenTelemetry describes a deployment of an opentelemetry
693+
collector for ETOS to use.
694+
properties:
695+
enabled:
696+
default: false
697+
description: Enable opentelemetry support, adding the environment
698+
variables to services.
699+
type: boolean
700+
endpoint:
701+
default: http://localhost:4317
702+
description: Sets the OTEL_EXPORTER_OTLP_ENDPOINT environment
703+
variable
704+
type: string
705+
insecure:
706+
default: "true"
707+
description: Sets the OTEL_EXPORTER_OTLP_INSECURE environment
708+
variable
709+
type: string
710+
type: object
696711
required:
697712
- database
698713
- etos
699714
- eventRepository
700715
- messageBus
716+
- openTelemetry
701717
type: object
702718
status:
703719
description: ClusterStatus defines the observed state of Cluster

internal/etos/etos.go

+4
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ func (r *ETOSDeployment) config(name types.NamespacedName, cluster *etosv1alpha1
397397
if cluster.Spec.ETOS.Config.TestRunRetention.Success != nil {
398398
data["TESTRUN_SUCCESS_RETENTION"] = []byte(cluster.Spec.ETOS.Config.TestRunRetention.Success.Duration.String())
399399
}
400+
if cluster.Spec.OpenTelemetry.Enabled {
401+
data["OTEL_EXPORTER_OTLP_ENDPOINT"] = []byte(cluster.Spec.OpenTelemetry.Endpoint)
402+
data["OTEL_EXPORTER_OTLP_INSECURE"] = []byte(cluster.Spec.OpenTelemetry.Insecure)
403+
}
400404
if r.Config.Timezone != "" {
401405
data["TZ"] = []byte(r.Config.Timezone)
402406
}

internal/etos/suitestarter/suitestarter.go

+1-6
Original file line numberDiff line numberDiff line change
@@ -378,18 +378,13 @@ func (r *ETOSSuiteStarterDeployment) config(ctx context.Context, name types.Name
378378
"RABBITMQ_ROUTING_KEY": []byte(routingKey),
379379
"RABBITMQ_QUEUE": []byte(r.EiffelQueueName),
380380
}
381-
if r.Config.ObservabilityConfigmapName != "" {
382-
data["ETOS_OBSERVABILITY_CONFIGMAP"] = []byte(r.Config.ObservabilityConfigmapName)
383-
}
384381
if r.Config.SidecarImage != "" {
385382
data["ETOS_SIDECAR_IMAGE"] = []byte(r.Config.SidecarImage)
386383
}
387-
if r.Config.OTELCollectorHost != "" {
388-
data["OTEL_COLLECTOR_HOST"] = []byte(r.Config.OTELCollectorHost)
389-
}
390384
if r.EiffelQueueParams != "" {
391385
data["RABBITMQ_QUEUE_PARAMS"] = []byte(r.EiffelQueueParams)
392386
}
387+
393388
eiffel := &corev1.Secret{}
394389
if err := r.Get(ctx, types.NamespacedName{Name: r.rabbitmqSecret, Namespace: name.Namespace}, eiffel); err != nil {
395390
return nil, err

0 commit comments

Comments
 (0)