Skip to content

Conversation

@honeyankit
Copy link
Contributor

@honeyankit honeyankit commented Mar 13, 2025

Context

Implement metrics collection in dependabot-actions to track calls to GitHub’s private registry by sending data to Dependabot API’s record_metrics. This enhancement will allow us to measure the frequency of image pulls from GitHub’s private registry. Previously, no metrics were captured within dependabot-actions, limiting our visibility into registry usage rates.

Approach

  1. Implemented the sendMetrics function within the existing ApiClient class, allowing metric reporting.
  2. Conditional Metric Reporting: Modified the ImageService.pull method 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-actions and 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

@honeyankit honeyankit self-assigned this Mar 13, 2025
Copy link
Contributor

@pavera pavera left a 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 :)

@pavera pavera self-requested a review March 13, 2025 16:56
@honeyankit honeyankit marked this pull request as ready for review March 13, 2025 20:59
@honeyankit honeyankit requested a review from a team as a code owner March 13, 2025 20:59

// 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 (
Copy link
Contributor Author

@honeyankit honeyankit Mar 13, 2025

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.

@honeyankit
Copy link
Contributor Author

Metrics are getting successfully:
image

@honeyankit honeyankit merged commit 91a3939 into main Mar 14, 2025
9 checks passed
@honeyankit honeyankit deleted the honeyankit/implement-metrics-collector branch March 14, 2025 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants