New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for getting DORA metrics from projects and groups #1582
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was testing this and ran into an issue. Sometimes Dora metrics are not integers so these functions will not be able to marshal the json:
error="error fetching DORA Metric leadTime for <repo>: json: cannot unmarshal number 607.5 into Go struct field DORAMetric.value of type int" project-name=<repo>
😐 I so wish there's a day that gitlab docs actually tell you that |
…teger when computing median time
type DORAMetricInterval string | ||
|
||
const ( | ||
// daily is the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// daily is the default |
"net/http" | ||
) | ||
|
||
type DORAMetricType string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments on all exported types and methods such that my linters don't fall over this...
DORAMetricIntervalDaily DORAMetricInterval = "daily" | ||
DORAMetricIntervalMonthly DORAMetricInterval = "monthly" | ||
DORAMetricIntervalAll DORAMetricInterval = "all" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please move these types to types.go
and also add helper methods to create pointers to these types/consts? See types.go
for examples of what I mean.
} | ||
|
||
type GetDORAMetricsOptions struct { | ||
Metric DORAMetricType `url:"metric" json:"metric"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metric DORAMetricType `url:"metric" json:"metric"` | |
Metric *DORAMetricType `url:"metric,omitempty" json:"metric,omitempty"` |
Metric DORAMetricType `url:"metric" json:"metric"` | ||
EndDate *string `url:"end_date,omitempty" json:"end_date,omitempty"` | ||
EnvironmentTiers *[]string `url:"environment_tiers,omitempty" del:"," json:"environment_tiers,omitempty"` | ||
// Interval can be one of daily, monthly, all, default is daily |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Interval can be one of daily, monthly, all, default is daily |
EnvironmentTier *string `url:"environment_tier,omitempty" json:"environment_tier,omitempty"` | ||
} | ||
|
||
// DORAMetricsService handles communication with the DORA metrics related methods of the GitLab API |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// DORAMetricsService handles communication with the DORA metrics related methods of the GitLab API | |
// DORAMetricsService handles communication with the DORA metrics related methods | |
// of the GitLab API | |
|
||
// GetProjectDORAMetrics gets the DORA metrics for a project. | ||
// | ||
// GitLab API Docs: https://docs.gitlab.com/ee/api/dora/metrics.html#get-project-level-dora-metrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GitLab API Docs: https://docs.gitlab.com/ee/api/dora/metrics.html#get-project-level-dora-metrics | |
// GitLab API Docs: | |
// https://docs.gitlab.com/ee/api/dora/metrics.html#get-project-level-dora-metrics |
|
||
if opt.Metric == "" { | ||
return nil, nil, fmt.Errorf("metric cannot be empty") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if opt.Metric == "" { | |
return nil, nil, fmt.Errorf("metric cannot be empty") | |
} |
While I understand this, I prefer to let the API return this info instead.
|
||
// GetGroupDORAMetrics gets the DORA metrics for a group. | ||
// | ||
// GitLab API Docs: https://docs.gitlab.com/ee/api/dora/metrics.html#get-group-level-dora-metrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// GitLab API Docs: https://docs.gitlab.com/ee/api/dora/metrics.html#get-group-level-dora-metrics | |
// GitLab API Docs: | |
// https://docs.gitlab.com/ee/api/dora/metrics.html#get-group-level-dora-metrics |
|
||
if opt.Metric == "" { | ||
return nil, nil, fmt.Errorf("metric cannot be empty") | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if opt.Metric == "" { | |
return nil, nil, fmt.Errorf("metric cannot be empty") | |
} |
resolves #1557