mirror of
https://github.com/hanzoai/runtime.git
synced 2026-10-30 18:23:13 +00:00
Mechanical migration following the beego v2.3.8 fork precedent (bc7b075). Same exposition surface, zero prometheus/client_golang in the dep graph.
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
// Copyright 2025 Hanzo Industries Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package common
|
|
|
|
import (
|
|
metric "github.com/luxfi/metric"
|
|
)
|
|
|
|
type PrometheusOperationStatus string
|
|
|
|
const (
|
|
PrometheusOperationStatusSuccess PrometheusOperationStatus = "success"
|
|
PrometheusOperationStatusFailure PrometheusOperationStatus = "failure"
|
|
)
|
|
|
|
// Define your metrics
|
|
var (
|
|
// Histogram to track duration of container operations
|
|
ContainerOperationDuration = metric.NewHistogramVec(
|
|
metric.HistogramOpts{
|
|
Name: "container_operation_duration_seconds",
|
|
Help: "Time taken for container operations in seconds",
|
|
// Buckets optimized for detecting anomalies in operation durations
|
|
Buckets: []float64{0.1, 0.25, 0.5, 0.75, 1, 2, 3, 5, 7.5, 10, 15, 30, 60, 120, 300},
|
|
},
|
|
[]string{"operation"},
|
|
)
|
|
|
|
// Counter to track occurrence of container operations with status
|
|
ContainerOperationCount = metric.NewCounterVec(
|
|
metric.CounterOpts{
|
|
Name: "container_operation_total",
|
|
Help: "Total number of container operations",
|
|
},
|
|
[]string{"operation", "status"},
|
|
)
|
|
)
|