Problem to solve
2 of my pipeline jobs always generated a new trace ID which looks pretty odd in Jaeger.

After identifying the pattern being the use of needs for asynchronous pipeline execution, I have found searched for needs requires artifacts because I remembered that needs explicitly requires to specify artifact dependencies or similar discussions.
Found
Proposal
Document the workaround with needs:artifacts
generate-trace-id:
stage: preparation
before_script: []
after_script: []
script:
- echo "main_trace_id=$(openssl rand -hex 16)" >> variables.env
- echo "main_span_id=$(openssl rand -hex 8)" >> variables.env
- echo "main_trace_start_time=$(date +%s)" >> variables.env
artifacts:
# Debug: Expose variables.env as artifact
paths:
- "variables.env"
reports:
dotenv: variables.env # Use artifacts:reports:dotenv to expose the variables to other jobs
# Note: Asynchronous jobs with `needs` do not download artifacts from previous stages by default.
# https://docs.gitlab.com/ee/ci/yaml/#needsartifacts
# All jobs using needs will need to explicitly specify this job.
# Example:
# needs:
# - job: generate-trace-id
# artifacts: true
test-cpp:
stage: test
# TODO: Verify if the heavy job needs to run for tests
needs:
- build-cpp
- build-cpp-heavy
# Require the tracepusher job artifacts explicitly
- job: generate-trace-id
artifacts: true
script:
- ci/test_cpp.sh
deploy-cloudnative:
stage: deploy
# TODO: Why is the deploy-rhel8 dependency needed?
needs:
- deploy-rhel8
- build-go
- build-cpp
# Require the tracepusher job artifacts explicitly
- job: generate-trace-id
artifacts: true
script:
- ci/deploy/prepare.sh
- ci/deploy/prepare_env.sh
- ci/deploy/provision_env.sh
- ci/deploy/deploy_app.sh
- ci/deploy/observe_app.sh
- ci/deploy/collect_profiling.sh
Tests in this MR https://gitlab.com/gitlab-de/use-cases/observability/devsecops-efficiency/slow-pipeline-for-analysis/-/merge_requests/1 and pipeline https://gitlab.com/gitlab-de/use-cases/observability/devsecops-efficiency/slow-pipeline-for-analysis/-/pipelines/920935030
Problem to solve
2 of my pipeline jobs always generated a new trace ID which looks pretty odd in Jaeger.
After identifying the pattern being the use of
needsfor asynchronous pipeline execution, I have found searched forneeds requires artifactsbecause I remembered that needs explicitly requires to specify artifact dependencies or similar discussions.Found
Proposal
Document the workaround with
needs:artifactsTests in this MR https://gitlab.com/gitlab-de/use-cases/observability/devsecops-efficiency/slow-pipeline-for-analysis/-/merge_requests/1 and pipeline https://gitlab.com/gitlab-de/use-cases/observability/devsecops-efficiency/slow-pipeline-for-analysis/-/pipelines/920935030