swift-server/swift-prometheus

Getting prometheusFactoryNotBootstrapped

LukasCZ opened this issue · 1 comments

I am trying to use this in my Vapor 4 app. I have followed the Readme and I'm bootstrapping PrometheusClient in the main configure(_ app: Application) method, like this:

let myPrometheus = PrometheusClient()
MetricsSystem.bootstrap(PrometheusMetricsFactory(client: myPrometheus))

And for the /metrics route, I am using the basic implementation too:

app.get("metrics") { request -> EventLoopFuture<String> in
        let promise = request.eventLoop.makePromise(of: String.self)
        DispatchQueue.global().async {
            do {
                try MetricsSystem.prometheus().collect(into: promise)
            } catch {
                promise.fail(error)
            }
        }
        return promise.futureResult
    }

But when I try accessing /metrics in the web browser, I get the following error:

[ WARNING ] prometheusFactoryNotBootstrapped(bootstrappedWith: "PrometheusMetricsFactory(client: Prometheus.PrometheusClient, configuration: Prometheus.PrometheusMetricsFactory.Configuration(labelSanitizer: Prometheus.PrometheusLabelSanitizer(allowedCharacters: "abcdefghijklmnopqrstuvwxyz0123456789_:"), timerImplementation: Prometheus.PrometheusMetricsFactory.TimerImplementation(_wrapped: Prometheus.PrometheusMetricsFactory.TimerImplementation._Wrapped.summary(defaultQuantiles: [0.01, 0.05, 0.5, 0.9, 0.95, 0.99, 0.999])), defaultRecorderBuckets: Prometheus.Buckets(buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 10.0, 1.7976931348623157e+308])))") [request-id: 1704CFC1-E848-41E3-992A-7DB5CA7B1C0F]

Any help with this would be much appreciated 🙏. And thank you for creating this package!

Thanks for raising! I've opened #49 as a fix