Skip to content

Commit

Permalink
feat(self-monitoring): add support for self-monitoring
Browse files Browse the repository at this point in the history
This commit lays the foundation for self-monitoring:
1. Add a cluster-scoped Dash0OperatorConfiguration CRD, which contains a
   default endpoint and authorization setting, which will be used for
   self-monitoring.
2. When self-monitoring is enabled in the Dash0OperatorConfiguration
   resource, the controller deployment and the collector daemonset are
   extended with environment variables like OTEL_EXPORTER_OTLP_ENDPOINT
   etc., based on the operator configuration resource export settings.
3. On removal of the Dash0OperatorConfiguration resource, the same
   environment variables are removed from the controller deployment and
   collector daemonset.
4. Add metrics and tracing to the filelogoffsetsynch container via the
   Go OTel SDK. Other collector containers and the operator controller
   process will be extended with the Go OTel SDK in a later iteration.
5. Add a new end-to-end test for self-monitoring telemetry.
  • Loading branch information
mmanciop authored and basti1302 committed Sep 1, 2024
1 parent 1076aef commit 0a3e04e
Show file tree
Hide file tree
Showing 69 changed files with 4,925 additions and 752 deletions.
7 changes: 7 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ sonar.projectKey=dash0hq_dash0-operator
sonar.sources=.
sonar.tests=test
sonar.test.inclusions=**/*_test.go,test/**

# enables disabling Sonar rules
sonar.issue.ignore.multicriteria=e1

# Do not report the keyword TODO as an issue.
sonar.issue.ignore.multicriteria.e1.ruleKey=go:S1135
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.go
31 changes: 17 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ golangci-lint:

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
@echo --------------------------------
$(GOLANGCI_LINT) run
helm lint helm-chart/dash0-operator --set operator.disableSecretCheck=true --set operator.disableOtlpEndpointCheck=true

Expand Down Expand Up @@ -192,38 +193,40 @@ docker-build: \
docker-build-filelog-offset-synch ## Build all container images.

define build_container_image
$(eval $@IMAGE_REPOSITORY = $(1))
$(eval $@_IMAGE_REPOSITORY = $(1))
$(eval $@_IMAGE_TAG = $(2))
if [[ -n "${$@IMAGE_REPOSITORY}" ]]; then \
if [[ "${$@IMAGE_REPOSITORY}" = *"/"* ]]; then \
echo "not rebuilding the image ${$@IMAGE_REPOSITORY}, this looks like a remote image"; \
else \
$(CONTAINER_TOOL) build -t ${$@IMAGE_REPOSITORY}:${$@_IMAGE_TAG} .; \
fi; \
elif [[ -n "${OPERATOR_HELM_CHART_URL}" ]]; then \
echo "not rebuilding image, a remote Helm chart is used with the default image from the chart"; \
$(eval $@_CONTEXT = $(3))
if [[ -n "$($@_IMAGE_REPOSITORY)" ]]; then \
if [[ "$($@_IMAGE_REPOSITORY)" = *"/"* ]]; then \
echo "not rebuilding the image $($@_IMAGE_REPOSITORY), this looks like a remote image"; \
else \
echo $(CONTAINER_TOOL) build -t $($@_IMAGE_REPOSITORY):$($@_IMAGE_TAG) $($@_CONTEXT); \
$(CONTAINER_TOOL) build -t $($@_IMAGE_REPOSITORY):$($@_IMAGE_TAG) $($@_CONTEXT); \
fi; \
elif [[ -n "$(OPERATOR_HELM_CHART_URL)" ]]; then \
echo "not rebuilding image, a remote Helm chart is used with the default image from the chart"; \
fi
endef

.PHONY: docker-build-controller
docker-build-controller: ## Build the manager container image.
@$(call build_container_image,$(CONTROLLER_IMG_REPOSITORY),$(CONTROLLER_IMG_TAG))
@$(call build_container_image,$(CONTROLLER_IMG_REPOSITORY),$(CONTROLLER_IMG_TAG),".")

.PHONY: docker-build-instrumentation
docker-build-instrumentation: ## Build the instrumentation image.
@$(call build_container_image,$(INSTRUMENTATION_IMG_REPOSITORY),$(INSTRUMENTATION_IMG_TAG))
@$(call build_container_image,$(INSTRUMENTATION_IMG_REPOSITORY),$(INSTRUMENTATION_IMG_TAG),images/instrumentation)

.PHONY: docker-build-collector
docker-build-collector: ## Build the OpenTelemetry collector container image.
@$(call build_container_image,$(COLLECTOR_IMG_REPOSITORY),$(COLLECTOR_IMG_TAG))
@$(call build_container_image,$(COLLECTOR_IMG_REPOSITORY),$(COLLECTOR_IMG_TAG),images/collector)

.PHONY: docker-build-config-reloader
docker-build-config-reloader: ## Build the config reloader container image.
@$(call build_container_image,$(CONFIGURATION_RELOADER_IMG_REPOSITORY),$(CONFIGURATION_RELOADER_IMG_TAG))
@$(call build_container_image,$(CONFIGURATION_RELOADER_IMG_REPOSITORY),$(CONFIGURATION_RELOADER_IMG_TAG),images/configreloader)

.PHONY: docker-build-filelog-offset-synch
docker-build-filelog-offset-synch: ## Build the filelog offset synch container image.
@$(call build_container_image,$(FILELOG_OFFSET_SYNCH_IMG_REPOSITORY),$(FILELOG_OFFSET_SYNCH_IMG_TAG))
@$(call build_container_image,$(FILELOG_OFFSET_SYNCH_IMG_REPOSITORY),$(FILELOG_OFFSET_SYNCH_IMG_TAG),images/filelogoffsetsynch)

ifndef ignore-not-found
ignore-not-found = false
Expand Down
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ resources:
webhooks:
defaulting: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: false
controller: true
domain: dash0.com
group: operator
kind: Dash0OperatorConfiguration
path: github.com/dash0hq/dash0-operator/api/dash0monitoring/v1alpha1
version: v1alpha1
version: "3"
34 changes: 34 additions & 0 deletions api/dash0monitoring/resource_interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
// SPDX-License-Identifier: Apache-2.0

package dash0monitoring

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type Dash0Resource interface {
GetResourceTypeName() string
GetNaturalLanguageResourceTypeName() string
Get() client.Object
GetName() string
GetUid() types.UID
GetCreationTimestamp() metav1.Time
GetReceiver() client.Object
GetListReceiver() client.ObjectList
IsClusterResource() bool
RequestToName(ctrl.Request) string

IsAvailable() bool
SetAvailableConditionToUnknown()
EnsureResourceIsMarkedAsAvailable()
EnsureResourceIsMarkedAsDegraded(string, string)
EnsureResourceIsMarkedAsAboutToBeDeleted()
IsMarkedForDeletion() bool

Items(client.ObjectList) []client.Object
At(client.ObjectList, int) Dash0Resource
}
Loading

0 comments on commit 0a3e04e

Please sign in to comment.