Files
query-orchestration/internal/serviceconfig/observability/prometheus/common.go
T
Jay Brown ab28cf30db Merged in feature/common-metrics (pull request #73)
Add common metrics

* add common metrics

and sample for using

* updates

* attempt integration

* wip

* working

stubs generate

* docs

* comments

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics

* runner metrics all

* exclude generated

from the coverage

* fix lint

* refactor metrics

* change .gen filename

* new gen

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics

* docs

* main merge

* refactor

* add to generate

* merge main
2025-03-05 16:59:01 +00:00

189 lines
3.9 KiB
Go

//go:generate go run ./generator/main.go
package prometheus
// NewStandardMetricDefinitions provides a base set of metric definitions that can be used
// across all services. Services can use these directly and append their own
// specific metrics to this slice.
// These base metrics are just suggestions/guesses and are expected to evolve as we implement them.
func NewStandardMetricDefinitions() []MetricDefinition {
return []MetricDefinition{
{
Type: Counter,
Name: "requests_total",
Help: "Total number of requests processed",
Labels: []string{
"operation",
"method",
"path", // Added from Second
"status",
"error_type",
},
},
{
Type: Histogram,
Name: "request_duration_seconds",
Help: "Request duration distribution in seconds",
Labels: []string{
"operation",
"method",
"path", // Added from Second
"status", // Added from Second
},
Buckets: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10}, // Merged buckets
},
{
Type: Gauge,
Name: "active_operations",
Help: "Number of currently active operations",
Labels: []string{
"operation_type",
},
},
{
Type: Gauge,
Name: "resource_usage",
Help: "Current resource usage metrics",
Labels: []string{
"resource_type",
"resource_name",
},
},
{
Type: Summary,
Name: "operation_size_bytes",
Help: "Size of operation results in bytes",
Labels: []string{
"operation",
"type",
},
Objectives: map[float64]float64{
0.5: 0.05,
0.9: 0.01,
0.99: 0.001,
},
},
{
Type: Gauge,
Name: "dependency_health",
Help: "Health status of service dependencies",
Labels: []string{
"dependency_name",
"dependency_type",
},
},
{
Type: Counter,
Name: "rate_limited_total",
Help: "Total number of rate limited operations",
Labels: []string{
"operation",
"limit_type",
},
},
{
Type: Counter,
Name: "cache_operations_total",
Help: "Total number of cache operations",
Labels: []string{
"operation",
"cache_name",
"result", // Added from Second
},
},
{
Type: Gauge,
Name: "background_tasks",
Help: "Status and count of background tasks",
Labels: []string{
"task_type",
"status",
},
},
{
Type: Counter,
Name: "business_operations_total",
Help: "Total number of business operations",
Labels: []string{
"operation",
"category",
"status",
"result", // Added from Second
},
},
// Added from Second
{
Type: Histogram,
Name: "operation_duration_seconds",
Help: "Duration of business operations in seconds",
Labels: []string{
"operation",
"result",
},
Buckets: []float64{0.001, 0.01, 0.1, 1, 10, 60},
},
{
Type: Gauge,
Name: "active_connections",
Help: "Current number of active connections/requests being processed",
Labels: []string{
"type",
},
},
{
Type: Gauge,
Name: "queue_length",
Help: "Current length of pending work items in queues",
Labels: []string{
"queue_name",
},
},
{
Type: Counter,
Name: "errors_total",
Help: "Total number of errors encountered",
Labels: []string{
"component",
"error_type",
},
},
{
Type: Counter,
Name: "retries_total",
Help: "Total number of retry attempts made",
Labels: []string{
"operation",
"component",
},
},
{
Type: Counter,
Name: "lifecycle_event",
Help: "major lifecycle events",
Labels: []string{
"operation",
"component",
},
},
{
Type: Histogram,
Name: "cache_operation_duration_seconds",
Help: "Duration of cache operations in seconds",
Labels: []string{
"operation",
"result",
},
Buckets: []float64{0.0001, 0.001, 0.005, 0.01, 0.1},
},
{
Type: Gauge,
Name: "items_in_progress",
Help: "Current number of items being processed",
Labels: []string{
"operation",
"component",
},
},
}
}