amzn / smoke-framework

A light-weight server-side service framework written in the Swift programming language.
Apache License 2.0
1.45k stars 41 forks source link

Migrate to swift-log and swift-metrics. #36

Closed tachyonics closed 4 years ago

tachyonics commented 5 years ago

Issue #, if available: #

Description of changes: Migrate to swift-log and swift-metrics.

New Types

  1. The SmokeServerInvocationReporting type stores the logger and internal request id for a request.
  2. The SmokeServerReportingConfiguration stores configuration on what metrics to record for what operation
  3. The SmokeServerOperationReporting type stores metrics counters for a particular operation and is initialised based on an operation identifier and an SmokeServerReportingConfiguration.
  4. The SmokeServerInvocationContext is the combination of SmokeServerRequestReporting and SmokeServerOperationReporting for a particular invocation (the combination of reporting for the request and reporting for the operation).

Flow Changes

  1. Pass through the logger and internal request id from HTTP1ChannelInboundHandler to the HTTP1RequestHandler.
  2. OperationServerHTTP1RequestHandler creates SmokeServerInvocationContext instances for anonymous request (ping, unknown operation) OTHERWISE
  3. Pass through the logger and internal request id from OperationServerHTTP1RequestHandler to the OperationHandler for the determined operation.
  4. The OperationHandler decorates the request logger if needed and creates the SmokeServerInvocationReporting instance for the request. It then combines it with the SmokeServerOperationReporting instance for that operation into a SmokeServerInvocationContext instance for that request.
  5. The operation handlers can then use the SmokeServerInvocationContext to call the operation handler.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.