mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Add @ditto/metrics package
This commit is contained in:
parent
773b5da461
commit
739153afc9
17 changed files with 30 additions and 25 deletions
|
|
@ -3,7 +3,8 @@
|
|||
"./packages/api",
|
||||
"./packages/conf",
|
||||
"./packages/db",
|
||||
"./packages/ditto"
|
||||
"./packages/ditto",
|
||||
"./packages/metrics"
|
||||
],
|
||||
"tasks": {
|
||||
"start": "deno run -A --env-file --deny-read=.env packages/ditto/server.ts",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { dbQueriesCounter, dbQueryDurationHistogram } from '@ditto/metrics';
|
||||
import { logi, type LogiValue } from '@soapbox/logi';
|
||||
|
||||
import { dbQueriesCounter, dbQueryDurationHistogram } from '@/metrics.ts';
|
||||
|
||||
import type { Logger } from 'kysely';
|
||||
|
||||
/** Log the SQL for queries. */
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import {
|
||||
streamingClientMessagesCounter,
|
||||
streamingConnectionsGauge,
|
||||
streamingServerMessagesCounter,
|
||||
} from '@ditto/metrics';
|
||||
import TTLCache from '@isaacs/ttlcache';
|
||||
import { NostrEvent, NostrFilter } from '@nostrify/nostrify';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { type AppController } from '@/app.ts';
|
||||
import {
|
||||
streamingClientMessagesCounter,
|
||||
streamingConnectionsGauge,
|
||||
streamingServerMessagesCounter,
|
||||
} from '@/metrics.ts';
|
||||
import { MuteListPolicy } from '@/policies/MuteListPolicy.ts';
|
||||
import { getFeedPubkeys } from '@/queries.ts';
|
||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { cachedTranslationsSizeGauge } from '@ditto/metrics';
|
||||
import { LanguageCode } from 'iso-639-1';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { AppController } from '@/app.ts';
|
||||
import { translationCache } from '@/caches/translationCache.ts';
|
||||
import { MastodonTranslation } from '@/entities/MastodonTranslation.ts';
|
||||
import { cachedTranslationsSizeGauge } from '@/metrics.ts';
|
||||
import { getEvent } from '@/queries.ts';
|
||||
import { localeSchema } from '@/schema.ts';
|
||||
import { parseBody } from '@/utils/api.ts';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { register } from 'prom-client';
|
||||
|
||||
import { AppController } from '@/app.ts';
|
||||
import {
|
||||
dbAvailableConnectionsGauge,
|
||||
dbPoolSizeGauge,
|
||||
relayPoolRelaysSizeGauge,
|
||||
relayPoolSubscriptionsSizeGauge,
|
||||
} from '@/metrics.ts';
|
||||
} from '@ditto/metrics';
|
||||
import { register } from 'prom-client';
|
||||
|
||||
import { AppController } from '@/app.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
|
||||
/** Prometheus/OpenMetrics controller. */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { type DittoConf } from '@ditto/conf';
|
||||
import { relayConnectionsGauge, relayEventsCounter, relayMessagesCounter } from '@ditto/metrics';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { JsonValue } from '@std/json';
|
||||
import {
|
||||
|
|
@ -14,7 +15,6 @@ import {
|
|||
|
||||
import { AppController } from '@/app.ts';
|
||||
import { relayInfoController } from '@/controllers/nostr/relay-info.ts';
|
||||
import { relayConnectionsGauge, relayEventsCounter, relayMessagesCounter } from '@/metrics.ts';
|
||||
import * as pipeline from '@/pipeline.ts';
|
||||
import { RelayError } from '@/RelayError.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { firehoseEventsCounter } from '@ditto/metrics';
|
||||
import { Semaphore } from '@core/asyncutil';
|
||||
import { logi } from '@soapbox/logi';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { firehoseEventsCounter } from '@/metrics.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
import { nostrNow } from '@/utils.ts';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { httpRequestsCounter, httpResponseDurationHistogram, httpResponsesCounter } from '@ditto/metrics';
|
||||
import { ScopedPerformance } from '@esroyo/scoped-performance';
|
||||
import { MiddlewareHandler } from '@hono/hono';
|
||||
|
||||
import { httpRequestsCounter, httpResponseDurationHistogram, httpResponsesCounter } from '@/metrics.ts';
|
||||
|
||||
/** Prometheus metrics middleware that tracks HTTP requests by methods and responses by status code. */
|
||||
export const metricsMiddleware: MiddlewareHandler = async (c, next) => {
|
||||
// Start a timer to measure the duration of the response.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { DittoTables } from '@ditto/db';
|
||||
import { pipelineEventsCounter, policyEventsCounter, webPushNotificationsCounter } from '@ditto/metrics';
|
||||
import { NKinds, NostrEvent, NSchema as n } from '@nostrify/nostrify';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { Kysely, UpdateObject } from 'kysely';
|
||||
|
|
@ -9,7 +10,6 @@ import { pipelineEncounters } from '@/caches/pipelineEncounters.ts';
|
|||
import { Conf } from '@/config.ts';
|
||||
import { DittoPush } from '@/DittoPush.ts';
|
||||
import { DittoEvent } from '@/interfaces/DittoEvent.ts';
|
||||
import { pipelineEventsCounter, policyEventsCounter, webPushNotificationsCounter } from '@/metrics.ts';
|
||||
import { RelayError } from '@/RelayError.ts';
|
||||
import { AdminSigner } from '@/signers/AdminSigner.ts';
|
||||
import { hydrateEvents } from '@/storages/hydrate.ts';
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
// deno-lint-ignore-file require-await
|
||||
import { type DittoDatabase, DittoDB } from '@ditto/db';
|
||||
import { internalSubscriptionsSizeGauge } from '@ditto/metrics';
|
||||
import { logi } from '@soapbox/logi';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { internalSubscriptionsSizeGauge } from '@/metrics.ts';
|
||||
import { wsUrlSchema } from '@/schema.ts';
|
||||
import { AdminStore } from '@/storages/AdminStore.ts';
|
||||
import { EventsDB } from '@/storages/EventsDB.ts';
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import { DittoTables } from '@ditto/db';
|
||||
import { NPostgres, NPostgresSchema } from '@nostrify/db';
|
||||
import { dbEventsCounter } from '@ditto/metrics';
|
||||
import { NIP50, NKinds, NostrEvent, NostrFilter, NSchema as n } from '@nostrify/nostrify';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { JsonValue } from '@std/json';
|
||||
|
|
@ -12,7 +13,6 @@ import { nip27 } from 'nostr-tools';
|
|||
import tldts from 'tldts';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { dbEventsCounter } from '@/metrics.ts';
|
||||
import { RelayError } from '@/RelayError.ts';
|
||||
import { isNostrId } from '@/utils.ts';
|
||||
import { abortError } from '@/utils/abort.ts';
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { DOMParser } from '@b-fuze/deno-dom';
|
||||
import { DittoTables } from '@ditto/db';
|
||||
import { cachedFaviconsSizeGauge } from '@ditto/metrics';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { safeFetch } from '@soapbox/safe-fetch';
|
||||
import { Kysely } from 'kysely';
|
||||
import tldts from 'tldts';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { cachedFaviconsSizeGauge } from '@/metrics.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
import { nostrNow } from '@/utils.ts';
|
||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { cachedLnurlsSizeGauge } from '@ditto/metrics';
|
||||
import { NostrEvent } from '@nostrify/nostrify';
|
||||
import { LNURL, LNURLDetails } from '@nostrify/nostrify/ln';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { safeFetch } from '@soapbox/safe-fetch';
|
||||
import { JsonValue } from '@std/json';
|
||||
|
||||
import { cachedLnurlsSizeGauge } from '@/metrics.ts';
|
||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||
import { errorJson } from '@/utils/log.ts';
|
||||
import { Time } from '@/utils/time.ts';
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { nip19 } from 'nostr-tools';
|
||||
import { cachedNip05sSizeGauge } from '@ditto/metrics';
|
||||
import { NIP05, NStore } from '@nostrify/nostrify';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { safeFetch } from '@soapbox/safe-fetch';
|
||||
import { nip19 } from 'nostr-tools';
|
||||
import tldts from 'tldts';
|
||||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { cachedNip05sSizeGauge } from '@/metrics.ts';
|
||||
import { Storages } from '@/storages.ts';
|
||||
import { errorJson } from '@/utils/log.ts';
|
||||
import { SimpleLRU } from '@/utils/SimpleLRU.ts';
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { cachedLinkPreviewSizeGauge } from '@ditto/metrics';
|
||||
import TTLCache from '@isaacs/ttlcache';
|
||||
import { logi } from '@soapbox/logi';
|
||||
import { safeFetch } from '@soapbox/safe-fetch';
|
||||
|
|
@ -6,7 +7,6 @@ import { unfurl } from 'unfurl.js';
|
|||
|
||||
import { Conf } from '@/config.ts';
|
||||
import { PreviewCard } from '@/entities/PreviewCard.ts';
|
||||
import { cachedLinkPreviewSizeGauge } from '@/metrics.ts';
|
||||
import { errorJson } from '@/utils/log.ts';
|
||||
|
||||
async function unfurlCard(url: string, signal: AbortSignal): Promise<PreviewCard | null> {
|
||||
|
|
|
|||
6
packages/metrics/deno.json
Normal file
6
packages/metrics/deno.json
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@ditto/metrics",
|
||||
"exports": {
|
||||
".": "./metrics.ts"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue