prometheus

package
v0.110.13 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package prometheus registers the engine Prometheus collectors (global and tenant-labeled task metrics, pub/sub) and gates tenant series on entitlement.

Index

Constants

This section is empty.

Variables

View Source
var (
	QueueInvocations = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(QueueInvocationsTotal),
		Help: "The total number of invocations of the queuer function",
	})

	CreatedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(CreatedTasksTotal),
		Help: "The total number of tasks created",
	})

	RetriedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(RetriedTasksTotal),
		Help: "The total number of tasks retried",
	})

	SucceededTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(SucceededTasksTotal),
		Help: "The total number of tasks that succeeded",
	})

	FailedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(FailedTasksTotal),
		Help: "The total number of tasks that failed (in a final state, not including retries)",
	})

	SkippedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(SkippedTasksTotal),
		Help: "The total number of tasks that were skipped",
	})

	CancelledTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(CancelledTasksTotal),
		Help: "The total number of tasks cancelled",
	})

	AssignedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(AssignedTasksTotal),
		Help: "The total number of tasks assigned to a worker",
	})

	SchedulingTimedOut = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(SchedulingTimedOutTotal),
		Help: "The total number of tasks that timed out while waiting to be scheduled",
	})

	RateLimited = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(RateLimitedTotal),
		Help: "The total number of tasks that were rate limited",
	})

	QueuedToAssigned = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(QueuedToAssignedTotal),
		Help: "The total number of unique tasks that were queued and later got assigned to a worker",
	})

	QueuedToAssignedTimeBuckets = promauto.NewHistogram(prometheus.HistogramOpts{
		Name:    string(QueuedToAssignedTimeSeconds),
		Help:    "Buckets of time in seconds spent in the queue before being assigned to a worker",
		Buckets: []float64{0.01, 0.02, 0.05, 0.1, 0.5, 1, 2, 5, 15},
	})

	ReassignedTasks = promauto.NewCounter(prometheus.CounterOpts{
		Name: string(ReassignedTasksTotal),
		Help: "The total number of tasks that were reassigned to a worker",
	})
)
View Source
var (
	PubSubPublishDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    string(PubSubPublishDurationSeconds),
		Help:    "Time for the pub/sub backend's Pub call to return; this is publisher-side blocking cost, not broker delivery latency, and is not comparable across backends, which block at different depths before returning.",
		Buckets: pubSubBuckets,
	}, []string{"kind", "topic_kind", "result"})

	PubSubTransit = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    string(PubSubTransitSeconds),
		Help:    "Publish-to-delivery latency computed from the message's published_at stamp; subject to clock skew between publisher and subscriber pods; unstamped messages (older engines) are not observed.",
		Buckets: pubSubBuckets,
	}, []string{"kind", "topic_kind"})

	PubSubStaleSkipped = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(PubSubStaleSkippedTotal),
		Help: "Delivered messages skipped without running the handler because their published_at stamp was older than the topic kind's max age; subject to clock skew between publisher and subscriber pods.",
	}, []string{"kind", "topic_kind"})

	PubSubHandlersInFlight = promauto.NewGaugeVec(prometheus.GaugeOpts{
		Name: string(PubSubHandlersInFlightCount),
		Help: "Subscriber handler calls currently running, summed over the process's subscriptions of a topic kind.",
	}, []string{"kind", "topic_kind"})

	PubSubHandlerPoolFull = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(PubSubHandlerPoolFullTotal),
		Help: "Deliveries that found their subscription's handler concurrency limit reached and had to wait for a running handler to return.",
	}, []string{"kind", "topic_kind"})

	PubSubHandlerSlotWait = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    string(PubSubHandlerSlotWaitSeconds),
		Help:    "Time a delivery waited for a free handler slot in its subscription; zero when a slot was free.",
		Buckets: pubSubBuckets,
	}, []string{"kind", "topic_kind"})
)
View Source
var (
	TenantWorkflowDurationBuckets = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name: string(TenantWorkflowDurationMilliseconds),
		Help: "Duration of workflow execution in milliseconds (DAGs and single tasks)",
		Buckets: []float64{

			0.1,
			0.5,
			1,
			2,
			5,
			10,
			25,
			50,
			100,
			250,
			500,

			1000,
			2500,
			5000,
			10000,
			30000,
			60000,

			300000,
			1800000,
			3600000,
			10800000,
			21600000,
			43200000,
			86400000,
		},
	}, []string{"tenant_id", "workflow_name", "status"})

	TenantQueueInvocations = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantQueueInvocationsTotal),
		Help: "The total number of invocations of the queuer function",
	}, []string{"tenant_id"})

	TenantCreatedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantCreatedTasksTotal),
		Help: "The total number of tasks created",
	}, []string{"tenant_id"})

	TenantRetriedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantRetriedTasksTotal),
		Help: "The total number of tasks retried",
	}, []string{"tenant_id"})

	TenantSucceededTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantSucceededTasksTotal),
		Help: "The total number of tasks that succeeded",
	}, []string{"tenant_id"})

	TenantFailedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantFailedTasksTotal),
		Help: "The total number of tasks that failed (in a final state, not including retries)",
	}, []string{"tenant_id"})

	TenantSkippedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantSkippedTasksTotal),
		Help: "The total number of tasks that were skipped",
	}, []string{"tenant_id"})

	TenantCancelledTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantCancelledTasksTotal),
		Help: "The total number of tasks cancelled",
	}, []string{"tenant_id"})

	TenantAssignedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantAssignedTasksTotal),
		Help: "The total number of tasks assigned to a worker",
	}, []string{"tenant_id"})

	TenantSchedulingTimedOut = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantSchedulingTimedOutTotal),
		Help: "The total number of tasks that timed out while waiting to be scheduled",
	}, []string{"tenant_id"})

	TenantRateLimited = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantRateLimitedTotal),
		Help: "The total number of tasks that were rate limited",
	}, []string{"tenant_id"})

	TenantQueuedToAssigned = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantQueuedToAssignedTotal),
		Help: "The total number of unique tasks that were queued and later got assigned to a worker",
	}, []string{"tenant_id"})

	TenantQueuedToAssignedTimeBuckets = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    string(TenantQueuedToAssignedTimeSeconds),
		Help:    "Buckets of time in seconds spent in the queue before being assigned to a worker",
		Buckets: []float64{0.01, 0.02, 0.05, 0.1, 0.5, 1, 2, 5, 15},
	}, []string{"tenant_id"})

	TenantQueuedToAssignedByWorkflowCounter = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantQueuedToAssignedByWorkflow),
		Help: "The total number of unique tasks that were queued and later got assigned to a worker, by workflow name",
	}, []string{"tenant_id", "workflow_name"})

	TenantQueuedToAssignedTimeByWorkflowBuckets = promauto.NewHistogramVec(prometheus.HistogramOpts{
		Name:    string(TenantQueuedToAssignedTimeSecondsByWorkflow),
		Help:    "Buckets of time in seconds spent in the queue before being assigned to a worker, by workflow name",
		Buckets: []float64{0.01, 0.02, 0.05, 0.1, 0.5, 1, 2, 5, 15},
	}, []string{"tenant_id", "workflow_name"})

	TenantReassignedTasks = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: string(TenantReassignedTasksTotal),
		Help: "The total number of tasks that were reassigned to a worker",
	}, []string{"tenant_id"})

	TenantWorkerSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantWorkerSlotsTotal),
			Help: "Total number of slots per worker pool",
		},
		[]string{"tenant_id", "worker_id", "worker_name"},
	)

	TenantUsedWorkerSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantUsedWorkerSlotsTotal),
			Help: "Number of used slots per worker pool",
		},
		[]string{"tenant_id", "worker_id", "worker_name"},
	)

	TenantAvailableWorkerSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantAvailableWorkerSlotsTotal),
			Help: "Number of available slots per worker pool",
		},
		[]string{"tenant_id", "worker_id", "worker_name"},
	)

	TenantWorkerLabelSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantWorkerLabelSlotsTotal),
			Help: "Total number of slots of the given slot type across workers with the given worker label pair",
		},
		[]string{"tenant_id", "label_key", "label_value", "slot_type"},
	)

	TenantUsedWorkerLabelSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantUsedWorkerLabelSlotsTotal),
			Help: "Number of used slots of the given slot type across workers with the given worker label pair",
		},
		[]string{"tenant_id", "label_key", "label_value", "slot_type"},
	)

	TenantAvailableWorkerLabelSlots = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantAvailableWorkerLabelSlotsTotal),
			Help: "Number of available slots of the given slot type across workers with the given worker label pair",
		},
		[]string{"tenant_id", "label_key", "label_value", "slot_type"},
	)

	TenantQueueSize = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantQueueSizeTotal),
			Help: "Number of queued items per queue and workflow",
		},
		[]string{"tenant_id", "queue", "workflow_name"},
	)

	TenantQueueSizeByMetadata = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: string(TenantAdditionalMetadataQueueSize),
			Help: "Number of queued items per queue carrying the given additional metadata key-value pair. An item counts towards every metadata key it carries, so series for different keys overlap and should not be summed across keys",
		},
		[]string{"tenant_id", "queue", "key", "value"},
	)
)

