Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TOOLS_PKG_NAMES_CLEAN := $(shell grep -E $(TOOLS_MOD_REGEX) < $(TOOLS_MOD_DIR)/
TOOLS_BIN_NAMES := $(addprefix $(TOOLS_BIN_DIR)/, $(notdir $(TOOLS_PKG_NAMES_CLEAN)))

.PHONY: install-tools
install-tools: $(TOOLS_BIN_NAMES) $(POPULATE_IMAGES)
install-tools: $(TOOLS_BIN_NAMES) $(POPULATE_IMAGES) $(PROMLINTER)

$(TOOLS_BIN_DIR):
if [ ! -d $@ ]; then mkdir -p $@; fi
Expand All @@ -55,6 +55,8 @@ STRINGER := $(TOOLS_BIN_DIR)/stringer
WSL := $(TOOLS_BIN_DIR)/wsl
K3D := $(TOOLS_BIN_DIR)/k3d
POPULATE_IMAGES := $(TOOLS_BIN_DIR)/populate-images
PROMLINTER := $(TOOLS_BIN_DIR)/promlinter
GOMPLATE := $(TOOLS_BIN_DIR)/gomplate

.PHONY: $(POPULATE_IMAGES)
$(POPULATE_IMAGES):
Expand Down Expand Up @@ -222,3 +224,7 @@ deploy-experimental: manifests-experimental $(KUSTOMIZE) ## Deploy resources bas
.PHONY: undeploy-experimental
undeploy-experimental: $(KUSTOMIZE) ## Undeploy resources based on the development variant from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/development | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

.PHONY: update-metrics-docs
update-metrics-docs: $(PROMLINTER) $(GOMPLATE) # Update metrics documentation
@metrics=$$(mktemp).json; echo $${metrics}; $(PROMLINTER) list -ojson . > $${metrics}; $(GOMPLATE) -d telemetry=$${metrics} -f hack/telemetry-internal-metrics.md.tpl > docs/contributor/telemetry-internal-metrics.md
10 changes: 10 additions & 0 deletions docs/contributor/telemetry-internal-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- The table below was generated automatically -->
<!-- Please do not edit it directly. If you want to change it, please update the template and regenerate the file with make target update-metrics-docs -->
# Metrics Emitted by Kyma Telemetry Manager

| Metric | Description |
|-----------------------------------------------------------------|:----------------------------------------------------------------------------------------------|
| **telemetry_otelcol_metrics_compatibility_mode** | Indicates if the OpenTelemetry internal metrics compatibility mode is enabled (1) or disabled (0) |
| **telemetry_self_monitor_prober_in_flight_requests** | The current number of in-flight requests initiated by the self-monitoring prober. |
| **telemetry_self_monitor_prober_requests_total** | Total number of requests initiated by the self-monitoring prober. |
| **telemetry_self_monitor_prober_duration_seconds** | A histogram of latencies for requests initiated by the self-monitoring prober. |
9 changes: 9 additions & 0 deletions hack/telemetry-internal-metrics.md.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- The table below was generated automatically -->
<!-- Please do not edit it directly. If you want to change it, please update the template and regenerate the file with make target update-metrics-docs -->
# Metrics Emitted by Kyma Telemetry Manager

| Metric | Description |
|-----------------------------------------------------------------|:----------------------------------------------------------------------------------------------|
{{- range (ds "telemetry") }}
| **{{.Name}}** | {{.Help}} |
{{- end }}
4 changes: 4 additions & 0 deletions internal/reconciler/telemetry/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type Reconciler struct {
healthCheckers healthCheckers
overridesHandler OverridesHandler
selfMonitorApplierDeleter SelfMonitorApplierDeleter
metricsEmitter telemetryMetricsEmitter
}

func New(
Expand All @@ -98,6 +99,7 @@ func New(
},
overridesHandler: overridesHandler,
selfMonitorApplierDeleter: selfMonitorApplierDeleter,
metricsEmitter: NewTelemetryMetricsEmitter(),
}
}

Expand Down Expand Up @@ -129,6 +131,8 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
}
}

r.metricsEmitter.updateCompatibilityModeMetric(telemetryutils.GetCompatibilityModeFromTelemetry(ctx, r.Client, telemetry.Namespace))

requeue := telemetry.Status.State == operatorv1alpha1.StateWarning

return ctrl.Result{Requeue: requeue}, err
Expand Down
25 changes: 25 additions & 0 deletions internal/reconciler/telemetry/telemetry_metric_emitter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package telemetry

import (
"github.com/prometheus/client_golang/prometheus"
"sigs.k8s.io/controller-runtime/pkg/metrics"
)

var compatibilityModeGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "telemetry_otelcol_metrics_compatibility_mode",
Help: "Indicates if the OpenTelemetry internal metrics compatibility mode is enabled (1) or disabled (0)",
})

type telemetryMetricsEmitter struct{}

func NewTelemetryMetricsEmitter() telemetryMetricsEmitter {
metrics.Registry.MustRegister(compatibilityModeGauge)
return telemetryMetricsEmitter{}
}
func (e telemetryMetricsEmitter) updateCompatibilityModeMetric(compatibilityMode bool) {
if compatibilityMode {
compatibilityModeGauge.Set(1)
} else {
compatibilityModeGauge.Set(0)
}
}
Loading
Loading