mirror of
https://github.com/immich-app/immich.git
synced 2026-03-04 09:57:33 +03:00
feat(server): job metrics (#8255)
* metric repo * add metric repo * remove unused import * formatting * fix * try disabling job metrics for e2e * import otel in test module
This commit is contained in:
31
server/src/repositories/metric.repository.ts
Normal file
31
server/src/repositories/metric.repository.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { MetricService } from 'nestjs-otel';
|
||||
import { CustomMetricOptions, IMetricRepository } from 'src/interfaces/metric.interface';
|
||||
|
||||
export class MetricRepository implements IMetricRepository {
|
||||
constructor(@Inject(MetricService) private readonly metricService: MetricService) {}
|
||||
|
||||
addToCounter(name: string, value: number, options?: CustomMetricOptions): void {
|
||||
if (options?.enabled === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.metricService.getCounter(name, options).add(value);
|
||||
}
|
||||
|
||||
updateGauge(name: string, value: number, options?: CustomMetricOptions): void {
|
||||
if (options?.enabled === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.metricService.getUpDownCounter(name, options).add(value);
|
||||
}
|
||||
|
||||
updateHistogram(name: string, value: number, options?: CustomMetricOptions): void {
|
||||
if (options?.enabled === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.metricService.getHistogram(name, options).record(value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user