MetricsMiddleware

Middleware recording metrics for each request

MetricsMiddleware.swift:27
struct MetricsMiddleware<Context> where Context : RequestContext

Records the number of requests, the request duration and how many errors were thrown. Each metric has additional dimensions URI and method.

Uses Swift-Metrics for recording the metrics. Swift-Metrics has a flexible backend, which will need to be initialized before any metrics are recorded.

A list of implementations is available in the swift-log repository’s README.