Skip to content

Expose cycle and lead time metrics via GraphQL

What does this MR do and why?

This MR exposes the last two flow metrics via GraphQL: lead time and cycle time.

Example queries:

Group level:

query groupLevel {
  group(fullPath: "vsmg-1678197394") {
    name
    flowMetrics {
      leadTime(from: "2023-02-01", to: "2023-04-01") {
        value
        title
        links {
          url
          name
        }
      }
      cycleTime(from: "2023-02-01", to: "2023-04-01") {
        value
        title
        links {
          url
          name
        }
      }
    }
  }
}

Project level:

query projectLevel {
  project(fullPath: "vsmg-1678197394/vsmp-1678197394") {
    name
    flowMetrics {
      leadTime(from: "2023-02-01", to: "2023-04-01") {
        value
        title
        links {
          url
          name
        }
      }
      cycleTime(from: "2023-02-01", to: "2023-04-01") {
        value
        title
        links {
          url
          name
        }
      }
    }
  }
}

How to set up and validate locally

  1. Ensure you're on Ultimate plan
  2. Seed VSA: SEED_CYCLE_ANALYTICS=true SEED_VSA=true FILTER=cycle_analytics rake db:seed_fu
  3. The seed script prints the project path, go to your browser and navigate to the group.
  4. Go to: Analytics -> CycleAnalytics
  5. Create a new value stream (default one)
  6. Go to rails console and run: Analytics::CycleAnalytics::IncrementalWorker.new.perform
  7. Invoking the example GraphQL queries (replace the paths) should return some data.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #387162 (closed)

Edited by Adam Hegyi

Merge request reports