r/typescript • u/Hour-Librarian3622 • 3h ago
Every refactor in our NestJS repo turns into fixing u/Traced decorators
NestJS monorepo, eleven services. Two years ago we wrote a `@Traced()` decorator that wraps every service method in an OpenTelemetry span, plus a typed helper so attribute names come from one union type and nobody writes `userId` in one place and `user_id` in another.
Now every refactor drags it along. Rename a method and the span name changes, so the Grafana panel built on the old name goes quietly empty and nobody notices for weeks. Move logic into a plain function and it stops being traced, because the decorator only works on class methods. The SDK upgrade in July broke the helper's types and I lost most of a sprint to generics so a tracing wrapper would compile. The PR template has a "spans updated?" checkbox and everyone ticks it.
One service has hud on it as a trial instead of more decorators. There's no manual instrumentation, it picks up the functions on its own, and after the last deploy it had the renamed ones without anyone touching a config. It doesn't build the business dashboards product wants though, signups per plan and that kind of thing, so Grafana and a handful of spans stay.
The decorator stays where it is on the quiet services. New code just doesn't get it anymore.