Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prom: Fix breakage due to msat purge #451

Merged
merged 2 commits into from
Jul 20, 2023
Merged

Conversation

cdecker
Copy link
Contributor

@cdecker cdecker commented May 22, 2023

Closes #450

@bleetube
Copy link

Probably a red herring (ie. something I did wrong) but using this branch with v23.05.1 resulted in:

Exception occurred during processing of request from ('127.0.0.1', 40712)
Traceback (most recent call last):
  File \"/usr/lib/python3.11/socketserver.py\", line 691, in process_request_thread
    self.finish_request(request, client_address)
  File \"/usr/lib/python3.11/socketserver.py\", line 361, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File \"/usr/lib/python3.11/socketserver.py\", line 755, in __init__
    self.handle()
  File \"/usr/lib/python3.11/http/server.py\", line 432, in handle
    self.handle_one_request()
  File \"/usr/lib/python3.11/http/server.py\", line 420, in handle_one_request
    method()
  File \"/home/lightning/.local/lib/python3.11/site-packages/prometheus_client/exposition.py\", line 151, in do_GET
    output = encoder(registry)
             ^^^^^^^^^^^^^^^^^
  File \"/home/lightning/.local/lib/python3.11/site-packages/prometheus_client/exposition.py\", line 89, in generate_latest
    for metric in registry.collect():
  File \"/home/lightning/.local/lib/python3.11/site-packages/prometheus_client/registry.py\", line 75, in collect
    for metric in collector.collect():
  File \"/home/lightning/src/plugins/prometheus/prometheus.py\", line 52, in collect
    [o['amount_msat'].to_satoshi() for o in funds['outputs']]
  File \"/home/lightning/src/plugins/prometheus/prometheus.py\", line 52, in <listcomp>  
    [o['amount_msat'].to_satoshi() for o in funds['outputs']]
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'to_satoshi'

Guessing I am missing another change that would make o['amount_msat'] into something other than just an integer. If so, please disregard.

@cdecker
Copy link
Contributor Author

cdecker commented Jun 12, 2023

Good catch, int(o['amount_msat']) instead of to_msatoshi should work on both old and new versions

@cdecker cdecker force-pushed the 202305-prometheus-msat-purge branch from d84776c to f45e61c Compare July 19, 2023 17:10
@cdecker
Copy link
Contributor Author

cdecker commented Jul 19, 2023

Ok, finally found the time to fix this one up. Now the tests also create a channel and ensure that listpeers and listpeerchannels are parsed correctly.

@bleetube
Copy link

It's been a minute, but I think the error I mentioned above was actually due to the attr name change. I submitted a PR a few weeks ago #459

I still need to figure out how to run these internal tests, but they look pretty useful.

@cdecker cdecker merged commit ce078bb into master Jul 20, 2023
2 of 8 checks passed
@cdecker cdecker deleted the 202305-prometheus-msat-purge branch July 20, 2023 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prometheus: update for CLN v23.05 with msat purge
2 participants