Skip to content

Commit db5bb3d

Browse files
Update README.md (#37)
Fix Vapor 4 metrics endpoint example leading to an NIO leaky promise error at runtime in debug mode.
1 parent 970bd31 commit db5bb3d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ By default, this should be accessible on your main serving port, at the `/metric
111111
```swift
112112
app.get("metrics") { req -> EventLoopFuture<String> in
113113
let promise = req.eventLoop.makePromise(of: String.self)
114-
try MetricsSystem.prometheus().collect(into: promise)
114+
DispatchQueue.global().async {
115+
do {
116+
try MetricsSystem.prometheus().collect(into: promise)
117+
} catch {
118+
promise.fail(error)
119+
}
120+
}
115121
return promise.futureResult
116122
}
117123
```

0 commit comments

Comments
 (0)