monitor

package
v0.0.0-...-4a8fab6 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Metric Tags
	HorizonErrorCounterTag                  MetricTag = "error_count"
	TransactionQueuedToCompletedLatencyTag  MetricTag = "queued_to_completed_latency_seconds"
	TransactionStartedToCompletedLatencyTag MetricTag = "started_to_completed_latency_seconds"
	TransactionRetryCountTag                MetricTag = "retry_count"
	TransactionProcessedCounterTag          MetricTag = "processed_count"

	// Metric Labels
	TransactionStatusSuccessLabel string = "success"
	TransactionStatusErrorLabel   string = "error"

	TransactionErrorBuildFeeBumpLabel string = "building_feebump_txn"
	TransactionErrorSignFeeBumpLebel  string = "sign_feebump_txn"
	TransactionErrorBuildPaymentLabel string = "building_payment_txn"
	TransactionErrorSignPaymentLebel  string = "sign_payment_txn"
	TransactionErrorSubmitLabel       string = "submitting_payment"
	TransactionErrorInvalidStateLabel string = "invalid_state"
	TransactionErrorHashingTxnLabel   string = "hashing_txn"
	TransactionErrorSavingHashLabel   string = "saving_hash"

	// Payment metric tags
	PaymentProcessingStartedTag        MetricTag = "payment_processing_started"
	PaymentTransactionSuccessfulTag    MetricTag = "payment_transaction_successful"
	PaymentReconciliationSuccessfulTag MetricTag = "payment_reconciliation_successful"
	PaymentReconciliationFailureTag    MetricTag = "payment_reconciliation_failure"
	PaymentErrorTag                    MetricTag = "payment_error"

	PaymentProcessingStartedLabel                   string = "payment_processing_started"
	PaymentProcessingSuccessfulLabel                string = "payment_processing_successful"
	PaymentReprocessingSuccessfulLabel              string = "payment_reprocessing_successful"
	PaymentReconciliationTransactionSuccessfulLabel string = "payment_reconciliation_transaction_successful"
	PaymentReconciliationMarkedForReprocessingLabel string = "payment_reconciliation_marked_for_reprocessing"
	PaymentReconciliationUnexpectedErrorLabel       string = "payment_reconciliation_unexpected_error"
	PaymentMarkedForReprocessingLabel               string = "payment_marked_for_reprocessing"
	PaymentFailedLabel                              string = "payment_failed"
)

Variables

