UploadMetricsController

public struct UploadMetricsController : RouteCollection
  • Declaration

    Swift

    public func boot(routes: RoutesBuilder) throws
  • Gets a Request to process a Log and enqueues it to be processed by ProcessMetricsJob asynchronously. Basically acts as a Fire & Forget endpoint, which is faster that the Sync option. If the Backend is started with the option XCMETRICS_USE_ASYNC_LOG_PROCESSING turned off, this endpoint will not be available (Returns a 404

    Throws

    If the request is not a valid UploadMetricsPayload or there was an error storing the log

    Declaration

    Swift

    public func create(req: Request) throws -> EventLoopFuture<HTTPStatus>

    Parameters

    req

    Request with a validUploadMetricsPayload

    Return Value

    200 HTTP Status if everything is ok. 400 if the request is not an UploadMetricsPayload, 404 if Async processing was turned off (XCMETRICS_USE_ASYNC_LOG_PROCESSING=0) 500 if there was an unexpected error

  • Inserts the build metrics Synchronously which can be slow. Use only if the Async method is not available for instance, if running in CloudRun

    Throws

    If the request is not a valid UploadMetricsPayload or there was an error parsing the Logs or inserting them in the database

    Declaration

    Swift

    public func createSync(req: Request) throws -> EventLoopFuture<HTTPStatus>

    Parameters

    req

    Request with a validUploadMetricsPayload

    Return Value

    201 HTTP Status if everything is ok. 400 if the request is not an UploadMetricsPayload, 500 if there was an unexpected error