mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Add a metric for active author subscriptions
This commit is contained in:
parent
9c3307f923
commit
f8eb4fc79c
2 changed files with 8 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import { DittoConf } from '@ditto/conf';
|
import { DittoConf } from '@ditto/conf';
|
||||||
import { DittoDB, DittoTables } from '@ditto/db';
|
import { DittoDB, DittoTables } from '@ditto/db';
|
||||||
import {
|
import {
|
||||||
|
activeAuthorSubscriptionsGauge,
|
||||||
cachedFaviconsSizeGauge,
|
cachedFaviconsSizeGauge,
|
||||||
cachedNip05sSizeGauge,
|
cachedNip05sSizeGauge,
|
||||||
pipelineEventsCounter,
|
pipelineEventsCounter,
|
||||||
|
|
@ -185,6 +186,7 @@ export class DittoRelayStore implements NRelay {
|
||||||
// Try to fetch a kind 0 for the user if we don't have one yet.
|
// Try to fetch a kind 0 for the user if we don't have one yet.
|
||||||
// TODO: Create a more elaborate system to refresh all replaceable events by addr.
|
// TODO: Create a more elaborate system to refresh all replaceable events by addr.
|
||||||
if (event.kind !== 0 && !event.author?.sig && !this.authorEncounters.get(event.pubkey)) {
|
if (event.kind !== 0 && !event.author?.sig && !this.authorEncounters.get(event.pubkey)) {
|
||||||
|
activeAuthorSubscriptionsGauge.inc();
|
||||||
this.authorEncounters.set(event.pubkey, true);
|
this.authorEncounters.set(event.pubkey, true);
|
||||||
|
|
||||||
const [author] = await pool.query(
|
const [author] = await pool.query(
|
||||||
|
|
@ -196,6 +198,7 @@ export class DittoRelayStore implements NRelay {
|
||||||
// await because it's important to have the kind 0 before the policy filter.
|
// await because it's important to have the kind 0 before the policy filter.
|
||||||
await this.event(author, { signal });
|
await this.event(author, { signal });
|
||||||
}
|
}
|
||||||
|
activeAuthorSubscriptionsGauge.dec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the event doesn't violate the policy.
|
// Ensure the event doesn't violate the policy.
|
||||||
|
|
|
||||||
|
|
@ -149,3 +149,8 @@ export const webPushNotificationsCounter: Counter<'type'> = new Counter({
|
||||||
help: 'Total number of Web Push notifications sent',
|
help: 'Total number of Web Push notifications sent',
|
||||||
labelNames: ['type'],
|
labelNames: ['type'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const activeAuthorSubscriptionsGauge: Gauge = new Gauge({
|
||||||
|
name: `${prefix}_active_author_subscriptions`,
|
||||||
|
help: "Number of active REQ's to find kind 0 events from the pool",
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue