Skip to content

Add myshoes_webhook_jobs_enqueued_total for auto-scaling from metrics#235

Merged
whywaita merged 1 commit intomasterfrom
feat/webhook-receive-metrics
Jul 3, 2025
Merged

Add myshoes_webhook_jobs_enqueued_total for auto-scaling from metrics#235
whywaita merged 1 commit intomasterfrom
feat/webhook-receive-metrics

Conversation

@whywaita
Copy link
Copy Markdown
Owner

@whywaita whywaita commented Jul 1, 2025

This pull request introduces updates to dependencies in go.mod and enhances webhook handling in pkg/web/webhook.go with new Prometheus metrics. The changes improve observability of webhook processing and job enqueuing while updating dependencies to their latest versions for better performance and compatibility.

Dependency Updates:

  • Updated several dependencies in go.mod to newer versions, including github.com/google/go-cmp, github.com/prometheus/client_golang, golang.org/x/sync, google.golang.org/protobuf, and golang.org/x/crypto, among others. These updates ensure compatibility and may include performance improvements or bug fixes. [1] [2]
  • Removed github.com/klauspost/compress from indirect dependencies in go.mod, simplifying the dependency graph.

Webhook Metrics Enhancements:

  • Added pkg/metric/webhook.go to define new Prometheus metrics (WebhookReceivedTotal, WebhookProcessingDuration, and WebhookJobsEnqueued) for tracking webhook events, processing duration, and job enqueuing.
  • Integrated metrics into pkg/web/webhook.go to record webhook processing outcomes, durations, and job enqueuing for various event types (ping, check_run, workflow_job). This improves observability and debugging capabilities. [1] [2] [3]

Webhook Event Handling Improvements:

  • Enhanced HandleGitHubEvent to extract runs-on labels for workflow_job events, enabling more detailed metrics.
  • Updated receiveCheckRunWebhook and receiveWorkflowJobWebhook functions to record metrics for jobs enqueued during webhook processing. [1] [2]

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new Prometheus metric (myshoes_webhook_jobs_enqueued_total) to support auto-scaling based on webhook activity and integrates metric tracking into webhook event handling.

  • Introduces new metric counters and histograms in pkg/metric/webhook.go.
  • Updates webhook event handling in pkg/web/webhook.go to record success, error, and processing duration metrics for various event types.
  • Bumps dependency versions in go.mod to compatible releases.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/web/webhook.go Adds metric instrumentation within webhook processing and job enqueuing logic.
pkg/metric/webhook.go Introduces new Prometheus metrics for webhook events and job enqueuing.
go.mod Updates versions for several dependencies.
Comments suppressed due to low confidence (1)

pkg/web/webhook.go:218

  • The variable 'labels' is undefined in this scope. Ensure that 'labels' is properly defined or passed in before using it to compute 'runsOn' for the workflow_job metric.
	runsOn := strings.Join(labels, ",")

@whywaita whywaita self-assigned this Jul 1, 2025
Copy link
Copy Markdown
Collaborator

@site0801 site0801 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@whywaita whywaita merged commit 4964293 into master Jul 3, 2025
5 checks passed
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