View Source
var CounterMetrics = map[MetricTag]prometheus.Counter{
	AnchorPlatformAuthProtectionEnsuredCounterTag: prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "sdp", Subsystem: "anchor_platform", Name: string(AnchorPlatformAuthProtectionEnsuredCounterTag),
		Help: "A counter of how many times the anchor platform auth protection was ensured",
	}),
	AnchorPlatformAuthProtectionMissingCounterTag: prometheus.NewCounter(prometheus.CounterOpts{
		Namespace: "sdp", Subsystem: "anchor_platform", Name: string(AnchorPlatformAuthProtectionMissingCounterTag),
		Help: "A counter of how many times the anchor platform auth protection check revealed the AP is not protected",
	}),
}
View Source
var CounterTSSMetrics = map[MetricTag]prometheus.Counter{}
View Source
var CounterTSSVecMetrics = map[MetricTag]*prometheus.CounterVec{
	TransactionProcessedCounterTag: prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tss",
		Subsystem: "tx_processing",
		Name:      string(TransactionProcessedCounterTag),
		Help:      "Count of transactions processed by TSS",
	},
		[]string{"retried", "result", "error_type"},
	),
	HorizonErrorCounterTag: prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tss",
		Subsystem: "horizon_client",
		Name:      string(HorizonErrorCounterTag),
		Help:      "Count of Horizon related errors",
	},
		[]string{"status_code", "result_code"},
	),

	PaymentProcessingStartedTag: prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tss",
			Name:      string(PaymentProcessingStartedTag),
			Help:      "Count of payments that are starting to process",
		},
		paymentLabelNames,
	),
	PaymentTransactionSuccessfulTag: prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tss",
			Name:      string(PaymentTransactionSuccessfulTag),
			Help:      "Count of payments that have processed successfully",
		},
		paymentLabelNames,
	),
	PaymentReconciliationSuccessfulTag: prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tss",
			Name:      string(PaymentReconciliationSuccessfulTag),
			Help:      "Count of payments that have completed reconciliation successfully",
		},
		paymentLabelNames,
	),
	PaymentReconciliationFailureTag: prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tss",
			Name:      string(PaymentReconciliationFailureTag),
			Help:      "Count of payments that have failed reconciliation",
		},
		paymentLabelNames,
	),
	PaymentErrorTag: prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tss",
			Name:      string(PaymentErrorTag),
			Help:      "Count of payments that have failed onchain",
		},
		paymentLabelNames,
	),
}
View Source
var CounterVecMetrics = map[MetricTag]*prometheus.CounterVec{
	DisbursementsCounterTag: prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "sdp", Subsystem: "bussiness", Name: string(DisbursementsCounterTag),
		Help: "Disbursements Counter",
	},
		[]string{"asset", "country", "wallet"},
	),
}
View Source
var HistogramTSSVecMetrics = map[MetricTag]*prometheus.HistogramVec{
	TransactionQueuedToCompletedLatencyTag: prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tss",
		Subsystem: "tx_processing",
		Name:      string(TransactionQueuedToCompletedLatencyTag),
		Help:      "Latency (seconds) taken from when a Transaction was created to when it completed (Success/Error status)",
		Buckets:   prometheus.LinearBuckets(5, 5, 24),
	},
		[]string{"retried", "result", "error_type"},
	),
	TransactionStartedToCompletedLatencyTag: prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tss",
		Subsystem: "tx_processing",
		Name:      string(TransactionStartedToCompletedLatencyTag),
		Help:      "Latency (seconds) taken from when a Transaction was started to when it completed (Success/Error status)",
		Buckets:   prometheus.LinearBuckets(5, 5, 24),
	},
		[]string{"retried", "result", "error_type"},
	),
	TransactionRetryCountTag: prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tss",
		Subsystem: "tx_processing",
		Name:      string(TransactionRetryCountTag),
		Help:      "Transaction retry count",
		Buckets:   prometheus.LinearBuckets(1, 1, 3),
	},
		[]string{"retried", "result", "error_type"},
	),
}
View Source
var HistogramVecMetrics map[MetricTag]prometheus.HistogramVec
View Source
var SummaryTSSVecMetrics = map[MetricTag]*prometheus.SummaryVec{
	SuccessfulQueryDurationTag: prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: "tss",
		Subsystem: "db",
		Name:      string(SuccessfulQueryDurationTag),
		Help:      "Successful DB query durations",
	},
		[]string{"query_type"},
	),
	FailureQueryDurationTag: prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: "tss",
		Subsystem: "db",
		Name:      string(FailureQueryDurationTag),
		Help:      "Failure DB query durations",
	},
		[]string{"query_type"},
	),
}
View Source
var SummaryVecMetrics = map[MetricTag]*prometheus.SummaryVec{
	HttpRequestDurationTag: prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: "sdp", Subsystem: "http", Name: string(HttpRequestDurationTag),
		Help: "HTTP requests durations, sliding window = 10m",
	},
		[]string{"status", "route", "method"},
	),
	SuccessfulQueryDurationTag: prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: "sdp", Subsystem: "db", Name: string(SuccessfulQueryDurationTag),
		Help: "Successful DB query durations",
	},
		[]string{"query_type"},
	),
	FailureQueryDurationTag: prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: "sdp", Subsystem: "db", Name: string(FailureQueryDurationTag),
		Help: "Failure DB query durations",
	},
		[]string{"query_type"},
	),
}

Functions

func NewPrometheusClient

func NewPrometheusClient() (*prometheusClient, error)

func NewTSSPrometheusClient

func NewTSSPrometheusClient() (*tssPrometheusClient, error)

NewTSSPrometheusClient registers Prometheus metrics for the Transaction Submission Service

Types

type DBQueryLabels

type DBQueryLabels struct {
	QueryType string
}

type DisbursementLabels

type DisbursementLabels struct {
	Asset   string
	Country string
	Wallet  string
}

func (DisbursementLabels) ToMap

func (d DisbursementLabels) ToMap() map[string]string

type HttpRequestLabels

type HttpRequestLabels struct {
	Status string
	Route  string
	Method string
}

