mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-18 21:04:23 +01:00
Add Policy metrics
This commit is contained in:
@@ -35,6 +35,12 @@ export const pipelineEventCounter = new Counter({
|
||||
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({
|
||||
name: 'relay_events_total',
|
||||
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 { deleteAttachedMedia } from '@/db/unattached-media.ts';
|
||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
import { pipelineEventCounter } from '@/metrics.ts';
|
||||
import { pipelineEventCounter, policyEventCounter } from '@/metrics.ts';
|
||||
import { RelayError } from '@/RelayError.ts';
|
||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||
@@ -71,6 +71,7 @@ async function policyFilter(event: NostrEvent): Promise<void> {
|
||||
|
||||
try {
|
||||
const result = await policyWorker.call(event);
|
||||
policyEventCounter.inc({ ok: String(result[2]) });
|
||||
debug(JSON.stringify(result));
|
||||
RelayError.assert(result);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user