diff --git a/metrics/waku-grafana-dashboard.json b/metrics/waku-grafana-dashboard.json index 20b57a382..046ee198e 100644 --- a/metrics/waku-grafana-dashboard.json +++ b/metrics/waku-grafana-dashboard.json @@ -878,6 +878,104 @@ "align": false, "alignLevel": null } + }, + { + "id": 21, + "gridPos": { + "h": 9, + "w": 8, + "x": 16, + "y": 14 + }, + "type": "graph", + "title": "Waku Swap Accounts #0", + "thresholds": [], + "pluginVersion": "8.0.0-beta2", + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "hiddenSeries": false, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "waku_swap_account_state{node=\"0\"}", + "hide": false, + "instant": false, + "interval": "", + "legendFormat": "Peer: {{peer}}", + "refId": "A" + } + ], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + }, + "datasource": null } ], "refresh": "30s", diff --git a/waku/v2/protocol/waku_swap/waku_swap.nim b/waku/v2/protocol/waku_swap/waku_swap.nim index 57c0eef25..bc69d345f 100644 --- a/waku/v2/protocol/waku_swap/waku_swap.nim +++ b/waku/v2/protocol/waku_swap/waku_swap.nim @@ -38,6 +38,7 @@ export waku_swap_types declarePublicGauge waku_swap_peers, "number of swap peers" declarePublicGauge waku_swap_errors, "number of swap protocol errors", ["type"] +declarePublicGauge waku_swap_account_state, "swap account state for each peer", ["peer"] logScope: topics = "wakuswap" @@ -191,6 +192,11 @@ proc handleCheque*(ws: WakuSwap, cheque: Cheque) = info "New accounting state", accounting = ws.accounting[peerId] +# Log Account Metrics +proc logAccountMetrics*(ws: Wakuswap, peer: PeerId) {.async.}= + waku_swap_account_state.set(ws.accounting[peer].int64, labelValues = [$peer]) + + proc init*(wakuSwap: WakuSwap) = info "wakuSwap init 1" proc handle(conn: Connection, proto: string) {.async, gcsafe, closure.} = @@ -242,6 +248,8 @@ proc init*(wakuSwap: WakuSwap) = else: info "Payment threshhold not hit" + waitFor wakuSwap.logAccountMetrics(peerId) + wakuSwap.handler = handle wakuSwap.codec = WakuSwapCodec wakuSwap.credit = credit