refactor: users.total metric (#23158)

* refactor: users.total metric

* fix: broken test
This commit is contained in:
Jason Rasmussen
2025-10-22 10:18:17 -04:00
committed by GitHub
parent 0b941d78c4
commit a70843e2b4
10 changed files with 76 additions and 23 deletions

View File

@@ -0,0 +1,26 @@
import { OnEvent } from 'src/decorators';
import { ImmichWorker } from 'src/enum';
import { BaseService } from 'src/services/base.service';
export class TelemetryService extends BaseService {
@OnEvent({ name: 'AppBootstrap', workers: [ImmichWorker.Api] })
async onBootstrap(): Promise<void> {
const userCount = await this.userRepository.getCount();
this.telemetryRepository.api.addToGauge('immich.users.total', userCount);
}
@OnEvent({ name: 'UserCreate' })
onUserCreate() {
this.telemetryRepository.api.addToGauge(`immich.users.total`, 1);
}
@OnEvent({ name: 'UserDelete' })
onUserDelete() {
this.telemetryRepository.api.addToGauge(`immich.users.total`, -1);
}
@OnEvent({ name: 'UserRestore' })
onUserRestore() {
this.telemetryRepository.api.addToGauge(`immich.users.total`, 1);
}
}