telemetry

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package telemetry provides a set of functions for incrementing counters which track various events across the codebase. Typically, calls to these counter functions SHOULD be made inside deferred anonymous functions so that they will reference the final values of their inputs. Any instrumented piece of code which contains branching logic with respect its counter function inputs is subject to this constraint (i.e. MUST defer).

Index

Constants

View Source
const (
	// DefaultCardinalityLevel represents the default cardinality level for metrics collection
	DefaultCardinalityLevel = "medium"
)

Default configuration values for telemetry

Variables

View Source
var (
	DefaultCounterFn = func() float32 { return 1 }
)

Functions

func BurnedTokensFromModule added in v0.0.11

func BurnedTokensFromModule(module string, amount float32)

BurnedTokensFromModule is a function to track token burning from a specific module. The metric used is an increment counter, and the label includes the module name for context.

func ClaimComputeUnitsCounter added in v0.0.3

func ClaimComputeUnitsCounter(
	claimProofStage string,
	numComputeUnits uint64,
	serviceId string,
	applicationAddress string,
	supplierOperatorAddress string,
	err error,
)

ClaimComputeUnitsCounter increments a counter which tracks the number of compute units which are represented by onchain claims at the given ClaimProofStage. If err is not nil, the counter is not incremented but Prometheus will ingest this event.

func ClaimCounter added in v0.0.3

func ClaimCounter(
	claimProofStage string,
	numClaims uint64,
	serviceId string,
	applicationAddress string,
	supplierOperatorAddress string,
	err error,
)

ClaimCounter increments a counter which tracks the number of claims at the given ClaimProofStage. If err is not nil, the counter is not incremented but Prometheus will ingest this event.

func ClaimRelaysCounter added in v0.0.4

func ClaimRelaysCounter(
	claimProofStage string,
	numRelays uint64,
	serviceId string,
	applicationAddress string,
	supplierOperatorAddress string,
	err error,
)

ClaimRelaysCounter increments a counter which tracks the number of relays represented by onchain claims at the given ClaimProofStage. If err is not nil, the counter is not incremented and an "error" label is added with the error's message. I.e., Prometheus will ingest this event.

func EventSuccessCounter

func EventSuccessCounter(
	eventType string,
	getValue func() float32,
	isSuccessful func() bool,
)

EventSuccessCounter increments a counter with the given data type and success status.

func InitBlockMetrics

func InitBlockMetrics(app *baseapp.BaseApp)

InitBlockMetrics initializes the block-specific metrics for the application.

func MetricNameKeys added in v0.0.11

func MetricNameKeys(metrics ...string) []string

MetricNameKeys prefixes metrics with `poktroll` for easy identification. E.g., `("hodlers", "regret_level")` yields `poktroll_hodlers_regret_level` — great for tracking FOMO as hodlers rethink choices. Returns a slice of strings as `go-metric`, the underlying metrics library, expects.

func MintedTokensFromModule added in v0.0.11

func MintedTokensFromModule(module string, amount float32)

MintedTokensFromModule is a function to track token minting from a specific module. The metric used is an increment counter, and the label includes the module name for context.

func New added in v0.0.11

func New(appOpts servertypes.AppOptions) error

New sets the globalTelemetryConfig for telemetry package.

func ProofRequirementCounter added in v0.0.3

func ProofRequirementCounter(
	reason string,
	serviceId string,
	applicationAddress string,
	supplierOperatorAddress string,
	err error,
)

ProofRequirementCounter increments a counter which tracks the number of claims which require proof for the given proof requirement reason (i.e. not required, probabilistic selection, above compute unit threshold). If err is not nil, the counter is not incremented but Prometheus will ingest this event.

func RelayEMAGauge added in v0.0.3

func RelayEMAGauge(relayEMA uint64, serviceId string)

RelayEMAGauge sets a gauge which tracks the relay EMA for a service. The serviceId is used as a label to be able to track the EMA for each service.

func RelayMiningDifficultyGauge added in v0.0.3

func RelayMiningDifficultyGauge(difficulty float32, serviceId string)

RelayMiningDifficultyGauge sets a gauge which tracks the integer representation of the relay mining difficulty. The serviceId is used as a label to be able to track the difficulty for each service.

func SessionSuppliersGauge added in v0.0.11

func SessionSuppliersGauge(numCandidates int, maxPerSession int, serviceId string)

SessionSuppliersGauge sets a gauge which tracks the number of candidates available for session suppliers at the given maxPerSession value. The serviceId is used as a label to be able to track this information for each service.

func SlashedTokensFromModule added in v0.0.11

func SlashedTokensFromModule(module string, amount float32)

SlashedTokensFromModule is a function to track token slashing from a specific module. The metric used is an increment counter, and the label includes the module name for context.

Types

type PoktrollTelemetryConfig added in v0.0.11

type PoktrollTelemetryConfig struct {
	CardinalityLevel string `mapstructure:"cardinality-level"`
}

PoktrollTelemetryConfig represents the telemetry portion of the custom poktroll config section in `app.toml`.

func DefaultConfig added in v0.0.12

func DefaultConfig() PoktrollTelemetryConfig

DefaultConfig returns the default telemetry configuration

Jump to

Keyboard shortcuts

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