Functions

func RegisterNATSSchedulerPartitionDrops added in v0.105.14

func RegisterNATSSchedulerPartitionDrops(dropped func() float64) func()

RegisterNATSSchedulerPartitionDrops exposes dropped() as a counter; the returned func unregisters it. Panics on double registration.

func RegisterNATSSchedulerPartitionPending added in v0.110.9

func RegisterNATSSchedulerPartitionPending(pending func() float64) func()

RegisterNATSSchedulerPartitionPending exposes pending() as a gauge; the returned func unregisters it. Panics on double registration.

Types

type EntitlementChecker added in v0.90.0

type EntitlementChecker func(ctx context.Context, tenantId uuid.UUID) (bool, error)

EntitlementChecker reports whether Prometheus metrics are entitled for a tenant. It's a func rather than repository.TenantEntitlementRepository to avoid importing pkg/repository (and the resulting import cycle).

type Gate added in v0.90.0

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

Gate decides whether per-tenant Prometheus metrics should be collected. When tenantScoped is false (self-hosted/OSS default) every tenant is enabled and the gate is a no-op. When tenantScoped is true, collection is gated on each tenant's prometheus_metrics entitlement.

func NewGate added in v0.90.0

func NewGate(checker EntitlementChecker, tenantScoped bool, l *zerolog.Logger) *Gate

