Help us shape the future of Go! Take the 2026 Go Developer Survey

metrics

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Prometheus Metrics Usage

  1. For number of requests, use value as 1 for each request:

    metric.Must(global.GetMeterProvider().Meter("radius-rp")).NewInt64ValueRecorder(requestMetricName, metric.WithUnit(unit.Dimensionless)).Record(r.Context(), int64(1))

  2. To record latency:

    metric.Must(global.GetMeterProvider().Meter("radius-rp")).NewInt64Counter(metricName, metric.WithUnit(unit.millisecond)).Add(ctx, int64(val), labels...)

  3. To use a gauge, define a call back function:

    callback := func(v int) metric.Int64ObserverFunc { return metric.Int64ObserverFunc(func(_ context.Context, result metric.Int64ObserverResult) { result.Observe(int64(v), labels...) }) }(val)

    getMeterMust().NewInt64ValueObserver(metricName, callback).Observation(int64(val))

Documentation

Index

Constants

View Source
const (
	// AsyncOperationCount is the metric name for async operation count.
	AsyncOperationCount = "asyncoperation.operation"

	// QueuedAsyncOperationCount is the metric name for queued async operation count.
	QueuedAsyncOperationCount = "asyncoperation.queued.operation"

	// ExtendedAsyncOperationCount is the metric name for extended async operation count.
	ExtendedAsyncOperationCount = "asyncoperation.extended.operation"

	// AsyncOperationDuration is the metric name for async operation duration.
	AsnycOperationDuration = "asyncoperation.duration"
)
View Source
const (

	// RecipeEngineOperationExecute represents the Execute operation of the Recipe Engine.
	RecipeEngineOperationExecute = "execute"

	// RecipeEngineOperationDelete represents the Delete operation of the Recipe Engine.
	RecipeEngineOperationDelete = "delete"

	// RecipeEngineOperationDownloadRecipe represents the Download Recipe operation of the Recipe Engine.
	RecipeEngineOperationDownloadRecipe = "download.recipe"

	// RecipeEngineOperationGC represents the Garbage Collection operation of the Recipe Engine.
	RecipeEngineOperationGC = "garbage.collection.recipe"
)
View Source
const (

	// OperationStateAttrKey is the attribute name for the operation state.
	OperationStateAttrKey = attribute.Key("operation_state")

	// TerraformVersionAttrKey is the attribute key for the Terraform version.
	TerraformVersionAttrKey = attribute.Key("terraform_version")

	// SuccessfulOperationState is the value for a successful operation state.
	SuccessfulOperationState = "success"

	// FailedOperationState is the value for a failed operation state.
	FailedOperationState = "failed"
)

Variables

View Source
var (
	// DefaultAsyncOperationMetrics holds async operation metrics definitions.
	DefaultAsyncOperationMetrics = newAsyncOperationMetrics()

	// DefaultRecipeEngineMetrics holds recipe engine metrics definitions.
	DefaultRecipeEngineMetrics = newRecipeEngineMetrics()
)

Functions

func InitMetrics

func InitMetrics() error

InitMetrics initializes metrics for Radius.

func NewRecipeAttributes

func NewRecipeAttributes(operationType, recipeName string, definition *recipes.EnvironmentDefinition, state string) []attribute.KeyValue

NewRecipeAttributes generates common attributes for recipe operations.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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