Skip to content

X-Request-Id support #190

@jace

Description

@jace

To facilitate log correlation, Baseframe must check for the X-Request-Id header in incoming requests and play it back in the outgoing response. If the header is missing in incoming (Nginx must provide it), it must be generated.

In API calls, the caller may provide this header, so it could originate even before Nginx. This requires the header to be sanitised as downstream uses (PostgreSQL) may have limitations on what it can contain. Our expected use case is a UUID1 or UUID4. (Caveat: since third party values are not guaranteed unique, we may want to treat it as a distinct X-Correlation-Id header and log both.)

PostgreSQL does not support such a header, but instead supports a set application_name command that can be issued at the beginning of a connection. This value can be included in logs. Assuming it is safe to issue this command on every transaction, Baseframe must facilitate this via a SQLAlchemy signal.

In addition:

  1. If Flask supports this header in any way, such built in support must be used.
  2. SQLAlchemy is not known to support this, so we have to add our patches.
  3. Coaster's error logging must include this.
  4. Hasjob's event logging must support this.
  5. The id must be included in HTML pages as a data header on the body element for future uses. Error pages may want to include it as visible element to facilitate customer support (for example, a mailto link to support with this id included in the subject).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions