prometheus

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package prometheus provides Prometheus metrics exporters for PromptKit pipelines.

Package prometheus provides Prometheus metrics exporters for PromptKit pipelines.

Package prometheus provides Prometheus metrics exporters for PromptKit pipelines.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordPipelineEnd

func RecordPipelineEnd(status string, durationSeconds float64)

RecordPipelineEnd records a pipeline completion.

func RecordPipelineStart

func RecordPipelineStart()

RecordPipelineStart records a pipeline start.

func RecordProviderCost

func RecordProviderCost(provider, model string, cost float64)

RecordProviderCost records cost from a provider call.

func RecordProviderRequest

func RecordProviderRequest(provider, model, status string, durationSeconds float64)

RecordProviderRequest records a provider API call.

func RecordProviderTokens

func RecordProviderTokens(provider, model string, inputTokens, outputTokens, cachedTokens int)

RecordProviderTokens records token consumption.

func RecordStageDuration

func RecordStageDuration(stageName, stageType string, durationSeconds float64)

RecordStageDuration records the duration of a stage.

func RecordStageElement

func RecordStageElement(stageName, status string)

RecordStageElement records a processed element.

func RecordToolCall

func RecordToolCall(toolName, status string, durationSeconds float64)

RecordToolCall records a tool call.

func RecordValidation

func RecordValidation(validator, validatorType, status string, durationSeconds float64)

RecordValidation records a validation check.

Types

type Exporter

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

Exporter serves Prometheus metrics over HTTP.

func NewExporter

func NewExporter(addr string) *Exporter

NewExporter creates a new Prometheus exporter that serves metrics at the given address.

func NewExporterWithRegistry

func NewExporterWithRegistry(addr string, registry *prometheus.Registry) *Exporter

NewExporterWithRegistry creates a new Prometheus exporter with a custom registry. This is useful for testing or when you want more control over metric registration.

func (*Exporter) Handler

func (e *Exporter) Handler() http.Handler

Handler returns an http.Handler for the metrics endpoint. This is useful when you want to integrate metrics into an existing HTTP server.

func (*Exporter) MustRegister

func (e *Exporter) MustRegister(cs ...prometheus.Collector)

MustRegister registers additional collectors with the exporter's registry. Panics if registration fails.

func (*Exporter) Register

func (e *Exporter) Register(c prometheus.Collector) error

Register registers additional collectors with the exporter's registry. Returns an error if registration fails.

func (*Exporter) Registry

func (e *Exporter) Registry() *prometheus.Registry

Registry returns the underlying Prometheus registry.

func (*Exporter) Shutdown

func (e *Exporter) Shutdown(ctx context.Context) error

Shutdown gracefully stops the exporter with the given context.

func (*Exporter) Start

func (e *Exporter) Start() error

Start begins serving metrics at /metrics endpoint. This method blocks until the server is stopped or encounters an error. Returns http.ErrServerClosed when shut down gracefully.

type MetricsListener

type MetricsListener struct{}

MetricsListener records pipeline events as Prometheus metrics. It implements the events.Listener signature and should be registered with an EventBus using SubscribeAll.

func NewMetricsListener

func NewMetricsListener() *MetricsListener

NewMetricsListener creates a new MetricsListener.

func (*MetricsListener) Handle

func (l *MetricsListener) Handle(event *events.Event)

Handle processes an event and records relevant metrics. This method is designed to be used with EventBus.SubscribeAll.

func (*MetricsListener) Listener

func (l *MetricsListener) Listener() events.Listener

Listener returns an events.Listener function that can be registered with an EventBus.

Jump to

Keyboard shortcuts

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