metric

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// HTTPRequestsTotal counts the total number of HTTP requests.
	HTTPRequestsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "nuwa_http_requests_total",
			Help: "Total number of HTTP requests",
		},
		[]string{"method", "path", "status"},
	)

	// HTTPRequestDuration measures the duration of HTTP requests.
	HTTPRequestDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "nuwa_http_request_duration_seconds",
			Help:    "Duration of HTTP requests in seconds",
			Buckets: prometheus.DefBuckets,
		},
		[]string{"method", "path"},
	)

	// BusinessOpsTotal counts specific business operations (e.g., login, create_user).
	BusinessOpsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "nuwa_business_ops_total",
			Help: "Total number of business operations",
		},
		[]string{"type", "status"},
	)

	// ExternalAPIDuration measures latency of external dependencies
	ExternalAPIDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "nuwa_external_api_duration_seconds",
			Help:    "Duration of external API calls in seconds",
			Buckets: []float64{0.1, 0.5, 1, 2, 5, 10},
		},
		[]string{"service", "operation", "status"},
	)

	// EventBusPublished stats
	EventBusPublished = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "nuwa_event_published_total",
			Help: "Total number of events published",
		},
		[]string{"topic"},
	)

	// EventBusConsumed stats
	EventBusConsumed = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "nuwa_event_consumed_total",
			Help: "Total number of events consumed",
		},
		[]string{"topic", "status"},
	)
)

Functions

func RegisterCronStats

func RegisterCronStats(monitor CronMonitor)

func RegisterDBStats

func RegisterDBStats(db *sql.DB, dbName string)

RegisterDBStats registers SQL DB stats with Prometheus

func RegisterRedisStats

func RegisterRedisStats(rdb *redis.Client, poolName string)

RegisterRedisStats registers Redis Pool stats with Prometheus

Types

type CronMonitor

type CronMonitor interface {
	RunningJobCount() int
}

MonitorCronService monitors running jobs

Jump to

Keyboard shortcuts

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