feat(core-shared): wire IMetrics into DI bindings
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
import type { Container } from "inversify";
|
||||
import { OtelTracer } from "../otel/otel-tracer";
|
||||
import { OtelLogger } from "../otel/otel-logger";
|
||||
import { OtelMetrics } from "../otel/otel-metrics";
|
||||
import { initOtelServerNode } from "../otel/init-server-node";
|
||||
import { INSTRUMENTATION_SYMBOLS } from "../symbols";
|
||||
import type { ITracer, ILogger } from "../index";
|
||||
import type { ITracer, ILogger, IMetrics } from "../index";
|
||||
|
||||
export type BindOtelOpts = {
|
||||
dsn: string;
|
||||
@@ -15,7 +16,7 @@ export type BindOtelOpts = {
|
||||
export function bindOtelInstrumentation(
|
||||
container: Container,
|
||||
opts: BindOtelOpts,
|
||||
): { tracer: ITracer; logger: ILogger } {
|
||||
): { tracer: ITracer; logger: ILogger; metrics: IMetrics } {
|
||||
const environment =
|
||||
process.env["SENTRY_ENVIRONMENT"] ??
|
||||
process.env["VERCEL_ENV"] ??
|
||||
@@ -32,6 +33,7 @@ export function bindOtelInstrumentation(
|
||||
|
||||
const tracer = new OtelTracer();
|
||||
const logger = new OtelLogger();
|
||||
const metrics = new OtelMetrics();
|
||||
|
||||
if (container.isBound(INSTRUMENTATION_SYMBOLS.TRACER)) {
|
||||
container.unbind(INSTRUMENTATION_SYMBOLS.TRACER);
|
||||
@@ -39,7 +41,11 @@ export function bindOtelInstrumentation(
|
||||
if (container.isBound(INSTRUMENTATION_SYMBOLS.LOGGER)) {
|
||||
container.unbind(INSTRUMENTATION_SYMBOLS.LOGGER);
|
||||
}
|
||||
if (container.isBound(INSTRUMENTATION_SYMBOLS.METRICS)) {
|
||||
container.unbind(INSTRUMENTATION_SYMBOLS.METRICS);
|
||||
}
|
||||
container.bind<ITracer>(INSTRUMENTATION_SYMBOLS.TRACER).toConstantValue(tracer);
|
||||
container.bind<ILogger>(INSTRUMENTATION_SYMBOLS.LOGGER).toConstantValue(logger);
|
||||
return { tracer, logger };
|
||||
container.bind<IMetrics>(INSTRUMENTATION_SYMBOLS.METRICS).toConstantValue(metrics);
|
||||
return { tracer, logger, metrics };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user