NewGate builds a Gate. When tenantScoped is false, Enabled always returns true and the checker is never consulted.

func (*Gate) Enabled added in v0.90.0

func (g *Gate) Enabled(ctx context.Context, tenantId uuid.UUID) bool

Enabled reports whether per-tenant Prometheus metrics should be collected for the tenant. It returns true when the gate is nil or not tenant-scoped. On a lookup error it fails closed (returns false) so unentitled data is not collected.

type GlobalHatchetMetric

type GlobalHatchetMetric string
const (
	QueueInvocationsTotal       GlobalHatchetMetric = "hatchet_queue_invocations_total"
	CreatedTasksTotal           GlobalHatchetMetric = "hatchet_created_tasks_total"
	RetriedTasksTotal           GlobalHatchetMetric = "hatchet_retried_tasks_total"
	SucceededTasksTotal         GlobalHatchetMetric = "hatchet_succeeded_tasks_total"
	FailedTasksTotal            GlobalHatchetMetric = "hatchet_failed_tasks_total"
	SkippedTasksTotal           GlobalHatchetMetric = "hatchet_skipped_tasks_total"
	CancelledTasksTotal         GlobalHatchetMetric = "hatchet_cancelled_tasks_total"
	AssignedTasksTotal          GlobalHatchetMetric = "hatchet_assigned_tasks"
	SchedulingTimedOutTotal     GlobalHatchetMetric = "hatchet_scheduling_timed_out"
	RateLimitedTotal            GlobalHatchetMetric = "hatchet_rate_limited"
	QueuedToAssignedTotal       GlobalHatchetMetric = "hatchet_queued_to_assigned"
	QueuedToAssignedTimeSeconds GlobalHatchetMetric = "hatchet_queued_to_assigned_time_seconds"
	ReassignedTasksTotal        GlobalHatchetMetric = "hatchet_reassigned_tasks"
)

type PubSubHatchetMetric added in v0.98.10

