feat(navigation): wire instrumentation — header repo spans + getHeader withSpan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,15 @@
|
||||
import {
|
||||
withSpan,
|
||||
INSTRUMENTATION_SYMBOLS,
|
||||
type ITracer,
|
||||
type ILogger,
|
||||
} from "@repo/core-shared/instrumentation";
|
||||
import { navigationContainer } from "./container.js";
|
||||
import { NAVIGATION_SYMBOLS } from "./symbols.js";
|
||||
import { MockHeaderRepository } from "../infrastructure/repositories/header.repository.mock.js";
|
||||
import { buildDevHeader } from "../__seeds__/dev.js";
|
||||
import { getHeaderUseCase } from "../application/use-cases/get-header.use-case.js";
|
||||
import { getHeaderController } from "../interface-adapters/controllers/get-header.controller.js";
|
||||
import type { IHeaderRepository } from "../application/repositories/header.repository.interface.js";
|
||||
|
||||
/**
|
||||
@@ -15,12 +23,49 @@ import type { IHeaderRepository } from "../application/repositories/header.repos
|
||||
* Idempotent: safe to call multiple times; each call rebuilds a fresh
|
||||
* populated repo and rebinds the symbol.
|
||||
*/
|
||||
export async function bindDevSeedNavigation(): Promise<void> {
|
||||
export async function bindDevSeedNavigation(tracer: ITracer, logger: ILogger): Promise<void> {
|
||||
// Bind shared instrumentation into feature container
|
||||
if (navigationContainer.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
|
||||
navigationContainer.unbind(INSTRUMENTATION_SYMBOLS.TRACER);
|
||||
}
|
||||
if (navigationContainer.isBound(INSTRUMENTATION_SYMBOLS.LOGGER)) {
|
||||
navigationContainer.unbind(INSTRUMENTATION_SYMBOLS.LOGGER);
|
||||
}
|
||||
navigationContainer.bind<ITracer>(INSTRUMENTATION_SYMBOLS.TRACER).toConstantValue(tracer);
|
||||
navigationContainer.bind<ILogger>(INSTRUMENTATION_SYMBOLS.LOGGER).toConstantValue(logger);
|
||||
|
||||
if (navigationContainer.isBound(NAVIGATION_SYMBOLS.IHeaderRepository)) {
|
||||
navigationContainer.unbind(NAVIGATION_SYMBOLS.IHeaderRepository);
|
||||
}
|
||||
|
||||
const repo = new MockHeaderRepository(buildDevHeader(), tracer, logger);
|
||||
navigationContainer
|
||||
.bind<IHeaderRepository>(NAVIGATION_SYMBOLS.IHeaderRepository)
|
||||
.toConstantValue(new MockHeaderRepository(buildDevHeader()));
|
||||
.toConstantValue(repo);
|
||||
|
||||
// Wrap use case + controller identically to bind-production
|
||||
const wrappedGetHeader = withSpan(
|
||||
tracer,
|
||||
{ name: "navigation.getHeader", op: "use-case" },
|
||||
getHeaderUseCase(repo),
|
||||
);
|
||||
|
||||
for (const sym of [
|
||||
NAVIGATION_SYMBOLS.IGetHeaderUseCase,
|
||||
NAVIGATION_SYMBOLS.IGetHeaderController,
|
||||
]) {
|
||||
if (navigationContainer.isBound(sym)) navigationContainer.unbind(sym);
|
||||
}
|
||||
navigationContainer
|
||||
.bind(NAVIGATION_SYMBOLS.IGetHeaderUseCase)
|
||||
.toConstantValue(wrappedGetHeader);
|
||||
|
||||
navigationContainer
|
||||
.bind(NAVIGATION_SYMBOLS.IGetHeaderController)
|
||||
.toConstantValue(
|
||||
withSpan(
|
||||
tracer,
|
||||
{ name: "navigation.getHeader", op: "controller" },
|
||||
getHeaderController(wrappedGetHeader),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user