Repository navigation
feat(correlation): request_id from the host correlation provider, opt-in correlation_id / upstream_id (1.27.0) - #95
Merged
Conversation
…-in correlation_id / upstream_id Adopt nowo-tech/correlation-contract ^0.1 (Beacon spec 235 FR-002 / FR-005). The main request's request_id comes from the host's CorrelationIdProviderInterface service when one is registered (read at kernel.request and kernel.response), else it is generated as before. correlation.columns maps nullable correlation_id (shared by web, named channel, outbound and mailer rows of a request) and upstream_id (X-Request-Id / X-Correlation-Id / traceparent trace-id, trusted proxies only, validated), with indexes, exact collation, admin filters, entry fields and export columns. Spec 005, UPGRADING To 1.27.0 with per-platform DDL.
|
@coderabbitai review |
… correlation_id One indexed lookup on (correlation_id, created_at) returns a request's web row (correlation_id = request_id), its named inbound channel rows and its outbound / mailer rows; covered on MySQL 8.4, MariaDB 11.4 and PostgreSQL 16. UPGRADING and CHANGELOG state it explicitly.
…HL-M1) request_id stays HttpLog's own generated unique id for every row, as in 1.26: a provider id that repeats can no longer collapse or drop rows. The provider's id only becomes the correlation id (ATTR_CORRELATION_ID, correlation_id, HttpLogEntryRecordedEvent::$correlationId), read on the main request at kernel.request, kernel.response and kernel.terminate (I1). L1: outbound calls and mails re-read the provider when recorded if it had no id at their start (HttpLogContext::correlationIdAtCapture()). I2: upstream_headers is replaced, not merged, by a later config file. I3: tests for two main requests with the same provider id (sync and async, SQLite and MySQL / MariaDB / PostgreSQL) and a provider throwing at kernel.response. L2 / L3: docs state that a trusted proxy must overwrite the upstream headers, and the CHANGELOG no longer claims a request_id change.
HecFranco
marked this pull request as ready for review
November 28, 2026 08:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Beacon spec 235 T002 / FR-002 / FR-005: HttpLog adopts
nowo-tech/correlation-contract^0.1. Target 1.27.0 (minor, no BC break). Spec:specs/005-correlation-ids/spec.md.Provider wiring (
correlation.use_provider, defaulttrue)Correlation\CorrelationIdsreads the host'sNowo\CorrelationContract\CorrelationIdProviderInterfaceservice through aNULL_ON_INVALID_REFERENCEreference. HttpLog registers no provider or alias itself, so a host without one keeps the 1.26 ids exactly.HttpLogSubscribersets the main request'sATTR_REQUEST_IDfromprovider->current()atkernel.request(1024) and again atkernel.response(-1024), so a provider that starts its unit of work after HttpLog's listener still wins, and a provider that clears its id before HttpLog's terminate listener (-1024) does not matter. No current id (or a throwing provider): generated as before. Sub-requests keep a generated id.request_idstays the row's unique dedupe key (async retry guard). Outbound and mailer rows therefore cannot share it (several per request): they keep their own unique event id, and the shared id goes tocorrelation_id(below) and to the newHttpLogEntryRecordedEvent::$correlationId.HttpLogFramegainscorrelationId, filled byHttpLogContext::current()at call time (provider id, else the main request'srequest_id, else null). The frame is taken when the call or the send starts, so the value matches the request / message that made it.Trusted-proxy rule (
upstream_id)correlation.columns: true, only for the main request, only whenRequest::isFromTrustedProxy()(framework.trusted_proxies). Headers in order fromcorrelation.upstream_headers(defaultX-Request-Id,X-Correlation-Id,traceparent; at most 4, validated names).traceparent→CorrelationId::tryFromTraceparent(), others →tryFromString(). First valid value wins; anything untrusted or invalid is dropped silently (raw values never logged). Kept on the request (ATTR_UPSTREAM_ID), never in a service (worker mode). Never replacesrequest_id.Columns / migration (
correlation.columns, defaultfalse, literal boolean)Doctrine\CorrelationColumnsListener(registered only when on, likeerror_code) maps nullablecorrelation_id/upstream_idVARCHAR(64)(=CorrelationId::MAX_LENGTH) and indexesidx_http_log_corr_id (correlation_id, created_at)/idx_http_log_upstream (upstream_id, created_at)(24 chars max, withinTablePrefixListener's fixed-name budget). Exact-match collation on MySQL / MariaDB (ExactColumnsCollationListener::COLUMNS), since ids are case-sensitive.correlation-ddl:*), verified byUsageSchemaTest::documentedCorrelationDdlLeavesNoSchemaDiffon SQLite / MySQL / PostgreSQL with the three prefix variants.correlationId/upstreamIdfilters (independent of the usage columns), both ids on the entry page; export criteria keep them. CSV / JSON exports appendcorrelationId,upstreamIdlast; CSV cells go through the existing formula neutralisation.Response header (item 4)
Skipped: HttpLog owns no response header today (it never writes to the response), so echoing
X-Request-Idstays with the provider's integration (documented).Why a hard
requirenowo-tech/correlation-contracthas no dependency beyond PHP (interfaces, one value object, a null provider, header constants). The bundle type-hintsCorrelationIdProviderInterfacein a service constructor and usesCorrelationIdfor validation on every capture path; a soft dependency would needinterface_existsguards and duplicate validation for no gain. The demo lock is updated (check-demo-lock.py).Tests
CorrelationIdsTest,HttpLogSubscriberCorrelationTest,CorrelationExtensionTest, context / capture / guard / inbound recorder / filter form additions.CorrelationColumnsTest(mapping, writes, case-sensitive filters, events, exports), documented DDL, exact collation, admin pages render.databasegroup:CorrelationColumnsDbTeston MySQL 8.4, MariaDB 11.4, PostgreSQL 16 (prefixed indexes, exact matching).Docs
CHANGELOG [Unreleased], UPGRADING "To 1.27.0", CONFIGURATION
correlationsection (+ full tree), README, spec 005, code inventory (also maps the 3error_codefiles 1.26 left out: 145/145).🤖 Generated with Claude Code