Injecting counter into service fails
Closed this issue · 1 comments
HansG89 commented
Following the instructions, typescript complains about incompatible types
@Injectable()
export class Service {
constructor(@InjectMetric("metric_name") public counter: Counter) {}
}
Error message "Generic type 'Counter' requires 1 type argument(s).ts(2314)" when calling the constructor.
Looks like all metrics are generics in prom-client.
/**
* A counter is a cumulative metric that represents a single numerical value that only ever goes up
*/
export class Counter<T extends string> {
/**
* @param configuration Configuration when creating a Counter metric. Name and Help is required.
*/
constructor(configuration: CounterConfiguration<T>);
/**
* Increment for given labels
* @param labels Object with label keys and values
* @param value The number to increment with
*/
inc(labels: LabelValues<T>, value?: number): void;
/**
* Increment with value
* @param value The value to increment with
*/
inc(value?: number): void;
/**
* Return the child for given labels
* @param values Label values
* @return Configured counter with given labels
*/
labels(...values: string[]): Counter.Internal;
/**
* Reset counter values
*/
reset(): void;
/**
* Remove metrics for the given label values
* @param values Label values
*/
remove(...values: string[]): void;
}
Used versions:
"prom-client": "^12.0.0",
"@willsoto/nestjs-prometheus": "^0.1.1",
Am I missing something?
willsoto commented
@HansG89 here is some information: siimon/prom-client#291 and siimon/prom-client#299. I'll update my docs so the examples reflect the latest api.