mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19: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 { DittoDB, DittoTables } from '@ditto/db';
|
||||
import {
|
||||
activeAuthorSubscriptionsGauge,
|
||||
cachedFaviconsSizeGauge,
|
||||
cachedNip05sSizeGauge,
|
||||
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.
|
||||
// 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)) {
|
||||
activeAuthorSubscriptionsGauge.inc();
|
||||
this.authorEncounters.set(event.pubkey, true);
|
||||
|
||||
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 this.event(author, { signal });
|
||||
}
|
||||
activeAuthorSubscriptionsGauge.dec();
|
||||
}
|
||||
|
||||
// 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',
|
||||
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