When Metrics Backfire: The Cobra Effect in the age of AI
When Metrics Backfire: The Cobra Effect in the age of AI
Author: Tomasz Byrski
Your metrics dashboard might be suggesting you everything is improving, while your system is actually degrading.
Metrics are supposed to help us build better software, in practice, they might do the opposite.
One of the most common, and subtle failure modes is something known as the Cobra Effect: when a measure designed to improve outcomes ends up making them worse. In modern engineering organizations, especially those embracing AI tooling and high-velocity delivery, this effect is not just theoretical — it is a real day-to-day issue.
And with AI in the picture, the stakes are higher than ever.
The Origin of the Cobra Effect
The term comes from a historical anecdote from colonial India. The British administration in Delhi was concerned about the number of venomous cobras in the city. To reduce the population, they introduced a bounty: citizens would be paid for every dead cobra they turned in. At first, the policy seemed to work — people brought in large numbers of dead snakes.
But then something unexpected happened. Entrepreneurs began breeding cobras specifically to kill them and collect the reward. When the government realized what was happening, they canceled the program. The breeders, now stuck with worthless snakes, released them into the wild.
The result? More cobras than before the program started. A well-intentioned metric — number of dead cobras — ended up making the problem worse.
The Mechanism Behind It
The pattern is deceptively simple:
- You pick a metric as a proxy for success
- You attach incentives to it
- People optimize for the metric
- The system adapts in unintended ways
The result is not just measurement error. It’s behavioral distortion. People don’t optimize metrics because they’re careless, they do it because metrics are visible, rewarded, and often easier to influence than the underlying system.
Lead vs. Lag Metrics
Before getting into how this plays out in engineering, let’s align on terms.
Lag metrics measure outcomes, that could be customer experience (e.g. customer satisfaction, contact rate with customer support), reliability (e.g. system downtime, transfer delivery on time), business impact (e.g. time & cost to open new transfer corridors). They tell you how good you are.
Lead metrics measure inputs or behaviors that are supposed to drive those outcomes: deployment frequency, PR cycle time, lines of code, test coverage, AI token usage, API error rate, manual interventions per e.g. 1000 transfers. They are your hypothesis about what will make things better.
Lag metrics are reality while lead metrics are bets. Typical engineering dashboards are dominated by lead metrics, often treated as if they were outcomes. That’s where things start to go wrong.
The Cobra Effect in Practice
The Cobra Effect occurs when people optimize for the metric instead of the outcome it represents. In engineering teams, this usually happens when a lead metric is treated as a hard target, tied, explicitly or implicitly, to performance, and is an imperfect proxy for what you actually care about.
Lead metrics without guardrails. Imagine a team sets a goal: increase deployment frequency. In high-performing teams, frequent deploys correlate with faster feedback and better outcomes. But without guardrails, behavior shifts. Changes intentionally get split into artificially small units; trivial deploys inflate the metric; risk is redistributed, not reduced. Deployments become more frequent, but not more meaningful.
Lag metrics that can be “managed.” Lag metrics aren’t immune either. Tell a team to reduce the number of incidents, and they may respond by reclassifying incidents, avoiding detection, or delaying reporting. On paper: fewer incidents. In reality: worse reliability. Just like counting dead cobras didn’t reflect the real number of snakes, counting incidents doesn’t always reflect real system health.
Proxy metrics becoming the goal. Consider PR review time. Push for faster approvals and you get them — but shallower ones. Fewer edge cases discussed, less design feedback, more issues discovered after merge. Approvals speed up. Code quality goes down.
The Modern Twist: AI Amplifies the Effect
This is where things get more dangerous.
AI doesn’t just accelerate development — it multiplies the impact of bad metrics. It also introduces a new class of metrics that are powerful but dangerously easy to misuse: token usage, AI-assisted output (PRs, lines of code), time-to-first-draft.
The token cost trap. Set a goal to reduce AI token usage, and here’s what happens: engineers avoid using AI for exploration and design, prompts get shorter and lose context, fewer tests and refactors get generated. Costs go down. Productivity and quality quietly degrade. Monitoring only token cost, without lag metrics, creates ambiguity: did the engineer get smarter with AI or stop using it? This ambiguity is the risk.
But high token usage isn’t a safe target either. It’s tempting to flip the logic — if low usage is bad, high usage must be good. It isn’t — a messy, poorly documented codebase forces engineers into long, meandering AI conversations just to accomplish basic tasks. High token usage then becomes a symptom of poor foundations, not a sign of quality process. Worse, if engineers know usage is being watched as a positive signal, the metric creates an incentive for activity theater: verbose prompts, rambling back-and-forth, the appearance of deep engagement without the substance.
There’s a subtler risk too. High usage can mean engineers are offloading decisions they should be making themselves — architecture choices, tradeoffs, design — rather than using AI to sharpen their own thinking. The output looks thorough and AI-assisted. The engineer’s judgment quietly atrophies.
Token usage is not inherently good or bad — it’s only meaningful in relation to outcomes. Without connecting it to quality, speed, and reliability, you’re just measuring noise in either direction.
PR throughput in an AI world. Set a goal to increase PRs per engineer, and AI-accelerated code generation will spike the number. Now pair that with a goal to reduce review time, and you’ve built a system that produces more code, reviews it less carefully, and ships more defects. Each of those two metrics looks healthy in isolation. Together, they recreate the cobra problem in a modern form.
Designing Metrics That Don’t Backfire
Avoiding the Cobra Effect isn’t about abandoning metrics — it’s about designing them as systems, not targets.
1. Always pair lead with lag. A lead metric without a lag metric is an unchecked assumption. Speed metrics like deployment frequency or PR cycle time should always be paired with a quality signal closer to what you actually care about — like customer-facing defects. AI usage with delivery speed and quality. Ask yourself: if this number improves, what should happen to the outcome? What would prove this metric is lying? If the lead improves but the lag degrades, you’ve found your cobra.
2. Use metric sets, not single numbers. Single metrics are easy to game. Systems of metrics are harder. Balanced frameworks like DORA work because they create tension between speed and stability. Shorten lead time by skipping reviews, and defects that would have been caught now reach production — exposing you immediately through a higher Change Failure Rate. You can’t game one without getting caught by another.
3. Avoid hard targets on proxies. The moment a proxy becomes a quota, behavior distorts. Instead of “achieve 80% test coverage,” for example prefer a goal: “increase confidence in releases.” Let metrics inform decisions, not dictate them.
4. Inspect behavior, not just output. Every metric incentivizes something. Ask: what behavior does this encourage? How could this be gamed? What would a lazy optimization look like? If you can game it easily, someone eventually will — intentionally or not. A team measured on PR cycle time will start approving PRs faster, not by getting better at reviews, but by leaving fewer comments. The metric improves. The code quality doesn’t.
5. Watch for “too good to be true.” Be wary when everything improves at once — for example, PRs per engineer go up, review time goes down, and AI token usage drops. More often this signals reduced rigor, hidden work, or deferred risk: work sliced into smaller, less substantial PRs, shallower reviews, and less exploratory AI use. The dashboard looks better, but the consequences surface later as more defects and delays.
A Mental Model to Keep Yourself Honest
Think of your metrics like this:
- Lag metric → what you actually care about
- Lead metric → your current best guess of how to influence the lag metric
The Cobra Effect appears when the guess is wrong, or when people optimize the guess instead of the goal. Your job is to keep those two things from drifting apart.
Closing Thought
Metrics don’t just measure systems — they shape them.
The British administration in Delhi didn’t set out to increase the number of cobras, but by choosing the wrong proxy and attaching incentives to it, that’s exactly what they achieved. A better approach would have been to pair and monitor the lead metric of dead cobras delivered with lag metric of cobra bites treated in hospital or cobra sightings in residential areas.
In an era of AI-assisted development and increasing pressure for speed, the risk isn’t that we won’t measure enough. It’s that we’ll measure the wrong things — and get exactly what we asked for.
Just not what we wanted.
Based in Kraków, Poland, Tomasz Byrski is a Software Engineer at Remitly. With two decades of professional experience, he currently focuses on platformizing the company’s backend capabilities.
At Remitly’s Kraków Engineering Hub, we’ve built a community where bold ideas and collaborative innovation go hand-in-hand. We’re looking for engineers who value their craft and are ready to tackle the unique challenges of global financial services. If you’re looking for a launchpad for your career and a team that supports your growth, come build with us. Explore our open roles here.
continue reading
Related Posts

Tuning Aurora MySQL for real-world workloads — part 3: Shaping Go workloads
Author: Dimitrios Sołtysiak This is Part 3 of a [...]

Tuning Aurora MySQL for real-world workloads — part 2: Engine, connections, and schema
Author: Dimitrios Sołtysiak This is Part 2 of a [...]

Tuning Aurora MySQL for real-world workloads — part 1: Making it observable
Author: Dimitrios Sołtysiak This is Part 1 of a [...]

