queue metrics job every 24 hours
This commit is contained in:
@@ -5,6 +5,7 @@ import pkg from 'src/../../package.json';
|
||||
|
||||
export const AUDIT_LOG_MAX_DURATION = Duration.fromObject({ days: 100 });
|
||||
export const ONE_HOUR = Duration.fromObject({ hours: 1 });
|
||||
export const TWENTY_FOUR_HOURS = Duration.fromObject({ hours: 24 });
|
||||
|
||||
export interface IVersion {
|
||||
major: number;
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { serverVersion } from '../domain.constant';
|
||||
import { JobName } from '../job';
|
||||
import { IJobRepository } from '../repositories/job.repository';
|
||||
import { IMetricsRepository, SharedMetrics } from '../repositories/metrics.repository';
|
||||
import { MetricsDto } from './metrics.dto';
|
||||
|
||||
@Injectable()
|
||||
export class MetricsService {
|
||||
constructor(@Inject(IMetricsRepository) private repository: IMetricsRepository) {}
|
||||
constructor(
|
||||
@Inject(IJobRepository) private jobRepository: IJobRepository,
|
||||
@Inject(IMetricsRepository) private repository: IMetricsRepository,
|
||||
) {}
|
||||
|
||||
async shareMetrics(metrics: SharedMetrics) {
|
||||
async handleQueueMetrics() {
|
||||
// TODO config for what metrics should be fetched and if any at all
|
||||
|
||||
await this.jobRepository.queue({ name: JobName.METRICS, data: { assetCount: true, serverInfo: true } });
|
||||
}
|
||||
|
||||
async handleMetrics(metrics: SharedMetrics) {
|
||||
const metricsPayload = new MetricsDto();
|
||||
if (metrics.serverInfo) {
|
||||
metricsPayload.serverInfo.version = serverVersion.toString();
|
||||
|
||||
Reference in New Issue
Block a user