mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Merge branch 'policy-metrics' into 'main'
Add Policy metrics See merge request soapbox-pub/ditto!438
This commit is contained in:
commit
7860dd2a0c
2 changed files with 8 additions and 1 deletions
|
|
@ -35,6 +35,12 @@ export const pipelineEventCounter = new Counter({
|
||||||
labelNames: ['kind'],
|
labelNames: ['kind'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const policyEventCounter = new Counter({
|
||||||
|
name: 'policy_events_total',
|
||||||
|
help: 'Total number of policy OK responses',
|
||||||
|
labelNames: ['ok'],
|
||||||
|
});
|
||||||
|
|
||||||
export const relayEventCounter = new Counter({
|
export const relayEventCounter = new Counter({
|
||||||
name: 'relay_events_total',
|
name: 'relay_events_total',
|
||||||
help: 'Total number of EVENT messages processed by the relay',
|
help: 'Total number of EVENT messages processed by the relay',
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { Conf } from '@/config.ts';
|
||||||
import { DittoDB } from '@/db/DittoDB.ts';
|
import { DittoDB } from '@/db/DittoDB.ts';
|
||||||
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
import { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
||||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||||
import { pipelineEventCounter } from '@/metrics.ts';
|
import { pipelineEventCounter, policyEventCounter } from '@/metrics.ts';
|
||||||
import { RelayError } from '@/RelayError.ts';
|
import { RelayError } from '@/RelayError.ts';
|
||||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||||
|
|
@ -71,6 +71,7 @@ async function policyFilter(event: NostrEvent): Promise<void> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await policyWorker.call(event);
|
const result = await policyWorker.call(event);
|
||||||
|
policyEventCounter.inc({ ok: String(result[2]) });
|
||||||
debug(JSON.stringify(result));
|
debug(JSON.stringify(result));
|
||||||
RelayError.assert(result);
|
RelayError.assert(result);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue