leviysoft / mockingbird

Flexible mock server
Apache License 2.0
13 stars 3 forks source link

proposal: Extracting/injecting trace info from/to headers #24

Closed ashashev closed 10 months ago

ashashev commented 1 year ago

Adding extracting tracing info from headers of HTTP and gRPC calls and adding them to response headers.

The configuration example:

{
    "tracing": {
      "required": ["correlationId", "traceId"],
      "incomingHeaders": {
        "X-Trace-ID": "traceId",
        "X-Request-ID": "traceId"
      },
      "outcomingHeaders": {
        "correlationId": "X-Correlation-ID",
        "traceId": "X-Trace-ID"
      }
    }
}

The required field contains the list of obligated tracing fields. These fields always exist, it means when a client calls, the mockingbird generates for these fields unique ID (UUID).

The incomingHeaders set matching between request headers that contain tracing info and tracing field on the Mockingbird side. Comparing the headers is case-insensitive. For the config above, if request contains "X-Trace-ID" or "X-Request-ID", its value overrides generated value of traceId field.

The outcomingHeaders specified which tracing fields should be returned in response headers.

@mockingbird/maintainers