Closed JulienFauvel closed 6 months ago
Hello,
following the issue https://github.com/pragmaticivan/nestjs-otel/issues/471, I created this fix
The createParamDecorator didn't returned the right type, so the example code in the Readme can't be compiled. But it does work if you ignore the TS error.
createParamDecorator
This is the type that was generated in metrics/decorators/counter.d.ts
metrics/decorators/counter.d.ts
export declare const OtelCounter: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
I reworked a bit the param decorators with the function createMetricParamDecorator, and gather all of them in param.ts as it has become simpler
createMetricParamDecorator
param.ts
With the fix this is the d.ts generated:
export type MetricParamDecorator = (name: string, options?: OtelMetricOptions) => ParameterDecorator; export declare const OtelCounter: MetricParamDecorator;
I also added an assertion in the E2E test for this use case
Thank you!
Hello,
following the issue https://github.com/pragmaticivan/nestjs-otel/issues/471, I created this fix
The
createParamDecorator
didn't returned the right type, so the example code in the Readme can't be compiled. But it does work if you ignore the TS error.This is the type that was generated in
metrics/decorators/counter.d.ts
I reworked a bit the param decorators with the function
createMetricParamDecorator
, and gather all of them inparam.ts
as it has become simplerWith the fix this is the d.ts generated:
I also added an assertion in the E2E test for this use case