Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Enforcing Observability Contracts in CI/CD With Open Policy Agent

A refactor dropped OpenTelemetry spans from our checkout worker and hid a 6-hour outage. Here is how we built an OPA CI gate to block blind deploys.

Enforcing Observability Contracts in CI/CD With Open Policy Agent

On Thursday afternoon, the team released version 4.11.2 of the checkout-worker to production on EKS. All unit tests and integration suites were successful, and health checks remained green. However, it wasn't until 8:19 PM that a problem was discovered - a merchant in the enterprise Slack channel reported that their paid orders since 2:30 PM hadn't triggered fulfillment webhooks.

Upon investigation, it was found that a Redis connection pool change had caused silent ECONNRESET drops on the third retry, resulting in 1,840 failed webhook jobs. The issue arose because a developer had split the handleWebhookJob() function into a new module but forgot to wrap it in the withTelemetry() helper, causing zero Prometheus counters and OpenTelemetry spans to be incremented. This led to the dashboards appearing calm and green, despite the actual issues in production.

The team realized that traditional tests were unable to catch missing telemetry in production. Despite having 86% line coverage on checkout-worker, there were still 11 other endpoints and background consumers across four TypeScript/Node services with zero spans, stale metric names, or console.log statements that didn't increment error counters. Engineers were not incentivized to check their telemetry during code reviews, as the responsibility was often overlooked in long PRs fixing critical bugs.

To address this issue, the team decided to treat observability as a merge contract using Open Policy Agent (OPA). They created a static AST extractor that scans every route handler and queue consumer in the repo and generates a JSON manifest (otel-manifest.json) listing the telemetry each handler produces. An OPA Rego policy was then implemented in the CI pipeline to evaluate the manifest and exit non-zero if any handler did not produce a trace span, error counter, or SLO owner declaration.

This approach eliminated the need for custom bash scripts and regex hacks, as OPA allowed for a declarative policy language that could be easily understood by both SREs and SDETs.

Rewritten by urgent.news; may contain errors โ€” check the original.

Source: hackernoon.com

Read the original at hackernoon.com โ†’

More from HackerNoon on urgent.news

Report a problem with this story

Get the day's news by email. Daily, weekly or monthly. Sign up

More in Tech

More from Sunday, 29 November 2026 โ†’