Open posquit0 opened 2 days ago
I want to configure OpenTelemetryModule with forRootAsync({ useClass: ... }) method by utilizing nestjs/config. But, it seems that nestjs-otel package is not exporting OpenTelemetryModuleOptions, OpenTelemetryOptionsFactory interfaces.
OpenTelemetryModule
forRootAsync({ useClass: ... })
nestjs/config
nestjs-otel
OpenTelemetryModuleOptions
OpenTelemetryOptionsFactory
OpenTelemetryModule.forRootAsync({ useClass: OtelConfigService }),
import { Injectable, Logger } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { OpenTelemetryOptionsFactory, OpenTelemetryModuleOptions } from 'nestjs-otel'; @Injectable() export class OtelConfigService implements OpenTelemetryOptionsFactory { private readonly logger = new Logger(OtelConfigService.name) constructor(private configService: ConfigService) {} createOpenTelemetryOptions(): Promise<OpenTelemetryModuleOptions> | OpenTelemetryModuleOptions { const { hostMetrics, apiMetrics } = this.configService.get('otel') return { metrics: { hostMetrics: hostMetrics.enabled, apiMetrics: { enable: apiMetrics.enabled, }, }, }; } }
0.145 yarn run v1.22.22 0.156 $ nest build 2.123 src/otel/otel-config.service.ts:3:10 - error TS2305: Module '"nestjs-otel"' has no exported member 'OpenTelemetryOptionsFactory'. 2.123 2.123 3 import { OpenTelemetryOptionsFactory, OpenTelemetryModuleOptions } from 'nestjs-otel'; 2.123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.123 src/otel/otel-config.service.ts:3:39 - error TS2724: '"nestjs-otel"' has no exported member named 'OpenTelemetryModuleOptions'. Did you mean 'OPENTELEMETRY_MODULE_OPTIONS'? 2.123 2.123 3 import { OpenTelemetryOptionsFactory, OpenTelemetryModuleOptions } from 'nestjs-otel'; 2.123 ~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.123 2.123 node_modules/nestjs-otel/lib/opentelemetry.constants.d.ts:1:22 2.123 1 export declare const OPENTELEMETRY_MODULE_OPTIONS = "OpenTelemetryModuleOptions"; 2.123 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.123 'OPENTELEMETRY_MODULE_OPTIONS' is declared here. 2.123 2.125 Found 2 error(s).
Which version are you using?
https://github.com/pragmaticivan/nestjs-otel/blob/main/src/index.ts#L7 https://github.com/pragmaticivan/nestjs-otel/blob/main/src/opentelemetry.constants.ts#L1
Version is 6.1.1. How can I use forRootAsync({ useClass: ... }) with your suggested constant value? Is there any example code?
6.1.1
I'm working on my first Nest.js project, so I don't know much about it yet. 😂
Expecting Behaviors
I want to configure
OpenTelemetryModule
withforRootAsync({ useClass: ... })
method by utilizingnestjs/config
. But, it seems thatnestjs-otel
package is not exportingOpenTelemetryModuleOptions
,OpenTelemetryOptionsFactory
interfaces.Errors