mirror of
https://github.com/p-stream/backend.git
synced 2026-05-11 02:00:32 +00:00
maybe fix metrics?
This commit is contained in:
parent
ba3f278603
commit
4dbc103545
1 changed files with 17 additions and 9 deletions
|
|
@ -281,23 +281,31 @@ export function recordProviderMetrics(items: any[], hostname: string, tool?: str
|
||||||
// Record hostname once per request
|
// Record hostname once per request
|
||||||
metrics.providerHostnames.inc({ hostname });
|
metrics.providerHostnames.inc({ hostname });
|
||||||
|
|
||||||
// Record status and watch metrics for each item
|
// Record status metrics for each item
|
||||||
items.forEach(item => {
|
items.forEach(item => {
|
||||||
// Record provider status
|
// Record provider status
|
||||||
metrics.providerStatuses.inc({
|
metrics.providerStatuses.inc({
|
||||||
provider_id: item.embedId ?? item.providerId,
|
provider_id: item.embedId ?? item.providerId,
|
||||||
status: item.status,
|
status: item.status,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Record watch metrics for each item
|
|
||||||
metrics.watchMetrics.inc({
|
|
||||||
tmdb_full_id: item.type + '-' + item.tmdbId,
|
|
||||||
provider_id: item.providerId,
|
|
||||||
title: item.title,
|
|
||||||
success: (item.status === 'success').toString(),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Reverse items to get the last one, and find the last successful item
|
||||||
|
const itemList = [...items];
|
||||||
|
itemList.reverse();
|
||||||
|
const lastSuccessfulItem = items.find(v => v.status === 'success');
|
||||||
|
const lastItem = itemList[0];
|
||||||
|
|
||||||
|
// Record watch metrics only for the last item
|
||||||
|
if (lastItem) {
|
||||||
|
metrics.watchMetrics.inc({
|
||||||
|
tmdb_full_id: lastItem.type + '-' + lastItem.tmdbId,
|
||||||
|
provider_id: lastSuccessfulItem?.providerId ?? lastItem.providerId,
|
||||||
|
title: lastItem.title,
|
||||||
|
success: (!!lastSuccessfulItem).toString(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Record tool metrics
|
// Record tool metrics
|
||||||
if (tool) {
|
if (tool) {
|
||||||
metrics.toolMetrics.inc({ tool });
|
metrics.toolMetrics.inc({ tool });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue