mirror of
https://github.com/immich-app/immich.git
synced 2026-02-14 12:58:17 +03:00
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.
23 lines
672 B
Bash
Executable File
23 lines
672 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
if [[ "$IMMICH_ENV" == "production" ]]; then
|
|
echo "This command can only be run in development environments"
|
|
exit 1
|
|
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 -- "$@"
|