Documentation
¶
Index ¶
- Variables
- func ActiveUsers(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, ...) (func(), error)
- func AgentStats(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, ...) (func(), error)
- func Agents(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, ...) (func(), error)
- func Experiments(registerer prometheus.Registerer, active codersdk.Experiments) error
- func Users(ctx context.Context, logger slog.Logger, clk quartz.Clock, ...) (func(), error)
- func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, ...) (func(), error)
- type AgentMetricLabels
- type CachedGaugeVec
- type MetricsAggregator
- type VectorOperation
Constants ¶
This section is empty.
Variables ¶
var MetricLabelValueEncoder = strings.NewReplacer("\\", "\\\\", "|", "\\|", ",", "\\,", "=", "\\=")
Functions ¶
func ActiveUsers ¶
func ActiveUsers(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, duration time.Duration) (func(), error)
ActiveUsers tracks the number of users that have authenticated within the past hour.
func AgentStats ¶
func AgentStats(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, initialCreateAfter time.Time, duration time.Duration, aggregateByLabels []string, usage bool) (func(), error)
nolint:revive // This will be removed alongside the workspaceusage experiment
func Agents ¶
func Agents(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, coordinator *atomic.Pointer[tailnet.Coordinator], derpMapFn func() *tailcfg.DERPMap, agentInactiveDisconnectTimeout, duration time.Duration) (func(), error)
Agents tracks the total number of workspaces with labels on status.
func Experiments ¶ added in v2.10.0
func Experiments(registerer prometheus.Registerer, active codersdk.Experiments) error
Experiments registers a metric which indicates whether each experiment is enabled or not.
func Users ¶ added in v2.17.0
func Users(ctx context.Context, logger slog.Logger, clk quartz.Clock, registerer prometheus.Registerer, db database.Store, duration time.Duration) (func(), error)
Users tracks the total number of registered users, partitioned by status.
func Workspaces ¶
func Workspaces(ctx context.Context, logger slog.Logger, registerer prometheus.Registerer, db database.Store, duration time.Duration) (func(), error)
Workspaces tracks the total number of workspaces with labels on status.
Types ¶
type AgentMetricLabels ¶ added in v2.5.1
type AgentMetricLabels struct { Username string WorkspaceName string AgentName string TemplateName string }
AgentMetricLabels are the labels used to decorate an agent's metrics. This list should match the list of labels in agentMetricsLabels.
type CachedGaugeVec ¶
type CachedGaugeVec struct {
// contains filtered or unexported fields
}
CachedGaugeVec is a wrapper for the prometheus.GaugeVec which allows for staging changes in the metrics vector. Calling "WithLabelValues(...)" will update the internal gauge value, but it will not be returned by "Collect(...)" until the "Commit()" method is called. The "Commit()" method resets the internal gauge and applies all staged changes to it.
The Use of CachedGaugeVec is recommended for use cases when there is a risk that the Prometheus collector receives incomplete metrics, collected in the middle of metrics recalculation, between "Reset()" and the last "WithLabelValues()" call.
func NewCachedGaugeVec ¶
func NewCachedGaugeVec(gaugeVec *prometheus.GaugeVec) *CachedGaugeVec
func (*CachedGaugeVec) Collect ¶
func (v *CachedGaugeVec) Collect(ch chan<- prometheus.Metric)
func (*CachedGaugeVec) Commit ¶
func (v *CachedGaugeVec) Commit()
Commit will set the internal value as the cached value to return from "Collect()". The internal metric value is completely reset, so the caller should expect the gauge to be empty for the next 'WithLabelValues' values.
func (*CachedGaugeVec) Describe ¶
func (v *CachedGaugeVec) Describe(desc chan<- *prometheus.Desc)
func (*CachedGaugeVec) WithLabelValues ¶
func (v *CachedGaugeVec) WithLabelValues(operation VectorOperation, value float64, labelValues ...string)
type MetricsAggregator ¶
type MetricsAggregator struct {
// contains filtered or unexported fields
}
func NewMetricsAggregator ¶
func NewMetricsAggregator(logger slog.Logger, registerer prometheus.Registerer, duration time.Duration, aggregateByLabels []string) (*MetricsAggregator, error)
func (*MetricsAggregator) Collect ¶
func (ma *MetricsAggregator) Collect(ch chan<- prometheus.Metric)
func (*MetricsAggregator) Describe ¶
func (*MetricsAggregator) Describe(_ chan<- *prometheus.Desc)
Describe function does not have any knowledge about the metrics schema, so it does not emit anything.
func (*MetricsAggregator) Run ¶
func (ma *MetricsAggregator) Run(ctx context.Context) func()
func (*MetricsAggregator) Update ¶
func (ma *MetricsAggregator) Update(ctx context.Context, labels AgentMetricLabels, metrics []*agentproto.Stats_Metric)
type VectorOperation ¶
type VectorOperation int
const ( VectorOperationAdd VectorOperation = iota VectorOperationSet )