Documentation
¶
Index ¶
- Constants
- Variables
- func NewTSSPrometheusClient() (*tssPrometheusClient, error)
- func ParseHTTPResponseStatus(resp *http.Response, reqErr error) (status, statusCode string)
- func PrometheusMetrics() map[MetricTag]prometheus.Collector
- type CircleLabels
- type DBQueryLabels
- type DisbursementLabels
- type HttpRequestLabels
- type MetricOptions
- type MetricTag
- type MetricType
- type Metrics
- type MonitorClient
- type MonitorService
- func (m *MonitorService) GetMetricHttpHandler() (http.Handler, error)
- func (m *MonitorService) GetMetricType() (MetricType, error)
- func (m *MonitorService) MonitorCounters(tag MetricTag, labels map[string]string) error
- func (m *MonitorService) MonitorDBQueryDuration(duration time.Duration, tag MetricTag, labels DBQueryLabels) error
- func (m *MonitorService) MonitorDuration(duration time.Duration, tag MetricTag, labels map[string]string) error
- func (m *MonitorService) MonitorHistogram(value float64, tag MetricTag, labels map[string]string) error
- func (m *MonitorService) MonitorHttpRequestDuration(duration time.Duration, labels HttpRequestLabels) error
- func (m *MonitorService) Start(opts MetricOptions) error
- type MonitorServiceInterface
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 CircleLabelNames = []string{"method", "endpoint", "status", "status_code", "tenant_name"}
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: "business", Name: string(DisbursementsCounterTag), Help: "Disbursements Counter", }, []string{"asset", "wallet"}, ), CircleAPIRequestsTotalTag: prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "sdp", Subsystem: "circle", Name: string(CircleAPIRequestsTotalTag), Help: "A counter of the Circle API requests", }, CircleLabelNames, ), }
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{ CircleAPIRequestDurationTag: prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "sdp", Subsystem: "circle", Name: string(CircleAPIRequestDurationTag), Help: "A histogram of the Circle API request durations", }, CircleLabelNames, ), }
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 NewTSSPrometheusClient ¶
func NewTSSPrometheusClient() (*tssPrometheusClient, error)
NewTSSPrometheusClient registers Prometheus metrics for the Transaction Submission Service
func ParseHTTPResponseStatus ¶
func PrometheusMetrics ¶
func PrometheusMetrics() map[MetricTag]prometheus.Collector
Types ¶
type CircleLabels ¶
type CircleLabels struct { Method string Endpoint string Status string StatusCode string TenantName string }
func (CircleLabels) ToMap ¶
func (c CircleLabels) ToMap() map[string]string
type DBQueryLabels ¶
type DBQueryLabels struct {
QueryType string
}
type DisbursementLabels ¶
func (DisbursementLabels) ToMap ¶
func (d DisbursementLabels) ToMap() map[string]string
type HttpRequestLabels ¶
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" // Circle API Requests CircleAPIRequestDurationTag MetricTag = "circle_api_request_duration_seconds" CircleAPIRequestsTotalTag MetricTag = "circle_api_requests_total" )
func (MetricTag) ListAllTSSMetricTags ¶
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
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 (*MonitorService) MonitorHistogram ¶
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 }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.