mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server): correlation id via injected logger (#8823)
* feat(server): correlation id via injected logger * feat: cid response header
This commit is contained in:
parent
95e67a7b1d
commit
2db76034b1
16 changed files with 152 additions and 26 deletions
|
|
@ -8,20 +8,21 @@ import sirv from 'sirv';
|
|||
import { ApiModule, ImmichAdminModule, MicroservicesModule } from 'src/app.module';
|
||||
import { WEB_ROOT, envName, excludePaths, isDev, serverVersion } from 'src/constants';
|
||||
import { LogLevel } from 'src/entities/system-config.entity';
|
||||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { WebSocketAdapter } from 'src/middleware/websocket.adapter';
|
||||
import { ApiService } from 'src/services/api.service';
|
||||
import { otelSDK } from 'src/utils/instrumentation';
|
||||
import { ImmichLogger } from 'src/utils/logger';
|
||||
import { useSwagger } from 'src/utils/misc';
|
||||
|
||||
async function bootstrapMicroservices() {
|
||||
const logger = new ImmichLogger('ImmichMicroservice');
|
||||
otelSDK.start();
|
||||
|
||||
const host = String(process.env.HOST || '0.0.0.0');
|
||||
const port = Number(process.env.MICROSERVICES_PORT) || 3002;
|
||||
|
||||
otelSDK.start();
|
||||
const app = await NestFactory.create(MicroservicesModule, { bufferLogs: true });
|
||||
app.useLogger(app.get(ImmichLogger));
|
||||
const logger = app.get(ILoggerRepository);
|
||||
logger.setContext('ImmichMicroservice');
|
||||
app.useLogger(logger);
|
||||
app.useWebSocketAdapter(new WebSocketAdapter(app));
|
||||
|
||||
await app.listen(port, host);
|
||||
|
|
@ -30,14 +31,15 @@ async function bootstrapMicroservices() {
|
|||
}
|
||||
|
||||
async function bootstrapApi() {
|
||||
const logger = new ImmichLogger('ImmichServer');
|
||||
otelSDK.start();
|
||||
|
||||
const host = String(process.env.HOST || '0.0.0.0');
|
||||
const port = Number(process.env.SERVER_PORT) || 3001;
|
||||
|
||||
otelSDK.start();
|
||||
const app = await NestFactory.create<NestExpressApplication>(ApiModule, { bufferLogs: true });
|
||||
const logger = app.get(ILoggerRepository);
|
||||
|
||||
app.useLogger(app.get(ImmichLogger));
|
||||
logger.setContext('ImmichServer');
|
||||
app.useLogger(logger);
|
||||
app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']);
|
||||
app.set('etag', 'strong');
|
||||
app.use(cookieParser());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue