Skip to content

Commit

Permalink
fix pr
Browse files Browse the repository at this point in the history
  • Loading branch information
leon mandel authored and leon mandel committed Sep 19, 2024
1 parent d0826b9 commit 08d53e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions protocol/chainlib/consumer_ws_subscription_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ func (cwsm *ConsumerWSSubscriptionManager) StartSubscription(
utils.LogAttr("GUID", webSocketCtx),
utils.LogAttr("hashedParams", utils.ToHexString(hashedParams)),
utils.LogAttr("dappKey", dappKey),
utils.LogAttr("connectedDapps", cwsm.connectedDapps),
)

websocketRepliesChan := make(chan *pairingtypes.RelayReply)
Expand Down Expand Up @@ -530,22 +529,22 @@ func (cwsm *ConsumerWSSubscriptionManager) listenForSubscriptionMessages(
utils.LogAttr("GUID", webSocketCtx),
utils.LogAttr("hashedParams", utils.ToHexString(hashedParams)),
)
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.UserDisconnect)
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.WS_DISCONNECTION_REASON_USER)
return
case <-replyServer.Context().Done():
utils.LavaFormatTrace("reply server context canceled",
utils.LogAttr("GUID", webSocketCtx),
utils.LogAttr("hashedParams", utils.ToHexString(hashedParams)),
)
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.ConsumerDisconnect)
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.WS_DISCONNECTION_REASON_CONSUMER)
return
default:
var reply pairingtypes.RelayReply
err := replyServer.RecvMsg(&reply)
if err != nil {
// The connection was closed by the provider
utils.LavaFormatTrace("error reading from subscription stream", utils.LogAttr("original error", err.Error()))
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.ProviderDisconnect)
go cwsm.consumerMetricsManager.SetWsSubscriptioDisconnectRequestMetric(metricsData.ChainID, metricsData.APIType, metrics.WS_DISCONNECTION_REASON_PROVIDER)
return
}
err = cwsm.handleIncomingSubscriptionNodeMessage(hashedParams, &reply, providerAddr)
Expand Down
18 changes: 9 additions & 9 deletions protocol/metrics/metrics_consumer_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
type WsDisconnectReasonEnum int

const (
ConsumerDisconnect WsDisconnectReasonEnum = iota
ProviderDisconnect WsDisconnectReasonEnum = iota
UserDisconnect WsDisconnectReasonEnum = iota
WS_DISCONNECTION_REASON_CONSUMER WsDisconnectReasonEnum = iota
WS_DISCONNECTION_REASON_PROVIDER
WS_DISCONNECTION_REASON_USER
)

var disconnectReasonMap = map[WsDisconnectReasonEnum]string{
ConsumerDisconnect: "ConsumerDisconnect",
ProviderDisconnect: "ProviderDisconnect",
UserDisconnect: "UserDisconnect",
WS_DISCONNECTION_REASON_CONSUMER: "consumer-disconnect",
WS_DISCONNECTION_REASON_PROVIDER: "provider-disconnect",
WS_DISCONNECTION_REASON_USER: "user-disconnect",
}

type LatencyTracker struct {
Expand Down Expand Up @@ -108,17 +108,17 @@ func NewConsumerMetricsManager(options ConsumerMetricsManagerOptions) *ConsumerM

totalWsSubscriptionRequestsMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "lava_consumer_total_ws_subscription_requests",
Help: "The total number of websocket subscription requests by the consumer over time per chain id per api interface.",
Help: "The total number of websocket subscription requests over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})

totalFailedWsSubscriptionRequestsMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "lava_consumer_total_failed_ws_subscription_requests",
Help: "The total number of failed websocket subscription requests by the consumer over time per chain id per api interface.",
Help: "The total number of failed websocket subscription requests over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})

totalDuplicatedWsSubscriptionRequestsMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "lava_consumer_total_duplicated_ws_subscription_requests",
Help: "The total number of duplicated webscket subscription requests by the consumer over time per chain id per api interface.",
Help: "The total number of duplicated webscket subscription requests over time per chain id per api interface.",
}, []string{"spec", "apiInterface"})

totalWsSubscriptionDissconnectMetric := prometheus.NewCounterVec(prometheus.CounterOpts{
Expand Down

0 comments on commit 08d53e8

Please sign in to comment.