metrics

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultSuccess = "success"
	ResultError   = "error"

	OperationCreate = "create"
	OperationUpdate = "update"
	OperationDelete = "delete"

	ReasonTransient    = "transient"
	ReasonGitHubAPI    = "github_api"
	ReasonConfig       = "config"
	ReasonOwnership    = "ownership"
	ReasonSecretCreate = "secret_create"
	ReasonSecretUpdate = "secret_update"
	ReasonStatusUpdate = "status_update"
)

Attribute value constants for result and operation labels.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

Recorder holds all custom OTEL metric instruments for the operator. All recording methods are nil-receiver safe.

func Setup

func Setup() (*Recorder, error)

Setup creates an OTEL Prometheus exporter registered with the controller-runtime metrics registry, and returns a Recorder holding all custom instruments.

func (*Recorder) EnsureTokenActive

func (r *Recorder) EnsureTokenActive(ctx context.Context, controllerName, tokenKey string)

EnsureTokenActive idempotently marks a token as active. The first call for a given tokenKey increments the active-token counter; subsequent calls are no-ops. This makes the counter self-healing across controller restarts.

func (*Recorder) RecordConfigError

func (r *Recorder) RecordConfigError(ctx context.Context, source string)

RecordConfigError records a configuration loading error.

func (*Recorder) RecordGitHubAPIDuration

func (r *Recorder) RecordGitHubAPIDuration(ctx context.Context, d time.Duration, err error)

RecordGitHubAPIDuration records the duration of a GitHub API call.

func (*Recorder) RecordGitHubTokenRequest

func (r *Recorder) RecordGitHubTokenRequest(ctx context.Context, err error)

RecordGitHubTokenRequest records a GitHub Installation Access Token request.

func (*Recorder) RecordReconcileError

func (r *Recorder) RecordReconcileError(ctx context.Context, controllerName, reason string)

RecordReconcileError records a reconciliation error with its reason.

func (*Recorder) RecordSecretOperation

func (r *Recorder) RecordSecretOperation(ctx context.Context, controllerName, operation, result string)

RecordSecretOperation records a secret create/update/delete operation.

func (*Recorder) RecordTokenExpiry

func (r *Recorder) RecordTokenExpiry(ctx context.Context, controllerName, namespace, name string, expiresAt time.Time)

RecordTokenExpiry records the expiry timestamp for a token.

func (*Recorder) RecordTokenRefresh

func (r *Recorder) RecordTokenRefresh(ctx context.Context, controllerName, result string)

RecordTokenRefresh records a token refresh operation with its result.

func (*Recorder) RecordTokenRefreshDuration

func (r *Recorder) RecordTokenRefreshDuration(ctx context.Context, controllerName, operation string, d time.Duration)

RecordTokenRefreshDuration records the duration of a token refresh operation.

func (*Recorder) RemoveTokenActive

func (r *Recorder) RemoveTokenActive(ctx context.Context, controllerName, tokenKey string)

RemoveTokenActive idempotently marks a token as inactive. Only decrements the counter if the tokenKey was previously tracked via EnsureTokenActive.

func (*Recorder) Shutdown

func (r *Recorder) Shutdown(ctx context.Context) error

Shutdown shuts down the underlying MeterProvider, flushing any remaining data. It is nil-receiver safe.

Jump to

Keyboard shortcuts

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