node: use promauto to auto-register metrics
Fixes certusone/wormhole#188 Change-Id: I26c0e3f05993e44185b6ee2531b7673f7fbc0eb6
This commit is contained in:
parent
fe48f05366
commit
514560f52c
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/certusone/wormhole/bridge/pkg/p2p"
|
||||
gossipv1 "github.com/certusone/wormhole/bridge/pkg/proto/gossip/v1"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"math/big"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -25,48 +26,39 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ethConnectionErrors = prometheus.NewCounterVec(
|
||||
ethConnectionErrors = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_eth_connection_errors_total",
|
||||
Help: "Total number of Ethereum connection errors (either during initial connection or while watching)",
|
||||
}, []string{"reason"})
|
||||
|
||||
ethMessagesObserved = prometheus.NewCounter(
|
||||
ethMessagesObserved = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_eth_messages_observed_total",
|
||||
Help: "Total number of Eth messages observed (pre-confirmation)",
|
||||
})
|
||||
ethMessagesConfirmed = prometheus.NewCounter(
|
||||
ethMessagesConfirmed = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_eth_messages_confirmed_total",
|
||||
Help: "Total number of Eth messages verified (post-confirmation)",
|
||||
})
|
||||
guardianSetChangesConfirmed = prometheus.NewCounter(
|
||||
guardianSetChangesConfirmed = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_eth_guardian_set_changes_confirmed_total",
|
||||
Help: "Total number of guardian set changes verified (we only see confirmed ones to begin with)",
|
||||
})
|
||||
currentEthHeight = prometheus.NewGauge(
|
||||
currentEthHeight = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "wormhole_eth_current_height",
|
||||
Help: "Current Ethereum block height",
|
||||
})
|
||||
queryLatency = prometheus.NewHistogramVec(
|
||||
queryLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "wormhole_eth_query_latency",
|
||||
Help: "Latency histogram for Ethereum calls (note that most interactions are streaming queries, NOT calls, and we cannot measure latency for those",
|
||||
}, []string{"operation"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(ethConnectionErrors)
|
||||
prometheus.MustRegister(ethMessagesObserved)
|
||||
prometheus.MustRegister(ethMessagesConfirmed)
|
||||
prometheus.MustRegister(guardianSetChangesConfirmed)
|
||||
prometheus.MustRegister(currentEthHeight)
|
||||
prometheus.MustRegister(queryLatency)
|
||||
}
|
||||
|
||||
type (
|
||||
EthBridgeWatcher struct {
|
||||
url string
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/certusone/wormhole/bridge/pkg/version"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -30,29 +31,23 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
p2pHeartbeatsSent = prometheus.NewCounter(
|
||||
p2pHeartbeatsSent = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_p2p_heartbeats_sent_total",
|
||||
Help: "Total number of p2p heartbeats sent",
|
||||
})
|
||||
p2pMessagesSent = prometheus.NewCounter(
|
||||
p2pMessagesSent = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_p2p_broadcast_messages_sent_total",
|
||||
Help: "Total number of p2p pubsub broadcast messages sent",
|
||||
})
|
||||
p2pMessagesReceived = prometheus.NewCounterVec(
|
||||
p2pMessagesReceived = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_p2p_broadcast_messages_received_total",
|
||||
Help: "Total number of p2p pubsub broadcast messages received",
|
||||
}, []string{"type"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(p2pHeartbeatsSent)
|
||||
prometheus.MustRegister(p2pMessagesSent)
|
||||
prometheus.MustRegister(p2pMessagesReceived)
|
||||
}
|
||||
|
||||
func Run(obsvC chan *gossipv1.SignedObservation,
|
||||
sendC chan []byte,
|
||||
rawHeartbeatListeners *publicrpc.RawHeartbeatConns,
|
||||
|
|
|
@ -3,6 +3,7 @@ package processor
|
|||
import (
|
||||
"encoding/hex"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"time"
|
||||
|
||||
ethcommon "github.com/ethereum/go-ethereum/common"
|
||||
|
@ -14,17 +15,13 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
observationsBroadcastTotal = prometheus.NewCounter(
|
||||
observationsBroadcastTotal = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_broadcast_total",
|
||||
Help: "Total number of signed observations queued for broadcast",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(observationsBroadcastTotal)
|
||||
}
|
||||
|
||||
func (p *Processor) broadcastSignature(v *vaa.VAA, signature []byte) {
|
||||
digest, err := v.SigningMsg()
|
||||
if err != nil {
|
||||
|
|
|
@ -4,53 +4,45 @@ import (
|
|||
"context"
|
||||
"github.com/certusone/wormhole/bridge/pkg/common"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var (
|
||||
aggregationStateEntries = prometheus.NewGauge(
|
||||
aggregationStateEntries = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "wormhole_aggregation_state_entries",
|
||||
Help: "Current number of aggregation state entries (including unexpired succeed ones)",
|
||||
})
|
||||
aggregationStateExpiration = prometheus.NewCounter(
|
||||
aggregationStateExpiration = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_aggregation_state_expirations_total",
|
||||
Help: "Total number of expired submitted aggregation states",
|
||||
})
|
||||
aggregationStateTimeout = prometheus.NewCounter(
|
||||
aggregationStateTimeout = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_aggregation_state_timeout_total",
|
||||
Help: "Total number of aggregation states expired due to timeout after exhausting retries",
|
||||
})
|
||||
aggregationStateRetries = prometheus.NewCounter(
|
||||
aggregationStateRetries = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_aggregation_state_retries_total",
|
||||
Help: "Total number of aggregation states queued for resubmission",
|
||||
})
|
||||
aggregationStateUnobserved = prometheus.NewCounter(
|
||||
aggregationStateUnobserved = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_aggregation_state_unobserved_total",
|
||||
Help: "Total number of aggregation states expired due to no matching local message observations",
|
||||
})
|
||||
aggregationStateFulfillment = prometheus.NewCounterVec(
|
||||
aggregationStateFulfillment = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_aggregation_state_settled_signatures_total",
|
||||
Help: "Total number of signatures produced by a validator, counted after waiting a fixed amount of time",
|
||||
}, []string{"addr", "origin", "status"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(aggregationStateEntries)
|
||||
prometheus.MustRegister(aggregationStateExpiration)
|
||||
prometheus.MustRegister(aggregationStateTimeout)
|
||||
prometheus.MustRegister(aggregationStateRetries)
|
||||
prometheus.MustRegister(aggregationStateUnobserved)
|
||||
prometheus.MustRegister(aggregationStateFulfillment)
|
||||
}
|
||||
|
||||
// handleCleanup handles periodic retransmissions and cleanup of VAAs
|
||||
func (p *Processor) handleCleanup(ctx context.Context) {
|
||||
p.logger.Info("aggregation state summary", zap.Int("cached", len(p.state.vaaSignatures)))
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/hex"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"go.uber.org/zap"
|
||||
|
@ -13,17 +14,13 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
vaaInjectionsTotal = prometheus.NewCounter(
|
||||
vaaInjectionsTotal = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_vaa_injections_total",
|
||||
Help: "Total number of injected VAA queued for broadcast",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(vaaInjectionsTotal)
|
||||
}
|
||||
|
||||
// handleInjection processes a pre-populated VAA injected locally.
|
||||
func (p *Processor) handleInjection(ctx context.Context, v *vaa.VAA) {
|
||||
// Generate digest of the unsigned VAA.
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/hex"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"go.uber.org/zap"
|
||||
|
@ -17,14 +18,14 @@ var (
|
|||
// SECURITY: source_chain/target_chain are untrusted uint8 values. An attacker could cause a maximum of 255**2 label
|
||||
// pairs to be created, which is acceptable.
|
||||
|
||||
messagesObservedTotal = prometheus.NewCounterVec(
|
||||
messagesObservedTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_message_observations_total",
|
||||
Help: "Total number of messages observed",
|
||||
},
|
||||
[]string{"emitter_chain"})
|
||||
|
||||
messagesSignedTotal = prometheus.NewCounterVec(
|
||||
messagesSignedTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_message_observations_signed_total",
|
||||
Help: "Total number of message observations that were successfully signed",
|
||||
|
@ -32,11 +33,6 @@ var (
|
|||
[]string{"emitter_chain"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(messagesObservedTotal)
|
||||
prometheus.MustRegister(messagesSignedTotal)
|
||||
}
|
||||
|
||||
// handleMessage processes a message received from a chain and instantiates our deterministic copy of the VAA. An
|
||||
// event may be received multiple times and must be handled in an idempotent fashion.
|
||||
func (p *Processor) handleMessage(ctx context.Context, k *common.MessagePublication) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
bridge_common "github.com/certusone/wormhole/bridge/pkg/common"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
@ -17,47 +18,38 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
observationsReceivedTotal = prometheus.NewCounter(
|
||||
observationsReceivedTotal = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_received_total",
|
||||
Help: "Total number of raw VAA observations received from gossip",
|
||||
})
|
||||
observationsReceivedByGuardianAddressTotal = prometheus.NewCounterVec(
|
||||
observationsReceivedByGuardianAddressTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_signed_by_guardian_total",
|
||||
Help: "Total number of signed and verified VAA observations grouped by guardian address",
|
||||
}, []string{"addr"})
|
||||
observationsFailedTotal = prometheus.NewCounterVec(
|
||||
observationsFailedTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_verification_failures_total",
|
||||
Help: "Total number of observations verification failure, grouped by failure reason",
|
||||
}, []string{"cause"})
|
||||
observationsUnknownTotal = prometheus.NewCounter(
|
||||
observationsUnknownTotal = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_unknown_total",
|
||||
Help: "Total number of verified observations we haven't seen ourselves",
|
||||
})
|
||||
observationsDirectSubmissionsTotal = prometheus.NewCounterVec(
|
||||
observationsDirectSubmissionsTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_direct_submissions_queued_total",
|
||||
Help: "Total number of observations for a specific target chain that were queued for direct submission",
|
||||
}, []string{"target_chain"})
|
||||
observationsDirectSubmissionSuccessTotal = prometheus.NewCounterVec(
|
||||
observationsDirectSubmissionSuccessTotal = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_observations_direct_submission_success_total",
|
||||
Help: "Total number of observations for a specific target chain that succeeded",
|
||||
}, []string{"target_chain"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(observationsReceivedTotal)
|
||||
prometheus.MustRegister(observationsReceivedByGuardianAddressTotal)
|
||||
prometheus.MustRegister(observationsFailedTotal)
|
||||
prometheus.MustRegister(observationsUnknownTotal)
|
||||
prometheus.MustRegister(observationsDirectSubmissionsTotal)
|
||||
prometheus.MustRegister(observationsDirectSubmissionSuccessTotal)
|
||||
}
|
||||
|
||||
// handleObservation processes a remote VAA observation, verifies it, checks whether the VAA has met quorum,
|
||||
// and assembles and submits a valid VAA if possible.
|
||||
func (p *Processor) handleObservation(ctx context.Context, m *gossipv1.SignedObservation) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package publicrpc
|
||||
|
||||
import (
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"math/rand"
|
||||
"sync"
|
||||
|
||||
|
@ -12,17 +13,13 @@ import (
|
|||
|
||||
// track the number of active connections
|
||||
var (
|
||||
currentPublicHeartbeatStreamsOpen = prometheus.NewGauge(
|
||||
currentPublicHeartbeatStreamsOpen = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "wormhole_publicrpc_rawheartbeat_connections",
|
||||
Help: "Current number of clients consuming gRPC raw heartbeat streams",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(currentPublicHeartbeatStreamsOpen)
|
||||
}
|
||||
|
||||
// RawHeartbeatConns holds the multiplexing state required for distribution of
|
||||
// heartbeat messages to all the open connections.
|
||||
type RawHeartbeatConns struct {
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/mr-tron/base58"
|
||||
"github.com/near/borsh-go"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"go.uber.org/zap"
|
||||
"time"
|
||||
)
|
||||
|
@ -26,41 +27,33 @@ type SolanaWatcher struct {
|
|||
}
|
||||
|
||||
var (
|
||||
solanaConnectionErrors = prometheus.NewCounterVec(
|
||||
solanaConnectionErrors = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_solana_connection_errors_total",
|
||||
Help: "Total number of Solana connection errors",
|
||||
}, []string{"reason"})
|
||||
solanaAccountSkips = prometheus.NewCounterVec(
|
||||
solanaAccountSkips = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_solana_account_updates_skipped_total",
|
||||
Help: "Total number of account updates skipped due to invalid data",
|
||||
}, []string{"reason"})
|
||||
solanaMessagesConfirmed = prometheus.NewCounter(
|
||||
solanaMessagesConfirmed = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_solana_observations_confirmed_total",
|
||||
Help: "Total number of verified Solana observations found",
|
||||
})
|
||||
currentSolanaHeight = prometheus.NewGauge(
|
||||
currentSolanaHeight = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "wormhole_solana_current_height",
|
||||
Help: "Current Solana slot height (at default commitment level, not the level used for observations)",
|
||||
})
|
||||
queryLatency = prometheus.NewHistogramVec(
|
||||
queryLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "wormhole_solana_query_latency",
|
||||
Help: "Latency histogram for Solana RPC calls",
|
||||
}, []string{"operation", "commitment"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(solanaConnectionErrors)
|
||||
prometheus.MustRegister(solanaAccountSkips)
|
||||
prometheus.MustRegister(solanaMessagesConfirmed)
|
||||
prometheus.MustRegister(currentSolanaHeight)
|
||||
prometheus.MustRegister(queryLatency)
|
||||
}
|
||||
|
||||
func NewSolanaWatcher(wsUrl, rpcUrl string, bridgeAddress solana.PublicKey, messageEvents chan *common.MessagePublication) *SolanaWatcher {
|
||||
return &SolanaWatcher{bridge: bridgeAddress, wsUrl: wsUrl, rpcUrl: rpcUrl, messageEvent: messageEvents}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"github.com/certusone/wormhole/bridge/pkg/p2p"
|
||||
gossipv1 "github.com/certusone/wormhole/bridge/pkg/proto/gossip/v1"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
@ -36,35 +37,28 @@ type (
|
|||
)
|
||||
|
||||
var (
|
||||
terraConnectionErrors = prometheus.NewCounterVec(
|
||||
terraConnectionErrors = promauto.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_terra_connection_errors_total",
|
||||
Help: "Total number of Terra connection errors",
|
||||
}, []string{"reason"})
|
||||
terraMessagesConfirmed = prometheus.NewCounter(
|
||||
terraMessagesConfirmed = promauto.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
Name: "wormhole_terra_messages_confirmed_total",
|
||||
Help: "Total number of verified terra messages found",
|
||||
})
|
||||
currentTerraHeight = prometheus.NewGauge(
|
||||
currentTerraHeight = promauto.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "wormhole_terra_current_height",
|
||||
Help: "Current terra slot height (at default commitment level, not the level used for observations)",
|
||||
})
|
||||
queryLatency = prometheus.NewHistogramVec(
|
||||
queryLatency = promauto.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Name: "wormhole_terra_query_latency",
|
||||
Help: "Latency histogram for terra RPC calls",
|
||||
}, []string{"operation"})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(terraConnectionErrors)
|
||||
prometheus.MustRegister(terraMessagesConfirmed)
|
||||
prometheus.MustRegister(currentTerraHeight)
|
||||
prometheus.MustRegister(queryLatency)
|
||||
}
|
||||
|
||||
type clientRequest struct {
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
// A String containing the name of the method to be invoked.
|
||||
|
|
Loading…
Reference in New Issue