Skip to content
Ona Docs

GetPrTimeSeries

client.Usage.GetPrTimeSeries(ctx, body) (*UsageGetPrTimeSeriesResponse, error)
POST/gitpod.v1.UsageService/GetPrTimeSeries

Gets PR speed metrics as a time series.

Use this method to:

  • Chart pull request lead time, review latency, and deploy counts
  • Select hourly, daily, weekly, or monthly buckets
  • Scope PR speed insights to a project, user, or team

Example

dateRange:
  startTime: "2024-01-01T00:00:00Z"
  endTime: "2024-02-01T00:00:00Z"
resolution: RESOLUTION_WEEKLY
projectId: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
ParametersExpand Collapse
body UsageGetPrTimeSeriesParams
DateRange param.Field[DateRange]

Date range to query within.

ProjectID param.Field[string]Optional

Optional project ID to scope results.

Resolution param.Field[Resolution]Optional

Time resolution for the series data.

TeamID param.Field[string]Optional

Optional team ID to scope results to a specific team. Mutually exclusive with user_id.

UserID param.Field[string]Optional

Optional user ID to scope results to a specific user. Mutually exclusive with team_id.

ReturnsExpand Collapse
type UsageGetPrTimeSeriesResponse struct{…}
TimeSeries []PrTimeBucketOptional

Time series of PR speed metrics, bucketed by the requested resolution.

Deploys stringOptional

Total number of deploys (merged PRs) in this bucket.

LeadTimeSeconds float64Optional

Median lead time in seconds for PRs merged in this bucket.

formatdouble
PrsMergedCount stringOptional

Number of PRs merged in this bucket.

StartTime TimeOptional

Start of this time bucket.

formatdate-time
TimeToFirstApprovalSeconds float64Optional

Median time to first approval in seconds for PRs in this bucket. Zero when no PRs in the bucket had approvals.

formatdouble

GetPrTimeSeries

package main

import (
  "context"
  "fmt"
  "time"

  "github.com/gitpod-io/gitpod-sdk-go"
  "github.com/gitpod-io/gitpod-sdk-go/option"
  "github.com/gitpod-io/gitpod-sdk-go/shared"
)

func main() {
  client := gitpod.NewClient(
    option.WithBearerToken("My Bearer Token"),
  )
  response, err := client.Usage.GetPrTimeSeries(context.TODO(), gitpod.UsageGetPrTimeSeriesParams{
    DateRange: gitpod.F(shared.DateRangeParam{
      EndTime: gitpod.F(time.Now()),
      StartTime: gitpod.F(time.Now()),
    }),
    ProjectID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
    Resolution: gitpod.F(gitpod.ResolutionWeekly),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.TimeSeries)
}
{
  "timeSeries": [
    {
      "deploys": "deploys",
      "leadTimeSeconds": 0,
      "prsMergedCount": "prsMergedCount",
      "startTime": "2019-12-27T18:11:19.117Z",
      "timeToFirstApprovalSeconds": 0
    }
  ]
}
Returns Examples
{
  "timeSeries": [
    {
      "deploys": "deploys",
      "leadTimeSeconds": 0,
      "prsMergedCount": "prsMergedCount",
      "startTime": "2019-12-27T18:11:19.117Z",
      "timeToFirstApprovalSeconds": 0
    }
  ]
}