metrics

package
v0.7.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

README

pkg/metrics

metrics registers all Prometheus metrics for the Orkestra runtime. All metrics are registered at package init via promauto — importing the package is sufficient to make them available at /metrics.

Each file owns one domain of metrics. Recording functions are the only public API; the underlying prometheus.Counter / Gauge / Histogram variables are unexported.

Metric domains

File Metric prefix What it tracks
autoscale.go orkestra_autoscale_* Worker count overrides and baseline restores per CRD
deletion_protection.go orkestra_deletion_protection_* Webhook admission decisions (allowed/denied)
external.go orkestra_external_call_* External HTTP API calls made during reconciliation
docker.go orkestra_docker_* Docker build/push operations triggered by reconcilers
git.go orkestra_git_* Git operations (clone, pull, push) triggered by reconcilers

Recording pattern

Each file exposes named Record* or Set* functions — callers never reference the underlying metric vars:

// After an external API call:
metrics.RecordExternalCall(crd, name, url, duration.Seconds(), errStr, statusCode)

// When the autoscaler applies an override:
metrics.RecordAutoscaleOverride(crd, workerCount)

// When the autoscaler restores the baseline:
metrics.RecordAutoscaleRestore(crd, baselineWorkers)

Labels

Most metrics carry a crd label (the CRD name as registered in the Katalog) so that Grafana panels can filter per operator. The external.go and docker.go metrics additionally carry name (the resource name) and url / image for per-call granularity.

Adding new metrics

Add a new file (e.g. queue.go) that:

  1. Declares metric vars with promauto.New* at package level
  2. Exports Record* / Set* / Observe* helpers
  3. Does not export the underlying prometheus.* vars

The promauto registration happens at init automatically — no registration call needed.

Documentation

Overview

pkg/metrics/autoscale.go

pkg/metrics/deletion_protection.go

pkg/metrics/namespace_protection.go

pkg/metrics/webhook_reconciliation.go

Index

Constants

View Source
const (
	// MetricSourceAdmission labels metrics originating from /validate or /mutate calls.
	MetricSourceAdmission = "admission"

	// MetricSourceReconcile labels metrics originating from the reconcile loop.
	MetricSourceReconcile = "reconcile"
)

Variables

This section is empty.

Functions

func DecConversionRequests

func DecConversionRequests()

DecConversionRequests decrements the in-flight conversion request gauge.

func IncConversionRequests

func IncConversionRequests()

IncConversionRequests increments the in-flight conversion request gauge.

func InitAutoscaleBaseline

func InitAutoscaleBaseline(crd string, workers int)

InitAutoscaleBaseline records the initial worker count at startup. Called once per operatorBox: when the autoscaler is started.

func ObserveCRDActivationLatency

func ObserveCRDActivationLatency(crd string, seconds float64)

ObserveCRDActivationLatency records how long a CRD took to become active.

func ObserveConversionDuration

func ObserveConversionDuration(kind, fromVersion, toVersion string, seconds float64)

ObserveConversionDuration records a conversion duration observation.

func ObserveProviderDuration

func ObserveProviderDuration(crd, provider, kind string, seconds float64)

ObserveProviderDuration records how long a provider reconcile call took.

func ObserveReconcileDuration

func ObserveReconcileDuration(gvk string, seconds float64)

ObserveReconcileDuration records a reconcile duration observation.

func RecordAutoscaleOverride

func RecordAutoscaleOverride(crd string, workers int)

RecordAutoscaleOverride records a scale override event.

func RecordAutoscaleRestore

func RecordAutoscaleRestore(crd string, baselineWorkers int)

RecordAutoscaleRestore records a baseline restore event.

func RecordCRDActivation

func RecordCRDActivation(crd, result string)

RecordCRDActivation increments the CRD activation counter.

func RecordConversion

func RecordConversion(kind, fromVersion, toVersion, result string)

RecordConversion increments the conversion request counter.

func RecordConversionError

func RecordConversionError(kind, errorType string)

