chore: Add application_name to postgres logging (#11415)

This commit is contained in:
Tom Moor
2026-02-11 20:59:39 -05:00
committed by GitHub
parent 20e84c8e1d
commit a52391842f
3 changed files with 17 additions and 8 deletions
+2
View File
@@ -9,6 +9,7 @@ import env from "@server/env";
import type Model from "@server/models/base/Model";
import Logger from "../logging/Logger";
import * as models from "../models";
import { getConnectionName } from "./utils";
/**
* Returns database configuration for Sequelize constructor.
@@ -64,6 +65,7 @@ export function createDatabaseInstance(
typeValidation: true,
logQueryParameters: env.isDevelopment,
dialectOptions: {
application_name: getConnectionName(),
ssl:
env.isProduction && !isSSLDisabled
? {
+2 -8
View File
@@ -3,6 +3,7 @@ import Redis from "ioredis";
import defaults from "lodash/defaults";
import env from "@server/env";
import Logger from "@server/logging/Logger";
import { getConnectionName } from "./utils";
type RedisAdapterOptions = RedisOptions & {
/** Suffix to append to the connection name that will be displayed in Redis */
@@ -42,14 +43,7 @@ export default class RedisAdapter extends Redis {
url: string | undefined,
{ connectionNameSuffix, ...options }: RedisAdapterOptions = {}
) {
/**
* For debugging. The connection name is based on the services running in
* this process. Note that this does not need to be unique.
*/
const connectionNamePrefix = env.isDevelopment ? process.pid : "outline";
const connectionName =
`${connectionNamePrefix}:${env.SERVICES.join("-")}` +
(connectionNameSuffix ? `:${connectionNameSuffix}` : "");
const connectionName = getConnectionName(connectionNameSuffix);
if (!url || !url.startsWith("ioredis://")) {
super(
+13
View File
@@ -0,0 +1,13 @@
import env from "@server/env";
/**
* For debugging. The connection name is based on the services running in
* this process. Note that this does not need to be unique.
*/
export const getConnectionName = (connectionNameSuffix?: string) => {
const connectionNamePrefix = env.isDevelopment ? process.pid : "outline";
return (
`${connectionNamePrefix}:${env.SERVICES.join("-")}` +
(connectionNameSuffix ? `:${connectionNameSuffix}` : "")
);
};