Skip to content
Ona Docs

GetPrTimeSeries

usage.get_pr_time_series(UsageGetPrTimeSeriesParams**kwargs) -> UsageGetPrTimeSeriesResponse
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
date_range: DateRange

Date range to query within.

end_time: datetime

End time of the date range (exclusive).

formatdate-time
start_time: datetime

Start time of the date range (inclusive).

formatdate-time
project_id: Optional[str]

Optional project ID to scope results.

resolution: Optional[Resolution]

Time resolution for the series data.

One of the following:
"RESOLUTION_UNSPECIFIED"
"RESOLUTION_HOURLY"
"RESOLUTION_DAILY"
"RESOLUTION_WEEKLY"
"RESOLUTION_MONTHLY"
team_id: Optional[str]

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

user_id: Optional[str]

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

ReturnsExpand Collapse
class UsageGetPrTimeSeriesResponse:
time_series: Optional[List[PrTimeBucket]]

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

deploys: Optional[str]

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

lead_time_seconds: Optional[float]

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

formatdouble
prs_merged_count: Optional[str]

Number of PRs merged in this bucket.

start_time: Optional[datetime]

Start of this time bucket.

formatdate-time
time_to_first_approval_seconds: Optional[float]

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

formatdouble

GetPrTimeSeries

import os
from datetime import datetime
from gitpod import Gitpod

client = Gitpod(
    bearer_token=os.environ.get("GITPOD_API_KEY"),  # This is the default and can be omitted
)
response = client.usage.get_pr_time_series(
    date_range={
        "end_time": datetime.fromisoformat("2024-02-01T00:00:00"),
        "start_time": datetime.fromisoformat("2024-01-01T00:00:00"),
    },
    project_id="d2c94c27-3b76-4a42-b88c-95a85e392c68",
    resolution="RESOLUTION_WEEKLY",
)
print(response.time_series)
{
  "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
    }
  ]
}