metrics

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2021-2024 Zenauth Ltd. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	UnitBytes         = "By"
	UnitDimensionless = "1"
	UnitMilliseconds  = "ms"
)

Variables

View Source
var (
	DriverKey      = attribute.Key("driver").String
	KindKey        = attribute.Key("kind").String
	OpKey          = attribute.Key("op").String
	RemoteEventKey = attribute.Key("remote_event").String
	ResultKey      = attribute.Key("result").String
	SourceKey      = attribute.Key("source").String
	StatusKey      = attribute.Key("status").String
)
View Source
var (
	AuditErrorCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_audit_error_count",
			metric.WithDescription("Number of errors encountered while writing an audit log entry"),
		)
	})

	BundleFetchErrorsCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_bundle_fetch_errors_count",
			metric.WithDescription("Count of errors encountered during bundle downloads"),
		)
	})

	BundleNotFoundErrorsCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_bundle_not_found_errors_count",
			metric.WithDescription("Count of bundle not found errors"),
		)
	})

	BundleStoreLatency = once(func() (metric.Float64Histogram, error) {
		return Meter().Float64Histogram(
			"cerbos_dev_store_bundle_op_latency",
			metric.WithDescription("Time to do an operation with the bundle store"),
			metric.WithUnit(UnitMilliseconds),
			metric.WithExplicitBucketBoundaries(defaultHistBoundsMS...),
		)
	})

	BundleStoreRemoteEventsCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_bundle_remote_events_count",
			metric.WithDescription("Count of remote server events received by the bundle store"),
		)
	})

	BundleStoreUpdatesCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_bundle_updates_count",
			metric.WithDescription("Count of bundle updates from remote source"),
		)
	})

	CacheAccessCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_cache_access_count",
			metric.WithDescription("Counter of cache access"),
		)
	})

	CacheLiveObjGauge = once(func() (metric.Int64UpDownCounter, error) {
		return Meter().Int64UpDownCounter(
			"cerbos_dev_cache_live_objects",
			metric.WithDescription("Number of live objects in the cache"),
		)
	})

	CacheMaxSize = once(func() (metric.Int64UpDownCounter, error) {
		return Meter().Int64UpDownCounter(
			"cerbos_dev_cache_max_size",
			metric.WithDescription("Maximum capacity of the cache"),
		)
	})

	CompileDuration = once(func() (metric.Float64Histogram, error) {
		return Meter().Float64Histogram(
			"cerbos_dev_compiler_compile_duration",
			metric.WithDescription("Time to compile a set of policies"),
			metric.WithUnit(UnitMilliseconds),
			metric.WithExplicitBucketBoundaries(defaultHistBoundsMS...),
		)
	})

	EngineCheckLatency = once(func() (metric.Float64Histogram, error) {
		return Meter().Float64Histogram(
			"cerbos_dev_engine_check_latency",
			metric.WithDescription("Time to match a request against a policy and provide a decision"),
			metric.WithUnit(UnitMilliseconds),
			metric.WithExplicitBucketBoundaries(defaultHistBoundsMS...),
		)
	})

	EngineCheckBatchSize = once(func() (metric.Int64Histogram, error) {
		return Meter().Int64Histogram(
			"cerbos_dev_engine_check_batch_size",
			metric.WithDescription("Batch size distribution of check requests"),
			metric.WithUnit(UnitDimensionless),
			metric.WithExplicitBucketBoundaries(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 45, 50),
		)
	})

	EnginePlanLatency = once(func() (metric.Float64Histogram, error) {
		return Meter().Float64Histogram(
			"cerbos_dev_engine_plan_latency",
			metric.WithDescription("Time to produce a query plan"),
			metric.WithUnit(UnitMilliseconds),
			metric.WithExplicitBucketBoundaries(defaultHistBoundsMS...),
		)
	})

	HubConnected = once(func() (metric.Int64UpDownCounter, error) {
		return Meter().Int64UpDownCounter(
			"cerbos_dev_hub_connected",
			metric.WithDescription("Is the instance connected to Cerbos Hub"),
		)
	})

	IndexCRUDCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_index_crud_count",
			metric.WithDescription("Number of create_update_delete operations"),
		)
	})

	IndexEntryCount = once(func() (metric.Int64UpDownCounter, error) {
		return Meter().Int64UpDownCounter(
			"cerbos_dev_index_entry_count",
			metric.WithDescription("Number of entries in the index"),
		)
	})

	StorePollCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_poll_count",
			metric.WithDescription("Number of times the remote store was polled for updates"),
		)
	})

	StoreSyncErrorCount = once(func() (metric.Int64Counter, error) {
		return Meter().Int64Counter(
			"cerbos_dev_store_sync_error_count",
			metric.WithDescription("Number of errors encountered while syncing updates from the remote store"),
		)
	})
)
View Source
var Meter = sync.OnceValue(func() metric.Meter {
	return otel.GetMeterProvider().Meter("cerbos.dev/cerbos")
})

Functions

func Add added in v0.32.0

func Add[T counter](ctx context.Context, m T, v int64, attr ...attribute.KeyValue)

func Inc added in v0.32.0

func Inc[T counter](ctx context.Context, m T, attr ...attribute.KeyValue)

func NewHandler added in v0.32.0

func NewHandler() (http.Handler, error)

func RecordDuration2 added in v0.32.0

func RecordDuration2[T any](hist metric.Float64Histogram, fn func() (T, error)) (T, error)

func RecordDuration3 added in v0.33.0

func RecordDuration3[A, B any](hist metric.Float64Histogram, fn func() (A, B, error)) (A, B, error)

func TotalTimeMS added in v0.32.0

func TotalTimeMS(startTime time.Time) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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