feat(server/otel): restructure observability metrics and add active sessions gauge

- Moved RateLimitMetrics import path to a more centralized location.
- Introduced a new file for active sessions gauge to track user sessions in the database.
- Updated index.ts to include new metrics and ensure proper initialization of observability metrics.
- Modified various routes and services to utilize the new observability structure.
- Added smoke tests for HTTP and WebSocket metrics to ensure proper metric registration and functionality.
- Enhanced error handling for metrics reading failures to improve observability.
This commit is contained in:
RainbowBird
2026-05-12 23:10:13 +08:00
parent 84bff1f757
commit 272cdae03b
27 changed files with 785 additions and 239 deletions
@@ -1,7 +1,7 @@
import type Redis from 'ioredis'
import type { Database } from '../../libs/db'
import type { RevenueMetrics } from '../../libs/otel'
import type { RevenueMetrics } from '../../otel'
import type { ConfigKVService } from '../config-kv'
import { useLogger } from '@guiiai/logg'
@@ -1,6 +1,6 @@
import type Redis from 'ioredis'
import type { RevenueMetrics } from '../../libs/otel'
import type { RevenueMetrics } from '../../otel'
import type { BillingService } from './billing-service'
import { useLogger } from '@guiiai/logg'
+1 -1
View File
@@ -1,5 +1,5 @@
import type { Database } from '../libs/db'
import type { EngagementMetrics } from '../libs/otel'
import type { EngagementMetrics } from '../otel'
import { useLogger } from '@guiiai/logg'
import { and, eq, isNull, or, sql } from 'drizzle-orm'
+1 -1
View File
@@ -1,7 +1,7 @@
import type { MessageRole, WireMessage } from '@proj-airi/server-sdk-shared'
import type { Database } from '../libs/db'
import type { EngagementMetrics } from '../libs/otel'
import type { EngagementMetrics } from '../otel'
import { useLogger } from '@guiiai/logg'
import { and, eq, gt, inArray, isNull, sql } from 'drizzle-orm'
+1 -1
View File
@@ -1,6 +1,6 @@
import type { Logger } from '@guiiai/logg'
import type { EmailMetrics } from '../libs/otel'
import type { EmailMetrics } from '../otel'
import { useLogger } from '@guiiai/logg'
import { errorMessageFrom } from '@moeru/std'