mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat(server): add OpenTelemetry tracing and metrics support
Adds comprehensive OpenTelemetry instrumentation for better observability: Tracing: - HTTP requests via @opentelemetry/instrumentation-http - NestJS controllers via @opentelemetry/instrumentation-nestjs-core - Redis operations via @opentelemetry/instrumentation-ioredis - BullMQ job queues via bullmq-otel - Database queries via Kysely log callback with accurate timing - File operations (send, stream, read) - Media processing (thumbnails, thumbhash, EXIF operations) - Metadata extraction Metrics: - Database connection pool usage (used/idle connections) The SDK is initialized in telemetry-preload.ts which is preloaded via --require before the main app starts. This ensures http instrumentation hooks are in place before any http module is imported. Enable tracing by setting OTEL_EXPORTER_OTLP_ENDPOINT environment variable. Also adds TraceContext to IBaseJob for future distributed trace propagation across BullMQ job boundaries.
This commit is contained in:
@@ -6,4 +6,17 @@ if [[ "$IMMICH_ENV" == "production" ]]; then
|
||||
fi
|
||||
|
||||
cd /usr/src/app || exit
|
||||
|
||||
# Compile telemetry-preload so it can be required before the app starts.
|
||||
# This is necessary for OpenTelemetry http instrumentation to work correctly.
|
||||
mkdir -p dist
|
||||
pnpm --filter immich exec tsc src/telemetry-preload.ts \
|
||||
--outDir dist \
|
||||
--esModuleInterop \
|
||||
--module node16 \
|
||||
--moduleResolution node16 \
|
||||
--target ES2022 \
|
||||
--skipLibCheck
|
||||
|
||||
export NODE_OPTIONS="${NODE_OPTIONS} --require ./dist/telemetry-preload.js"
|
||||
pnpm --filter immich exec nest start --debug "0.0.0.0:9230" --watch -- "$@"
|
||||
|
||||
Reference in New Issue
Block a user