This is a significant refactor of the farcaster exporter.
I started with the goal of adding features to serve the metrics directly over http, rather than relying on the prometheus node exporter. This was challenging because of the global state and calls to terminate that caused the entire program to exit.
This refactor removes all global variables, implements separate daemon and miner subclasses of the lotus class, and uses context and with as statements to handle writing out the final metrics for collection time and success status.
As for features this adds several. First of all farcaster will now use the same environment variables that lotus does FULLNODE_API_INFO and MINER_API_INFO to discover the urls and tokens. Falling back to looking for the files in LOTUS_PATH and LOTUS_MINER_PATH. Command line arguments are also supported which take priority.
Farcaster can now write to a file directly without relying on redirection in a cron job, using the --file option. And the feature I originally set out to build, farcaster can now listen on a TCP port and serve metrics directly to prometheus for scraping. It also supports sytemd socket activation so that farcaster can automatically be started when prometheus tries to scrape it. Sample service and socket unit files have been added.
These changes should be backwards compatible and not change anything about the metrics exported.
This is a significant refactor of the farcaster exporter.
I started with the goal of adding features to serve the metrics directly over http, rather than relying on the prometheus node exporter. This was challenging because of the global state and calls to terminate that caused the entire program to exit.
This refactor removes all global variables, implements separate daemon and miner subclasses of the lotus class, and uses context and
with as
statements to handle writing out the final metrics for collection time and success status.As for features this adds several. First of all farcaster will now use the same environment variables that lotus does
FULLNODE_API_INFO
andMINER_API_INFO
to discover the urls and tokens. Falling back to looking for the files inLOTUS_PATH
andLOTUS_MINER_PATH
. Command line arguments are also supported which take priority.Farcaster can now write to a file directly without relying on redirection in a cron job, using the
--file
option. And the feature I originally set out to build, farcaster can now listen on a TCP port and serve metrics directly to prometheus for scraping. It also supports sytemd socket activation so that farcaster can automatically be started when prometheus tries to scrape it. Sample service and socket unit files have been added.These changes should be backwards compatible and not change anything about the metrics exported.