refactor(core-shared): rename bindSentryInstrumentation → bindOtelInstrumentation
git mv bind-sentry-instrumentation → bind-otel-instrumentation; function renamed; new impl calls initOtelServerNode and binds OtelTracer (SentryLogger kept for Phase 3). Barrel re-exports both new name and deprecated alias bindSentryInstrumentation for one release. ESLint allowlist updated to the new filename. init-server-node opts gains release? field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// packages/core-shared/src/instrumentation/di/bind-otel-instrumentation.ts
|
||||
import type { Container } from "inversify";
|
||||
import { OtelTracer } from "../otel/otel-tracer";
|
||||
import { SentryLogger } from "../sentry/sentry-logger";
|
||||
import { initOtelServerNode } from "../otel/init-server-node";
|
||||
import { INSTRUMENTATION_SYMBOLS } from "../symbols";
|
||||
import type { ITracer, ILogger } from "../index";
|
||||
|
||||
export type BindOtelOpts = {
|
||||
dsn: string;
|
||||
app: "web-next" | "cms" | "web-tanstack";
|
||||
release?: string;
|
||||
};
|
||||
|
||||
export function bindOtelInstrumentation(
|
||||
container: Container,
|
||||
opts: BindOtelOpts,
|
||||
): { tracer: ITracer; logger: ILogger } {
|
||||
const environment =
|
||||
process.env["SENTRY_ENVIRONMENT"] ??
|
||||
process.env["VERCEL_ENV"] ??
|
||||
process.env["NODE_ENV"] ??
|
||||
"development";
|
||||
const release = opts.release ?? process.env["VERCEL_GIT_COMMIT_SHA"] ?? "unknown";
|
||||
|
||||
initOtelServerNode({
|
||||
dsn: opts.dsn,
|
||||
serviceName: opts.app,
|
||||
environment,
|
||||
release,
|
||||
});
|
||||
|
||||
const tracer = new OtelTracer();
|
||||
const logger = new SentryLogger(); // Phase 3 replaces with OtelLogger
|
||||
|
||||
if (container.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
|
||||
container.unbind(INSTRUMENTATION_SYMBOLS.TRACER);
|
||||
}
|
||||
if (container.isBound(INSTRUMENTATION_SYMBOLS.LOGGER)) {
|
||||
container.unbind(INSTRUMENTATION_SYMBOLS.LOGGER);
|
||||
}
|
||||
container.bind<ITracer>(INSTRUMENTATION_SYMBOLS.TRACER).toConstantValue(tracer);
|
||||
container.bind<ILogger>(INSTRUMENTATION_SYMBOLS.LOGGER).toConstantValue(logger);
|
||||
return { tracer, logger };
|
||||
}
|
||||
Reference in New Issue
Block a user