prom: Fix breakage due to msat purge

Closes #450
This commit is contained in:
Christian Decker
2023-05-22 18:27:44 +02:00
parent 1713f9aebb
commit a3d3388d6a
2 changed files with 16 additions and 1 deletions

View File

@@ -32,7 +32,11 @@ class NodeCollector(BaseLnCollector):
value=blockheight,
)
fees_msat = info["msatoshi_fees_collected"]
print(info)
fees_msat = int(info.get(
"fees_collected_msat",
info.get("msatoshi_fees_collected", None)
))
yield GaugeMetricFamily(
'lightning_fees_collected_msat',
'How much have we been paid to route payments?',

View File

@@ -1,5 +1,6 @@
import os
from pyln.testing.fixtures import * # noqa: F401,F403
import urllib
plugin_path = os.path.join(os.path.dirname(__file__), "prometheus.py")
@@ -14,3 +15,13 @@ def test_prometheus_starts(node_factory):
# Then statically
l1.daemon.opts["plugin"] = plugin_path
l1.start()
def test_prometheus_scrape(node_factory):
"""Test that we can scrape correctly.
"""
l1 = node_factory.get_node(options={'plugin': plugin_path})
scrape = urllib.request.urlopen("http://localhost:9750")