Documentation
¶
Overview ¶
Package correlation carries the request-scoped identifiers that every signal is joined on: the request ID and the tenant (observability-reliability.md §3.1).
It lives in core/shared rather than in the observability adapter because both ends need it and they are not allowed to know each other: the REST middleware writes the values, the logger and the metrics read them, and presentation must not import infrastructure (project-structure.md §2).
Only identifiers belong here. The actor and the permissions have their own typed wrapper; a context value is not a place to keep an authorisation decision (ADR-0005).
Index ¶
- func APIClientFrom(ctx context.Context) string
- func ComponentFrom(ctx context.Context) string
- func ContextWithAPIClient(ctx context.Context, clientID string) context.Context
- func ContextWithComponent(ctx context.Context, component string) context.Context
- func ContextWithRequestID(ctx context.Context, id string) context.Context
- func ContextWithTenant(ctx context.Context, tenantID string) context.Context
- func RequestIDFrom(ctx context.Context) string
- func TenantFrom(ctx context.Context) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIClientFrom ¶
APIClientFrom returns the client, or the empty string for a request no app is behind.
func ComponentFrom ¶
ComponentFrom returns the component, or the empty string where nothing named one.
func ContextWithAPIClient ¶
ContextWithAPIClient carries the OAuth client a request acts under (identity.md §15.3): an identifier of a registered app, which is what "audited with the client as a first-class actor attribute" means. An identifier like the other two, never content - which is why it belongs here.
func ContextWithComponent ¶
ContextWithComponent carries which part of the system a line came from: `rest`, `worker.runner`, `worker.scheduler`, and so on (observability-reliability.md §3.1).
It is not the same as `role`, and the difference is why it exists. The role is the *process* and one process may serve several (ADR-0014), so a line from a combined deployment reads `role=api,worker` and says nothing about which loop wrote it. The component is the loop, and it is set once where each one starts rather than at every call site - a field a caller has to remember is a field that is missing from exactly the line being read at three in the morning.
A name, never a workspace or a person: it belongs here for the same reason the other three do.
func ContextWithRequestID ¶
ContextWithRequestID carries the request ID through the call chain. It is what a user quotes in a support request: the one handle that connects a response to a log entry (api-guidelines.md §6).
func ContextWithTenant ¶
ContextWithTenant carries the tenant for the signals. tenant_id is a mandatory log field (§3.1) and the one metric label an operator may switch on (§3.2) - an identifier of an installation, not user content.
This is for observability only. The tenant boundary itself is enforced by the transaction wrapper against the database (ADR-0010), never by reading this value.
func RequestIDFrom ¶
RequestIDFrom returns the request ID, or the empty string outside a request.
func TenantFrom ¶
TenantFrom returns the tenant, or the empty string outside a tenant scope.
Types ¶
This section is empty.