Report CI/CD observability metric durations in seconds

What does this MR do and why?

Gitlab::Observability::PipelineToMetrics treated pipeline and job durations as milliseconds, but Gitlab::DataBuilder::Pipeline sends seconds. CommitStatus#duration, CommitStatus#queued_duration and Ci::Pipeline#duration all come from Ci::HasStatus#calculate_duration, which returns seconds.

As a result:

  • pipeline.duration_seconds, pipeline.queue_duration_seconds and gitlab.cicd.pipeline.run.queued_duration were divided by 1000, so a 300-second pipeline reported 0.3.
  • build_histogram_buckets compared each value against bound * 1000, so every job and pipeline duration under 1000 seconds landed in the first bucket.
  • The specs didn't catch it because the shared fixture used millisecond values (duration: 120000).

This MR:

  • Uses the duration values as seconds in every gauge and histogram, and compares histogram values against the bounds directly.
  • Changes pipeline_converter_shared_context.rb to seconds, so the fixture matches the real payload. Trace and log specs only change their expected values, because those converters already passed the value through unchanged.
  • Rewrites pipeline_to_metrics_spec.rb as table-driven examples with shared lookup helpers (609 to about 330 lines), adds a bucket-boundary table and a skipped result-mapping row, and removes duplicated exemplar examples.
  • Fixes the docs: the trace and log attribute tables said milliseconds, but the export has always sent seconds there. Adds a history note to the Metrics section.

The section duration histogram planned in gitlab-org/embody-team/experimental-observability/documentation#179 reuses build_histogram_buckets, so this fix is a prerequisite for that work.

Impact

Exported duration values become 1000 times larger, and histogram bucket counts change. Dashboards or alerts built on the old values need adjusting. The feature is an experiment.

How to verify

bin/rspec spec/lib/gitlab/observability/pipeline_to_metrics_spec.rb \
  spec/lib/gitlab/observability/pipeline_to_traces_spec.rb \
  spec/lib/gitlab/observability/pipeline_to_logs_spec.rb

Restoring the old / 1000.0 and bound * 1000 code makes 10 of the metrics examples fail.

spec/services/ci/observability/export_service_spec.rb was not run locally (missing Gitaly test setup). It doesn't reference durations.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Closes gitlab-org/embody-team/experimental-observability/documentation#176 (closed)

Merge request reports

Loading
Loading