Implement trace context initialization in Rails for CI job telemetry
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
Implement trace context initialization in Rails so that all telemetry spans for a CI job share the same trace_id. The trace context is passed to the Runner in the job payload response when job_telemetry is enabled.
Job payload change
Add a trace_context object to the /api/v4/jobs/request response (only when job_telemetry is enabled):
{
"trace_context": {
"trace_id": "00000000000000000000000002a6c18e",
"parent_span_id": "a1b2c3d4e5f60718"
}
}
| Field | Type | Description |
|---|---|---|
trace_id |
String (32-char hex) | Deterministically derived from job_id. All spans for this job share this trace ID. |
parent_span_id |
String (16-char hex) | The span ID of the Rails-created job_lifecycle span (Phase 3). For MVC this is a placeholder root — the Runner's job_execution span becomes the trace root and will be re-parented once Phase 3 adds the Rails job_lifecycle span. |
Requirements
- Generate
trace_iddeterministically fromjob_id(e.g., zero-padded hex representation, or UUID v5) - Generate
parent_span_idas a random 16-char hex span ID (placeholder for MVC; becomes the actualjob_lifecyclespan ID in Phase 3) - Only include
trace_contextwhen thejob_telemetryfeature is enabled (see #590588)
Architecture Reference
Dependencies
- Feature negotiation (#590588) must be implemented first —
trace_contextis only included whenjob_telemetryis enabled - Coordinate with grouprunner core on job payload schema changes (&20633)
Parent Epic
Edited by 🤖 GitLab Bot 🤖