mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
chore: Add application_name to postgres logging (#11415)
This commit is contained in:
@@ -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
|
||||
? {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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}` : "")
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user