-
Notifications
You must be signed in to change notification settings - Fork 61
Implement feature to capture metrics inside Dependabot Actions to post to Dependabot API #1428
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
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.
LGTM - Forgot it is only a draft, let me know when it is ready for review :)
|
|
||
| // The sendMetrics function is used to send metrics to the API client. | ||
| // It uses the package manager as a tag to identify the metric. | ||
| const sendMetricsWithPackageManager: MetricReporter = async ( |
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.
I’ve introduced a wrapper around sendMetrics to pass it into ImageService.pull. This approach avoids significant changes to the existing interface by adding a thin layer to capture the package manager information. This way, we don’t need to extensively modify ImageService while still ensuring metrics are accurately captured.

Context
Implement metrics collection in
dependabot-actionsto track calls toGitHub’s private registryby sending data to Dependabot API’srecord_metrics. This enhancement will allow us to measure the frequency of image pulls from GitHub’s private registry. Previously, no metrics were captured withindependabot-actions, limiting our visibility into registry usage rates.Approach
sendMetricsfunction within the existing ApiClient class, allowing metric reporting.ImageService.pullmethod to accept an optional MetricReporter parameter, ensuring metrics are reported only when explicitly passed. This prevents unwanted metric reporting in scripts like fetch-image.ts that reuse the same image pulling logic but do not require metrics during unit-tests.Tradeoffs
This change introduces two additional calls per Dependabot Actions run to the Dependabot API’s record_metrics endpoint, effectively doubling the number of requests—two million API requests for one million action runs. Batch processing isn’t feasible here, as each Dependabot Actions run occurs independently, requiring immediate collection and posting of metrics via the sendMetrics function. These metrics are then forwarded from Dependabot API to Datadog. Given this constraint, monitoring the API performance closely will be essential to ensure reliability.
Q. Why we cannot directly install Datadog agent in
dependabot-actionsand send the metrics to the Data Dog server instead?Ephemeral Container Billing: Each time proxy container (with the embedded Datadog Agent) runs, it’s considered a separate host instance. Even if these containers are short-lived, they are counted individually for billing purposes.
Referenced: #1156