RecordConversionError increments the conversion error counter.

func RecordDeletionProtectionBlocked

func RecordDeletionProtectionBlocked(resource string)

RecordDeletionProtectionBlocked increments the blocked deletion counter. resource is the CRD full name (e.g. "pipelines.platform.io") or "orkestra-deployment" when the Orkestra deployment itself was protected.

func RecordDockerOperation

func RecordDockerOperation(crd, image, operation, err string, durationSeconds float64)

RecordDockerOperation records a Docker operation result and duration.

func RecordExternalCall

func RecordExternalCall(crd, name, url string, durationSeconds float64, err string, statusCode int)

RecordExternalCall is a convenience helper for recording metrics after an external call.

func RecordGitOperation

func RecordGitOperation(crd, repo, operation, err string, durationSeconds float64)

RecordGitOperation records a Git operation result and duration.

func RecordMutationDurationSeconds

func RecordMutationDurationSeconds(crd string, seconds float64)

RecordMutationDurationSeconds observes the duration of a /mutate call.

func RecordMutationFieldApplied

func RecordMutationFieldApplied(crd, field, mutationType, source string)

RecordMutationFieldApplied increments the per-field mutation counter.

func RecordMutationFieldDetail

func RecordMutationFieldDetail(crd, field, mutationType string)

RecordMutationFieldDetail increments the per-field reconcile-time mutation counter.

func RecordMutationOutcome

func RecordMutationOutcome(crd, result, source string)

RecordMutationOutcome increments the aggregate mutation counter.

func RecordMutationTotal

func RecordMutationTotal(crd string)

RecordMutationTotal increments the reconcile-time mutation counter for a CRD.

func RecordNamespaceProtectionBlocked added in v0.1.9

func RecordNamespaceProtectionBlocked(resource string)

RecordNamespaceProtectionBlocked increments the blocked namespace protection counter. resource is the CRD plural name (e.g. "pipelines") of the resource that was blocked.

func RecordProviderDelete

func RecordProviderDelete(crd, provider, kind, result string)

RecordProviderDelete increments the provider delete counter.

func RecordProviderReconcile

func RecordProviderReconcile(crd, provider, kind, result string)

RecordProviderReconcile increments the provider reconcile counter. Call after each provider.Reconcile() or provider.Delete() returns.

func RecordReconcile

func RecordReconcile(gvk, result string)

RecordReconcile increments the reconcile counter for a CRD.

func RecordValidationDurationSeconds

func RecordValidationDurationSeconds(crd string, seconds float64)

RecordValidationDurationSeconds observes the duration of a /validate call. Only call this for source=admission — reconcile durations use a different histogram.

func RecordValidationOutcome

func RecordValidationOutcome(crd, result, source string)

RecordValidationOutcome increments the aggregate validation counter.

func RecordValidationViolation

func RecordValidationViolation(crd, field, rule, action, source string)

RecordValidationViolation increments the per-field violation counter.

func RecordWebhookReconciled

func RecordWebhookReconciled(webhookType string)

RecordWebhookReconciled increments the reconciliation counter for a webhook type. webhookType is one of:

  • "validating"
  • "mutating"
  • "deletion-protection"

func RecordWebhookReconciliationFailure

func RecordWebhookReconciliationFailure(webhookType string)

RecordWebhookReconciliationFailure increments the failure counter for a webhook type.

func SetAutoscaleActive

func SetAutoscaleActive(crd string, active bool)

SetAutoscaleActive records an active state change.

func SetQueueDepth

func SetQueueDepth(gvk string, depth float64)

SetQueueDepth sets the queue depth gauge for a CRD.

func SetResourceCount

func SetResourceCount(gvk string, count float64)

SetResourceCount sets the resource count gauge for a CRD.

func SetWorkersIdle

func SetWorkersIdle(gvk string, value float64)

func SetWorkersProcessing

func SetWorkersProcessing(gvk string, value float64)

func SetWorkersTotal

func SetWorkersTotal(gvk string, value float64)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL