Skip to content

feat: expose provider metrics in the Helm chart - #2848

Merged
fseldow merged 3 commits into
notaryproject:mainfrom
charleswool:feat/chart-metrics-exposure
Aug 6, 2026
Merged

feat: expose provider metrics in the Helm chart#2848
fseldow merged 3 commits into
notaryproject:mainfrom
charleswool:feat/chart-metrics-exposure

Conversation

@charleswool

@charleswool charleswool commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Description

Exposes the provider's Prometheus /metrics endpoint through the Helm chart.

Note

Stacked on #2847, which adds the --enable-metrics / --metrics-port flags to the provider. This branch contains that commit, so review the chart commit here; please merge #2847 first and I'll rebase onto main afterward.

Change

  • Pass --enable-metrics and --metrics-port to the provider when metrics.enabled is true (matching the v1 flag convention).
  • Add the metrics container port (metrics, default 8888).
  • Add prometheus.io/{scrape,port,path} pod annotations for annotation-based Prometheus scraping.
  • New metrics values: enabled (default true) and port (default 8888), documented in the chart README.

A Prometheus Operator PodMonitor was split out of this PR per review feedback and will follow separately.

Testing

helm template verified:

  • default (metrics.enabled=true): --enable-metrics + --metrics-port=8888, the metrics container port, and the scrape annotations are rendered.
  • metrics.enabled=false: none of the above are rendered.
  • --set-string metrics.port=9999: the port still renders as an integer (| int).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates the ratify-gatekeeper-provider Helm chart to expose the provider’s Prometheus /metrics endpoint via pod annotations and an optional Prometheus Operator PodMonitor, and wires the configured metrics port into the provider container args.

Changes:

  • Add new metrics values (enabled, port, podMonitor.*) and document them in the chart README.
  • Add conditional Prometheus scrape annotations and a named metrics container port to the provider Deployment.
  • Add an optional PodMonitor template for Prometheus Operator-based scraping.

Reviewed changes

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

File Description
deployments/ratify-gatekeeper-provider/values.yaml Introduces default metrics configuration values (enabled/port/PodMonitor settings).
deployments/ratify-gatekeeper-provider/templates/deployment.yaml Adds scrape annotations, passes --metrics-port, and conditionally exposes the metrics container port.
deployments/ratify-gatekeeper-provider/templates/podmonitor.yaml Adds an optional Prometheus Operator PodMonitor for scraping /metrics.
deployments/ratify-gatekeeper-provider/README.md Documents the new metrics-related chart values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deployments/ratify-gatekeeper-provider/templates/podmonitor.yaml Outdated
Comment thread deployments/ratify-gatekeeper-provider/templates/deployment.yaml
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.63%. Comparing base (52e0867) to head (9a35e76).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2848      +/-   ##
==========================================
+ Coverage   76.58%   76.63%   +0.05%     
==========================================
  Files          89       89              
  Lines        4095     4104       +9     
==========================================
+ Hits         3136     3145       +9     
  Misses        812      812              
  Partials      147      147              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charleswool
charleswool force-pushed the feat/chart-metrics-exposure branch 2 times, most recently from f06bfb8 to 25e0d9e Compare July 30, 2026 03:23
@charleswool

Copy link
Copy Markdown
Contributor Author

CI fix: the e2e helm install was timing out because the chart passes --metrics-port to the provider, but this PR was branched off main where that flag does not exist yet (it is added in #2847), so the container crashed on the unknown flag and the pod never became Ready. Rebuilt this branch stacked on #2847 so the built image supports the flag. Please merge #2847 first; I will rebase onto main after it lands.

Comment thread deployments/ratify-gatekeeper-provider/templates/deployment.yaml Outdated
Comment thread deployments/ratify-gatekeeper-provider/values.yaml Outdated
Comment thread cmd/ratify-gatekeeper-provider/main.go Outdated
The metrics package (OTel + Prometheus, ported from v1) was never wired into the gatekeeper provider: the exporter was never initialized and no request duration was recorded, so the provider emitted no metrics and served no /metrics endpoint.

Initialize the Prometheus exporter on startup behind a new --metrics-port flag (default 8888, 0 disables) and record verification/mutation request durations in the verify/mutate handlers. Exporter init failures are logged but non-fatal.

Signed-off-by: Charles Wu <yuewu2@microsoft.com>
Wire the provider Prometheus /metrics endpoint into the chart: pass --metrics-enabled and --metrics-port when metrics.enabled is set, add the metrics container port, and add prometheus.io pod scrape annotations for annotation-based scraping.

Signed-off-by: Charles Wu <yuewu2@microsoft.com>
@charleswool
charleswool force-pushed the feat/chart-metrics-exposure branch from 96c0be0 to 46cefd5 Compare August 5, 2026 06:03
@fseldow
fseldow merged commit 6782e78 into notaryproject:main Aug 6, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants