Built-in build stage span instrumentation

Summary

Instrument GitLab Runner to emit child spans for each built-in build stage under the job_execution parent span. This is Phase 2 of Runner instrumentation — builds on the OTLP export client and job_execution span from Phase 1.

Build Stages to Instrument

Each stage becomes a child span of job_execution:

Span Name Description
prepare_executor Executor setup (Docker, Kubernetes, etc.)
pull_image Container image pull
get_sources Git clone/fetch
restore_cache Cache download and extraction
step_script Main script execution
after_script After-script execution
archive_cache Cache creation and upload
upload_artifacts Artifact upload

Metadata to Capture

Each span should include relevant attributes:

  • pull_image: ci.image.name, ci.image.tag, ci.image.pull_policy
  • get_sources: ci.git.operation (clone/fetch), ci.git.depth, ci.git.filter
  • restore_cache / archive_cache: ci.cache.key, ci.cache.hit (boolean), ci.cache.size_bytes
  • upload_artifacts: ci.artifact.name, ci.artifact.type, ci.artifact.size_bytes
  • All stages: ci.stage.status (success/failed), duration via span timing

Requirements

  1. Create child spans under the job_execution span from Phase 1
  2. Stream spans to the OTEL Collector as each stage completes (not batched at job end)
  3. Spans must have accurate start/end timestamps
  4. Failed stages should set span status to ERROR with a description

Architecture Reference

  • GitLab Runner changes
  • Span format and CI Function types

Related

  • Phase 1 (prerequisite): #39232 (closed), #39231
  • Phase 3 (CI Functions): #39271
  • Parent epic: &20633
Edited Feb 19, 2026 by Pedro Pombeiro
Assignee Loading
Time tracking Loading