package metrics
import "github.com/open-policy-agent/opa/v1/metrics"
Package metrics contains helpers for performance metric management inside the policy engine.
Index ¶
- Constants
- func Statistics(num ...int64) any
- type Counter
- type Histogram
- type Info
- type Metrics
- type Timer
- type TimerMetrics
Constants ¶
const ( BundleRequest = "bundle_request" ServerHandler = "server_handler" ServerQueryCacheHit = "server_query_cache_hit" SDKDecisionEval = "sdk_decision_eval" RegoQueryCompile = "rego_query_compile" RegoQueryEval = "rego_query_eval" RegoQueryParse = "rego_query_parse" RegoModuleParse = "rego_module_parse" RegoDataParse = "rego_data_parse" RegoModuleCompile = "rego_module_compile" RegoPartialEval = "rego_partial_eval" RegoInputParse = "rego_input_parse" RegoLoadFiles = "rego_load_files" RegoLoadBundles = "rego_load_bundles" RegoExternalResolve = "rego_external_resolve" )
Well-known metric names.
Functions ¶
func Statistics ¶
Types ¶
type Counter ¶
Counter defines the interface for a monotonic increasing counter.
type Histogram ¶
Histogram defines the interface for a histogram with hardcoded percentiles.
type Info ¶
type Info struct { Name string `json:"name"` // name is a unique human-readable identifier for the provider. }
Info contains attributes describing the underlying metrics provider.
type Metrics ¶
type Metrics interface { Info() Info Timer(name string) Timer Histogram(name string) Histogram Counter(name string) Counter All() map[string]any Clear() json.Marshaler }
Metrics defines the interface for a collection of performance metrics in the policy engine.
func New ¶
func New() Metrics
New returns a new Metrics object.
func NoOp ¶
func NoOp() Metrics
NoOp returns a Metrics implementation that does nothing and costs nothing. Used when metrics are expected, but not of interest.
type Timer ¶
type Timer interface { Value() any Int64() int64 // Start or resume a timer's time tracking. Start() // Stop a timer, and accumulate the delta (in nanoseconds) since it was last // started. Stop() int64 }
Timer defines the interface for a restartable timer that accumulates elapsed time.
type TimerMetrics ¶
Source Files ¶
- Version
- v1.6.0 (latest)
- Published
- Jun 30, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 3 days ago –
Tools for package owners.