Documentation
¶
Index ¶
- func Register(metric Metric) error
- func Unregister(name string, labels map[string]string)
- type Counter
- type Gauge
- func (g *Gauge) Add(delta float64)
- func (g *Gauge) Dec()
- func (g *Gauge) Help() string
- func (g *Gauge) Inc()
- func (g *Gauge) Labels() map[string]string
- func (g *Gauge) Name() string
- func (g *Gauge) Reset()
- func (g *Gauge) Set(value float64)
- func (g *Gauge) Sub(delta float64)
- func (g *Gauge) Type() MetricType
- func (g *Gauge) Value() interface{}
- type Handler
- type Histogram
- func (h *Histogram) Help() string
- func (h *Histogram) Labels() map[string]string
- func (h *Histogram) Name() string
- func (h *Histogram) Observe(value float64)
- func (h *Histogram) ObserveDuration(start time.Time)
- func (h *Histogram) Reset()
- func (h *Histogram) Type() MetricType
- func (h *Histogram) Value() interface{}
- type Metric
- type MetricType
- type PrometheusExporter
- type Registry
- func (r *Registry) All() []Metric
- func (r *Registry) Clear()
- func (r *Registry) Get(name string, labels map[string]string) (Metric, bool)
- func (r *Registry) GetOrCreateCounter(name, help string, labels map[string]string) *Counter
- func (r *Registry) GetOrCreateGauge(name, help string, labels map[string]string) *Gauge
- func (r *Registry) GetOrCreateHistogram(name, help string, labels map[string]string, buckets []float64) *Histogram
- func (r *Registry) Register(metric Metric) error
- func (r *Registry) Reset()
- func (r *Registry) Unregister(name string, labels map[string]string)
- type StreamBusMetrics
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Unregister ¶
Unregister removes a metric from the default registry
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a cumulative metric that only increases
Example ¶
counter := NewCounter("requests_total", "Total number of requests", map[string]string{"method": "GET"})
counter.Inc()
counter.Add(5)
fmt.Println(counter.Value())
Output: 6
func NewCounter ¶
NewCounter creates a new counter metric
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a metric that can go up or down
Example ¶
gauge := NewGauge("temperature_celsius", "Current temperature in Celsius", nil)
gauge.Set(22.5)
gauge.Add(2.5)
fmt.Println(gauge.Value())
Output: 25
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides HTTP handlers for metrics endpoints
func NewHandler ¶
NewHandler creates a new HTTP handler for metrics
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers metrics routes on the given mux
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks the distribution of values
Example ¶
histogram := NewHistogram("request_duration_seconds", "Request duration in seconds", nil, []float64{0.1, 0.5, 1.0})
histogram.Observe(0.05)
histogram.Observe(0.3)
histogram.Observe(0.75)
value := histogram.Value().(map[string]interface{})
fmt.Println(value["count"])
Output: 3
func NewHistogram ¶
NewHistogram creates a new histogram metric
func (*Histogram) ObserveDuration ¶
ObserveDuration observes a duration in seconds
type Metric ¶
type Metric interface {
Name() string
Type() MetricType
Help() string
Value() interface{}
Labels() map[string]string
Reset()
}
Metric represents a single metric
type MetricType ¶
type MetricType int
MetricType represents the type of metric
const ( // MetricTypeCounter is a cumulative metric that only increases MetricTypeCounter MetricType = iota // MetricTypeGauge is a metric that can go up or down MetricTypeGauge // MetricTypeHistogram tracks distributions of values MetricTypeHistogram // MetricTypeSummary tracks summary statistics MetricTypeSummary )
func (MetricType) String ¶
func (mt MetricType) String() string
String returns the string representation of the metric type
type PrometheusExporter ¶
type PrometheusExporter struct {
// contains filtered or unexported fields
}
PrometheusExporter exports metrics in Prometheus text format
func NewPrometheusExporter ¶
func NewPrometheusExporter(registry *Registry) *PrometheusExporter
NewPrometheusExporter creates a new Prometheus exporter
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages a collection of metrics
Example ¶
registry := NewRegistry()
counter := registry.GetOrCreateCounter("operations_total", "Total operations", nil)
counter.Inc()
gauge := registry.GetOrCreateGauge("active_connections", "Active connections", nil)
gauge.Set(42)
fmt.Println(len(registry.All()))
Output: 2
func DefaultRegistry ¶
func DefaultRegistry() *Registry
DefaultRegistry returns the default global registry
func (*Registry) GetOrCreateCounter ¶
GetOrCreateCounter gets or creates a counter metric
func (*Registry) GetOrCreateGauge ¶
GetOrCreateGauge gets or creates a gauge metric
func (*Registry) GetOrCreateHistogram ¶
func (r *Registry) GetOrCreateHistogram(name, help string, labels map[string]string, buckets []float64) *Histogram
GetOrCreateHistogram gets or creates a histogram metric
type StreamBusMetrics ¶
type StreamBusMetrics struct {
// Broker metrics
BrokerUptime *Gauge
BrokerStatus *Gauge
BrokerConnections *Gauge
BrokerActiveRequests *Gauge
// Message metrics
MessagesProduced *Counter
MessagesConsumed *Counter
MessagesStored *Counter
BytesProduced *Counter
BytesConsumed *Counter
BytesStored *Counter
// Topic metrics
TopicsTotal *Gauge
PartitionsTotal *Gauge
ReplicasTotal *Gauge
// Performance metrics
ProduceLatency *Histogram
ConsumeLatency *Histogram
ReplicationLatency *Histogram
CommitLatency *Histogram
// Consumer group metrics
ConsumerGroups *Gauge
ConsumerGroupMembers *Gauge
ConsumerGroupLag *Gauge
// Transaction metrics
TransactionsActive *Gauge
TransactionsCommitted *Counter
TransactionsAborted *Counter
TransactionDuration *Histogram
// Storage metrics
StorageUsedBytes *Gauge
StorageAvailableBytes *Gauge
SegmentsTotal *Gauge
CompactionsTotal *Counter
// Network metrics
NetworkBytesIn *Counter
NetworkBytesOut *Counter
NetworkRequestsTotal *Counter
NetworkErrorsTotal *Counter
// Security metrics
AuthenticationAttempts *Counter
AuthenticationFailures *Counter
AuthorizationChecks *Counter
AuthorizationDenials *Counter
AuditEventsLogged *Counter
// Cluster metrics
ClusterSize *Gauge
ClusterLeader *Gauge
RaftTerm *Gauge
RaftCommitIndex *Gauge
// Schema registry metrics
SchemasRegistered *Counter
SchemaValidations *Counter
SchemaValidationErrors *Counter
// contains filtered or unexported fields
}
StreamBusMetrics holds all StreamBus-specific metrics
func NewStreamBusMetrics ¶
func NewStreamBusMetrics(registry *Registry) *StreamBusMetrics
NewStreamBusMetrics creates a new StreamBus metrics collector