How Datadog Used Claude and Cursor for Test-Driven Production Migration

· Source: InfoQ · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Advanced, short

Summary

Datadog engineer Arnold Wakim detailed the company's successful migration of its critical Stream Router API, which manages metrics pipeline routing, from a key-value (KV) model on FoundationDB to a relational schema on PostgreSQL. The original system faced severe performance issues, with operations taking up to 45 minutes due to transaction size limits. To refactor the codebase, Datadog utilized AI tools, specifically Claude and Cursor, in a test-driven process. These AI models generated initial code passes for methods, guided by the old implementation, new schema, and failing tests. Key enablers included strong code modularity, a comprehensive test suite, and a parallel "blue/green" infrastructure with a validator service. Post-migration, operations now complete in about one second, latencies are significantly reduced, data storage is 40x smaller, and database costs are down by 90%. While AI generated correct code, human input was needed for query optimization and to manage high token consumption.

Key takeaway

For Software Engineering teams considering AI-assisted refactoring for critical systems, prioritize developing a robust, comprehensive test suite before engaging AI tools. Your test suite will serve as the essential guardrail, validating AI-generated code and ensuring correctness during complex migrations. Be prepared to manually optimize AI-generated queries for performance and manage high token consumption, as AI may produce correct but inefficient solutions.

Key insights

The strength of a comprehensive test suite is paramount for safely and effectively integrating AI into critical code refactoring.

Principles

Method

Datadog's migration involved three phases: Claude describing function intent, focused prompts fixing failing tests with context, and blue/green deployment with continuous validation between parallel systems.

In practice

Topics

Best for: AI Architect, CTO, VP of Engineering/Data, AI Engineer, Machine Learning Engineer, Software Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by InfoQ.