swift-server / swift-prometheus

Prometheus client library for Swift

Home Page:https://swiftpackageindex.com/swift-server/swift-prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Async/Await

petershaw opened this issue · comments

Feature Request

We use Prom a lot in Vapor projects. In the contoller we have to handle the future:

    func index(_ req: Request) throws -> EventLoopFuture<String> {
        let promise = req.eventLoop.makePromise(of: String.self)
        try MetricsSystem.prometheus().collect(into: promise)
        return promise.futureResult
    }

This feature request change the usage to

    func index(_ req: Request) async throws -> String {
        return try await MetricsSystem.prometheus().collect()
    }

Motivation Behind Feature

Vapor itself will turn to fully async/await. It would be nice to habe SwiftPrometheus async/await, too.

Feature Description

Support Async/Await

Alternatives or Workarounds

We could write an extension to wrap it into a/a.

Sounds good, feel free to send in a PR implementing this :-)