metric

package
v0.0.0-...-efbd42f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VaaCountMeasurement       = "vaa_count"
	VaaVolumeMeasurement      = "vaa_volume_v2"
	VaaAllMessagesMeasurement = "vaa_count_all_messages"
)

Variables

This section is empty.

Functions

func MakePointForVaaCount

func MakePointForVaaCount(vaa *sdk.VAA) (*write.Point, error)

MakePointForVaaCount generates a data point for the VAA count measurement.

Some VAAs will not generate a measurement, so the caller must always check whether the returned point is nil.

func MakePointForVaaVolume

func MakePointForVaaVolume(params *MakePointForVaaVolumeParams) (*write.Point, error)

MakePointForVaaVolume builds the InfluxDB volume metric for a given VAA

Some VAAs will not generate a measurement, so the caller must always check whether the returned point is nil.

Types

type MakePointForVaaVolumeParams

type MakePointForVaaVolumeParams struct {

	// Vaa is the VAA for which we want to compute the volume metric
	Vaa *sdk.VAA

	// TokenPriceFunc returns the price of the given token at the specified timestamp.
	TokenPriceFunc func(tokenID string, timestamp time.Time) (decimal.Decimal, error)

	// Logger is an optional parameter, in case the caller wants additional visibility.
	Logger *zap.Logger

	// Metrics is in case the caller wants additional visibility.
	Metrics metrics.Metrics

	// TransferredToken is the token that was transferred in the VAA.
	TransferredToken *token.TransferredToken
}

MakePointForVaaVolumeParams contains input parameters for the function `MakePointForVaaVolume`

type Metric

type Metric struct {
	// contains filtered or unexported fields
}

Metric definition.

func New

func New(
	ctx context.Context,
	db *mongo.Database,
	influxCli influxdb2.Client,
	organization string,
	bucketInifite string,
	bucket30Days string,
	bucket24Hours string,
	notionalCache deltaswapscanNotionalCache.NotionalLocalCacheReadable,
	metrics metrics.Metrics,
	getTransferredTokenByVaa token.GetTransferredTokenByVaa,
	logger *zap.Logger,
) (*Metric, error)

New create a new *Metric.

func (*Metric) Close

func (m *Metric) Close()

Close influx client.

func (*Metric) Push

func (m *Metric) Push(ctx context.Context, vaa *sdk.VAA) error

Push implement MetricPushFunc definition.

type MetricPushFunc

type MetricPushFunc func(context.Context, *vaa.VAA) error

MetricPushFunc is a function to push metrics

type TransferPriceDoc

type TransferPriceDoc struct {
	// ID is the unique identifier of the VAA for which we are storing price information.
	ID string `bson:"_id"`
	// Timestamp is the timestamp of the VAA for which we are storing price information.
	Timestamp time.Time `bson:"timestamp"`
	// Symbol is the trading symbol of the token being transferred.
	Symbol string `bson:"symbol"`
	// SymbolPriceUsd is the price of the token in USD at the moment of the transfer.
	SymbolPriceUsd string `bson:"price"`
	// TokenAmount is the amount of the token being transferred.
	TokenAmount string `bson:"tokenAmount"`
	// UsdAmount is the value in USD of the token being transferred.
	UsdAmount string `bson:"usdAmount"`
}

TransferPriceDoc models a document in the `transferPrices` collection

Jump to

Keyboard shortcuts

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