import { withSpan, withCapture, type ITracer, type ILogger, } from "@repo/core-shared/instrumentation"; import { workspacesContainer } from "./container"; /** * Binds a controller wrapped with the span + capture sandwich at bind time * (withSpan outermost, per template convention). Shared by bind-production * and bind-dev-seed so the wrapping stays identical in both modes. * * Idempotent: rebinding replaces the previous constant value. */ export function bindWorkspacesController( tracer: ITracer, logger: ILogger, symbol: symbol, name: string, controller: (...args: Args) => Promise, ): void { if (workspacesContainer.isBound(symbol)) { workspacesContainer.unbind(symbol); } workspacesContainer .bind(symbol) .toConstantValue( withSpan( tracer, { name: `workspaces.${name}`, op: "controller" }, withCapture( logger, { feature: "workspaces", layer: "controller", name: `workspaces.${name}`, }, controller, ), ), ); }