Skip to content

feat(verifier): policy endpoint latency histogram - #1415

Merged
tt-cll merged 2 commits into
mainfrom
tt/policy-endpoint-latency
Sep 9, 2026
Merged

feat(verifier): policy endpoint latency histogram#1415
tt-cll merged 2 commits into
mainfrom
tt/policy-endpoint-latency

Conversation

@tt-cll

@tt-cll tt-cll commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Description

Testing

Checklist

  • Breaking changes documented in changelog (see changelog directory)
  • Cross link related PRs (in this or other repositories)

Stack created with GitHub Stacks CLIGive Feedback 💬

@tt-cll
tt-cll requested review from a team as code owners September 5, 2026 19:03
makramkd
makramkd previously approved these changes Sep 9, 2026
Copilot AI lite review requested due to automatic review settings September 9, 2026 11:20
@tt-cll
tt-cll force-pushed the tt/policy-endpoint-latency branch from 52948af to 81b941b Compare September 9, 2026 11:20

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.

🟡 Changes recommended

The new histogram bucket range and documentation don’t align with the configured maximum policy request timeout, and the interface change is breaking without clear release/changelog treatment or targeted test coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adds a new outbound policy-hook latency histogram to complement existing policy outcome counters, enabling visibility into slow-but-not-failing policy endpoint behavior.

Changes:

  • Adds RecordPolicyHTTPRequestDuration to vtypes.MetricLabeler and implements it across noop/fake/mock labelers.
  • Records policy endpoint call duration (labeled by policy outcome vocabulary) from the gated verifier’s evaluation path.
  • Registers a new OTel histogram + view and documents the new metric in the policy hook docs.
File summaries
File Description
verifier/testutil/metric_labeler.go Extends noop labeler with the new policy HTTP duration method.
verifier/pkg/vtypes/interfaces.go Adds the new policy HTTP duration method to the MetricLabeler interface.
verifier/pkg/policy/gate.go Records per-call latency and introduces callOutcome outcome mapping for histogram labels.
verifier/pkg/monitoring/monitoring.go Extends fake metric labeler with the new method.
verifier/pkg/monitoring/metrics.go Defines and registers the new histogram instrument, view buckets, and label recording.
verifier/pkg/helpers_test.go Updates local test noop metric labeler to satisfy the extended interface.
verifier/internal/mocks/mock_MetricLabeler.go Updates generated mock to include the new method.
verifier/docs/policy_hook.md Documents the new latency histogram and its label vocabulary.
Review details

Files not reviewed (1)

  • verifier/internal/mocks/mock_MetricLabeler.go: Generated file
  • Files reviewed: 7/8 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread verifier/pkg/monitoring/metrics.go Outdated
sdkmetric.NewView(
sdkmetric.Instrument{Name: "verifier_policy_http_request_duration_seconds"},
sdkmetric.Stream{Aggregation: sdkmetric.AggregationExplicitBucketHistogram{
Boundaries: []float64{0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10},
Comment on lines 199 to 203
req := NewEvaluateRequest(g.verifierID, &tasks[index])
start := time.Now()
verdict, err := g.checker.Evaluate(ctx, req)
g.messageMetrics(tasks[index].Message).RecordPolicyHTTPRequestDuration(ctx, callOutcome(verdict, err), time.Since(start))
out[index] = evaluation{verdict: verdict, err: err}
Comment on lines +216 to +220
// endpoint took. outcome is one of the monitoring.MessageTransitionOutcomePolicy* constants
// the stage's transition counter uses; policy_skipped never occurs here because a skipped
// task makes no call. A slow endpoint that is not yet timing out is invisible on the
// outcome counters, which is what this histogram is for.
RecordPolicyHTTPRequestDuration(ctx context.Context, outcome string, duration time.Duration)
Comment thread verifier/docs/policy_hook.md Outdated
Comment on lines +352 to +353
endpoint that is slow but not yet timing out shows up here first. Buckets run from 1ms to 10s,
around the per-call timeout.
Base automatically changed from tt/policy-hook-cl-mode-error to main September 9, 2026 12:38
@tt-cll
tt-cll force-pushed the tt/policy-endpoint-latency branch from 81b941b to 12683de Compare September 9, 2026 12:38
@tt-cll
tt-cll force-pushed the tt/policy-endpoint-latency branch from 12683de to 18234fd Compare September 9, 2026 16:12
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Code coverage report:

Package main tt/policy-endpoint-latency Diff
github.com/smartcontractkit/chainlink-ccv/aggregator 50.86% 50.85% -0.01%
github.com/smartcontractkit/chainlink-ccv/bootstrap 72.00% 72.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/cli 58.12% 58.12% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 35.65% 35.65% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 48.17% 48.32% +0.15%
github.com/smartcontractkit/chainlink-ccv/executor 42.80% 42.80% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 35.54% 35.55% +0.01%
github.com/smartcontractkit/chainlink-ccv/integration 60.58% 60.58% +0.00%
github.com/smartcontractkit/chainlink-ccv/internal 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/migration 78.70% 78.70% +0.00%
github.com/smartcontractkit/chainlink-ccv/pkg 100.00% 100.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 63.46% 63.46% +0.00%
github.com/smartcontractkit/chainlink-ccv/tools 43.61% 43.61% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 36.55% 36.71% +0.16%
Total 50.80% 50.90% +0.10%

@tt-cll
tt-cll added this pull request to the merge queue Sep 9, 2026
Merged via the queue into main with commit 51663c6 Sep 9, 2026
54 checks passed
@tt-cll
tt-cll deleted the tt/policy-endpoint-latency branch September 9, 2026 19:36
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.

4 participants