type MetricOptions

type MetricOptions struct {
	MetricType  MetricType
	Environment string
}

type MetricTag

type MetricTag string
const (
	SuccessfulQueryDurationTag MetricTag = "successful_queries_duration"
	FailureQueryDurationTag    MetricTag = "failure_queries_duration"
	HttpRequestDurationTag     MetricTag = "requests_duration_seconds"
	// Disbursements:
	DisbursementsCounterTag MetricTag = "disbursements_counter"
	// AnchorPlatformAuthProtection
	AnchorPlatformAuthProtectionEnsuredCounterTag MetricTag = "anchor_platform_auth_protection_ensured_counter"
	AnchorPlatformAuthProtectionMissingCounterTag MetricTag = "anchor_platform_auth_protection_missing_counter"
)

func (MetricTag) ListAll

func (m MetricTag) ListAll() []MetricTag

func (MetricTag) ListAllTSSMetricTags

func (m MetricTag) ListAllTSSMetricTags() []MetricTag

type MetricType

type MetricType string
const (
	MetricTypePrometheus    MetricType = "PROMETHEUS"
	MetricTypeTSSPrometheus MetricType = "TSS_PROMETHEUS"
)

func ParseMetricType

func ParseMetricType(metricTypeStr string) (MetricType, error)

type Metrics

type Metrics map[logrus.Level]prometheus.Counter

Metrics is a logrus hook-compliant struct that records metrics about logging when added to a logrus.Logger

func (*Metrics) Fire

func (m *Metrics) Fire(e *logrus.Entry) error

Fire is triggered by logrus, in response to a logging event

func (*Metrics) Levels

func (m *Metrics) Levels() []logrus.Level

Levels returns the logging levels that will trigger this hook to run. In this case, all of them.

type MonitorClient

type MonitorClient interface {
	GetMetricHttpHandler() http.Handler
	GetMetricType() MetricType
	MonitorHttpRequestDuration(duration time.Duration, labels HttpRequestLabels)
	MonitorDBQueryDuration(duration time.Duration, tag MetricTag, labels DBQueryLabels)
	MonitorCounters(tag MetricTag, labels map[string]string)
	MonitorDuration(duration time.Duration, tag MetricTag, labels map[string]string)
	MonitorHistogram(value float64, tag MetricTag, labels map[string]string)
}

func GetClient

func GetClient(opts MetricOptions) (MonitorClient, error)

type MonitorService

type MonitorService struct {
	MonitorClient MonitorClient
}

func (*MonitorService) GetMetricHttpHandler

func (m *MonitorService) GetMetricHttpHandler() (http.Handler, error)

func (*MonitorService) GetMetricType

func (m *MonitorService) GetMetricType() (MetricType, error)

func (*MonitorService) MonitorCounters

func (m *MonitorService) MonitorCounters(tag MetricTag, labels map[string]string) error

func (*MonitorService) MonitorDBQueryDuration

func (m *MonitorService) MonitorDBQueryDuration(duration time.Duration, tag MetricTag, labels DBQueryLabels) error

func (*MonitorService) MonitorDuration

func (m *MonitorService) MonitorDuration(duration time.Duration, tag MetricTag, labels map[string]string) error

func (*MonitorService) MonitorHistogram

func (m *MonitorService) MonitorHistogram(value float64, tag MetricTag, labels map[string]string) error

func (*MonitorService) MonitorHttpRequestDuration

func (m *MonitorService) MonitorHttpRequestDuration(duration time.Duration, labels HttpRequestLabels) error

func (*MonitorService) Start

func (m *MonitorService) Start(opts MetricOptions) error

type MonitorServiceInterface

type MonitorServiceInterface interface {
	Start(opts MetricOptions) error
	GetMetricType() (MetricType, error)
	GetMetricHttpHandler() (http.Handler, error)
	MonitorHttpRequestDuration(duration time.Duration, labels HttpRequestLabels) error
	MonitorDBQueryDuration(duration time.Duration, tag MetricTag, labels DBQueryLabels) error
	MonitorCounters(tag MetricTag, labels map[string]string) error
	MonitorDuration(duration time.Duration, tag MetricTag, labels map[string]string) error
	MonitorHistogram(value float64, tag MetricTag, labels map[string]string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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