type PubSubHatchetMetric string
const (
	PubSubPublishDurationSeconds                PubSubHatchetMetric = "hatchet_pubsub_publish_duration_seconds"
	PubSubTransitSeconds                        PubSubHatchetMetric = "hatchet_pubsub_transit_seconds"
	PubSubNATSSchedulerPartitionDropsTotal      PubSubHatchetMetric = "hatchet_pubsub_nats_scheduler_partition_drops_total"
	PubSubStaleSkippedTotal                     PubSubHatchetMetric = "hatchet_pubsub_stale_skipped_total"
	PubSubHandlersInFlightCount                 PubSubHatchetMetric = "hatchet_pubsub_handlers_in_flight"
	PubSubHandlerPoolFullTotal                  PubSubHatchetMetric = "hatchet_pubsub_handler_pool_full_total"
	PubSubHandlerSlotWaitSeconds                PubSubHatchetMetric = "hatchet_pubsub_handler_slot_wait_seconds"
	PubSubNATSSchedulerPartitionPendingMessages PubSubHatchetMetric = "hatchet_pubsub_nats_scheduler_partition_pending_messages"
)

type TenantHatchetMetric

type TenantHatchetMetric string
const (
	TenantWorkflowDurationMilliseconds          TenantHatchetMetric = "hatchet_tenant_workflow_duration_milliseconds"
	TenantAssignedTasksTotal                    TenantHatchetMetric = "hatchet_tenant_assigned_tasks"
	TenantSchedulingTimedOutTotal               TenantHatchetMetric = "hatchet_tenant_scheduling_timed_out"
	TenantRateLimitedTotal                      TenantHatchetMetric = "hatchet_tenant_rate_limited"
	TenantQueuedToAssignedTotal                 TenantHatchetMetric = "hatchet_tenant_queued_to_assigned"
	TenantQueuedToAssignedTimeSeconds           TenantHatchetMetric = "hatchet_tenant_queued_to_assigned_time_seconds"
	TenantQueuedToAssignedByWorkflow            TenantHatchetMetric = "hatchet_tenant_queued_to_assigned_by_workflow"
	TenantQueuedToAssignedTimeSecondsByWorkflow TenantHatchetMetric = "hatchet_tenant_queued_to_assigned_time_seconds_by_workflow"
	TenantQueueInvocationsTotal                 TenantHatchetMetric = "hatchet_tenant_queue_invocations"
	TenantCreatedTasksTotal                     TenantHatchetMetric = "hatchet_tenant_created_tasks"
	TenantRetriedTasksTotal                     TenantHatchetMetric = "hatchet_tenant_retried_tasks"
	TenantSucceededTasksTotal                   TenantHatchetMetric = "hatchet_tenant_succeeded_tasks"
	TenantFailedTasksTotal                      TenantHatchetMetric = "hatchet_tenant_failed_tasks"
	TenantSkippedTasksTotal                     TenantHatchetMetric = "hatchet_tenant_skipped_tasks"
	TenantCancelledTasksTotal                   TenantHatchetMetric = "hatchet_tenant_cancelled_tasks"
	TenantReassignedTasksTotal                  TenantHatchetMetric = "hatchet_tenant_reassigned_tasks"
	TenantUsedWorkerSlotsTotal                  TenantHatchetMetric = "hatchet_tenant_used_worker_slots"
	TenantAvailableWorkerSlotsTotal             TenantHatchetMetric = "hatchet_tenant_available_worker_slots"
	TenantWorkerSlotsTotal                      TenantHatchetMetric = "hatchet_tenant_worker_slots"
	TenantUsedWorkerLabelSlotsTotal             TenantHatchetMetric = "hatchet_tenant_used_worker_label_slots"
	TenantAvailableWorkerLabelSlotsTotal        TenantHatchetMetric = "hatchet_tenant_available_worker_label_slots"
	TenantWorkerLabelSlotsTotal                 TenantHatchetMetric = "hatchet_tenant_worker_label_slots"
	TenantQueueSizeTotal                        TenantHatchetMetric = "hatchet_tenant_queue_size"
	TenantAdditionalMetadataQueueSize           TenantHatchetMetric = "hatchet_tenant_additional_metadata_queue_size"
)

Jump to

Keyboard shortcuts

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