pinax-network / substreams-sink

Substreams Sink library
MIT License
4 stars 1 forks source link

Only provide Prometheus metrics at specific endpoint `/metrics` #12

Closed DenisCarriere closed 1 year ago

DenisCarriere commented 1 year ago

Only provide Prometheus metrics to single HTTP route /metrics, this makes it easier for other routes to be expanded by other HTTP services.

// Create a local server to serve Prometheus metrics
export const server = http.createServer(async (req, res) => {
    if (!req.url) return;
    if (req.method == "GET") {
        if (req.url === "/metrics") {
            res.writeHead(200, { 'Content-Type': prometheus.registry.contentType });
            return res.end(await prometheus.registry.metrics());
        }
    }
});
chamorin commented 1 year ago

Added in commit: https://github.com/pinax-network/substreams-sink/commit/9ffa81024dd133c6ccacc3cd4084f8cb64d4a9ad and bumped up version to v0.9.3

DenisCarriere commented 1 year ago

Published new release