commit
b0f5b28084
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "backend",
|
||||
"version": "1.3.0",
|
||||
"version": "1.3.1",
|
||||
"private": true,
|
||||
"homepage": "https://github.com/movie-web/backend",
|
||||
"engines": {
|
||||
|
|
|
@ -13,6 +13,7 @@ export type Metrics = {
|
|||
providerHostnames: Counter<'hostname'>;
|
||||
providerStatuses: Counter<'provider_id' | 'status'>;
|
||||
watchMetrics: Counter<'title' | 'tmdb_full_id' | 'provider_id' | 'success'>;
|
||||
toolMetrics: Counter<'tool'>;
|
||||
};
|
||||
|
||||
let metrics: null | Metrics = null;
|
||||
|
@ -59,6 +60,11 @@ export async function setupMetrics(app: FastifyInstance) {
|
|||
help: 'mw_media_watch_count',
|
||||
labelNames: ['title', 'tmdb_full_id', 'provider_id', 'success'],
|
||||
}),
|
||||
toolMetrics: new Counter({
|
||||
name: 'mw_provider_tool_count',
|
||||
help: 'mw_provider_tool_count',
|
||||
labelNames: ['tool'],
|
||||
}),
|
||||
};
|
||||
|
||||
const promClient = app.metrics.client;
|
||||
|
@ -68,6 +74,7 @@ export async function setupMetrics(app: FastifyInstance) {
|
|||
promClient.register.registerMetric(metrics.providerStatuses);
|
||||
promClient.register.registerMetric(metrics.watchMetrics);
|
||||
promClient.register.registerMetric(metrics.captchaSolves);
|
||||
promClient.register.registerMetric(metrics.toolMetrics);
|
||||
|
||||
const orm = getORM();
|
||||
const em = orm.em.fork();
|
||||
|
|
|
@ -19,6 +19,7 @@ const metricsProviderSchema = z.object({
|
|||
|
||||
const metricsProviderInputSchema = z.object({
|
||||
items: z.array(metricsProviderSchema).max(10).min(1),
|
||||
tool: z.string().optional(),
|
||||
});
|
||||
|
||||
export const metricsRouter = makeRouter((app) => {
|
||||
|
@ -65,6 +66,12 @@ export const metricsRouter = makeRouter((app) => {
|
|||
});
|
||||
}
|
||||
|
||||
if (body.tool) {
|
||||
getMetrics().toolMetrics.inc({
|
||||
tool: body.tool,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue