metrics

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DBMeterName is the name of the meter for DB metrics. Use the global DB
	// instance to access use these metrics.
	DBMeterName = "github.com/kwilteam/kwil-db/node/pg"

	// RPCMeterName is the name of the meter for RPC metrics. Use the global RPC
	// instance to access use these metrics.
	RPCMeterName = "github.com/kwilteam/kwil-db/node/services/jsonrpc" // currently the http server, but may be used in services like services/jsonrpc/usersvc

	NodeMeterName = "github.com/kwilteam/kwil-db/node" // node and node/peers

	EngineMeterName = "github.com/kwilteam/kwil-db/node/engine" // maybe split into engine/interpreter and engin/parse and engine/planner

	ConsensusMeterName = "github.com/kwilteam/kwil-db/node/consensus"

	BlockProcessorMeterName = "github.com/kwilteam/kwil-db/node/block_processor"

	MempoolMeterName = "github.com/kwilteam/kwil-db/node/mempool"

	BlockStoreMeterName = "github.com/kwilteam/kwil-db/node/store"

	AccountsMeterName = "github.com/kwilteam/kwil-db/node/accounts"
)

Variables

View Source
var (
	RPC       RPCMetrics       = rpcMetrics{}
	DB        DBMetrics        = dbMetrics{}
	Consensus ConsensusMetrics = consensusMetrics{}
	Node      NodeMetrics      = nodeMetrics{}
	Store     StoreMetrics     = storeMetrics{}
)

These are the global instances of the metrics grouped by the meter name. Until and unless Start is called, these are no-op meters.

Functions

func StartOTEL

func StartOTEL(ctx context.Context, options ...OTELOption) (func(context.Context) error, error)

StartOTEL bootstraps the OpenTelemetry pipeline. The collected metrics are exported to the specified OTLP (opentelemetry protocol) collector HTTP endpoint. The endpoint is in host port format, with no schema, as it uses unencrypted HTTP currently. If it does not return an error, make sure to call shutdown for proper cleanup.

Types

type ConsensusMetrics

type ConsensusMetrics interface {
	RecordCommit(ctx context.Context, latency time.Duration, height int64)
	RecordExecuted(ctx context.Context, latency time.Duration, height, numTxns int64)
}

type DBMetrics

type DBMetrics interface {
	AcquiredConnections(ctx context.Context, dbName string)
	ReleasedConnection(ctx context.Context)
	RecordQuery(ctx context.Context, crudType string, duration time.Duration)
	RecordQueryFailure(ctx context.Context, crudType string, err error)
}

type NodeMetrics

type NodeMetrics interface {
	PeerCount(ctx context.Context, numPeers int)
	DownloadedBlock(ctx context.Context, blockHeight, size int64)
	ServedBlock(ctx context.Context, blockHeight, size int64)
	Advertised(ctx context.Context, protocol string)
	AdvertiseRejected(ctx context.Context, protocol string)
	AdvertiseServed(ctx context.Context, protocol string, contentLen int64)
	TxnsReannounced(ctx context.Context, num, totalSize int64)
}

type OTELOption

type OTELOption func(*otelOptions)

func WithOTELEndpoint

func WithOTELEndpoint(endpoint string) OTELOption

func WithOTELInterval

func WithOTELInterval(interval time.Duration) OTELOption

type RPCMetrics

type RPCMetrics interface {
	RecordRequest(ctx context.Context, method string, status int, latency time.Duration)
}

type StoreMetrics

type StoreMetrics interface {
	BlockStored(ctx context.Context, blockHeight, size int64)
	BlockRetrieved(ctx context.Context, blockHeight, size int64)
	TransactionRetrieved(ctx context.Context)
}

Jump to

Keyboard shortcuts

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