var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import './config'; import { Global, Module, } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; import { Config } from '../config'; import { LocalOpentelemetryFactory, OpentelemetryFactory, registerCustomMetrics, } from './opentelemetry'; const factorProvider = { provide: OpentelemetryFactory, useFactory: (config) => { return config.metrics.enabled ? new LocalOpentelemetryFactory() : null; }, inject: [Config], }; let MetricsModule = class MetricsModule { constructor(ref) { this.ref = ref; this.sdk = null; } onModuleInit() { const factor = this.ref.get(OpentelemetryFactory, { strict: false }); if (factor) { this.sdk = factor.create(); this.sdk.start(); registerCustomMetrics(); } } async onModuleDestroy() { if (this.sdk) { await this.sdk.shutdown(); } } }; MetricsModule = __decorate([ Global(), Module({ providers: [factorProvider], exports: [factorProvider], }), __metadata("design:paramtypes", [ModuleRef]) ], MetricsModule); export { MetricsModule }; export * from './metrics'; export * from './utils'; export { OpentelemetryFactory }; //# sourceMappingURL=index.js.map