mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-28 05:59:42 -08:00
refactor(core): Enrich relay-execution-lifecycle-event
logs (#12165)
This commit is contained in:
parent
365e82d200
commit
454b022305
|
@ -70,7 +70,7 @@ export abstract class AbstractPush<Connection> extends TypedEmitter<AbstractPush
|
||||||
}
|
}
|
||||||
|
|
||||||
private sendTo<Type extends PushType>(type: Type, data: PushPayload<Type>, pushRefs: string[]) {
|
private sendTo<Type extends PushType>(type: Type, data: PushPayload<Type>, pushRefs: string[]) {
|
||||||
this.logger.debug(`Send data of type "${type}" to editor-UI`, {
|
this.logger.debug(`Pushed to frontend: ${type}`, {
|
||||||
dataType: type,
|
dataType: type,
|
||||||
pushRefs: pushRefs.join(', '),
|
pushRefs: pushRefs.join(', '),
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Service } from 'typedi';
|
||||||
|
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { Logger } from '@/logging/logger.service';
|
import { Logger } from '@/logging/logger.service';
|
||||||
|
import type { LogMetadata } from '@/logging/types';
|
||||||
import { RedisClientService } from '@/services/redis-client.service';
|
import { RedisClientService } from '@/services/redis-client.service';
|
||||||
|
|
||||||
import type { PubSub } from './pubsub.types';
|
import type { PubSub } from './pubsub.types';
|
||||||
|
@ -45,7 +46,7 @@ export class Publisher {
|
||||||
// #region Publishing
|
// #region Publishing
|
||||||
|
|
||||||
/** Publish a command into the `n8n.commands` channel. */
|
/** Publish a command into the `n8n.commands` channel. */
|
||||||
async publishCommand(msg: Omit<PubSub.Command, 'senderId'>) {
|
async publishCommand(msg: PubSub.Command) {
|
||||||
// @TODO: Once this class is only ever used in scaling mode, remove next line.
|
// @TODO: Once this class is only ever used in scaling mode, remove next line.
|
||||||
if (config.getEnv('executions.mode') !== 'queue') return;
|
if (config.getEnv('executions.mode') !== 'queue') return;
|
||||||
|
|
||||||
|
@ -59,7 +60,18 @@ export class Publisher {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.logger.debug(`Published ${msg.command} to command channel`);
|
let msgName = msg.command;
|
||||||
|
|
||||||
|
const metadata: LogMetadata = { msg: msg.command, channel: 'n8n.commands' };
|
||||||
|
|
||||||
|
if (msg.command === 'relay-execution-lifecycle-event') {
|
||||||
|
const { args, type } = msg.payload;
|
||||||
|
msgName += ` (${type})`;
|
||||||
|
metadata.type = type;
|
||||||
|
metadata.executionId = args.executionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug(`Published pubsub msg: ${msgName}`, metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Publish a response to a command into the `n8n.worker-response` channel. */
|
/** Publish a response to a command into the `n8n.worker-response` channel. */
|
||||||
|
|
|
@ -23,10 +23,14 @@ export namespace PubSub {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
|
|
||||||
type _ToCommand<CommandKey extends keyof PubSubCommandMap> = {
|
type _ToCommand<CommandKey extends keyof PubSubCommandMap> = {
|
||||||
senderId: string;
|
|
||||||
targets?: string[];
|
|
||||||
command: CommandKey;
|
command: CommandKey;
|
||||||
|
|
||||||
|
/** Host ID of the sender, added during publishing. */
|
||||||
|
senderId?: string;
|
||||||
|
|
||||||
|
/** Host IDs of the receivers. */
|
||||||
|
targets?: string[];
|
||||||
|
|
||||||
/** Whether the command should be sent to the sender as well. */
|
/** Whether the command should be sent to the sender as well. */
|
||||||
selfSend?: boolean;
|
selfSend?: boolean;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Service } from 'typedi';
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
import { EventService } from '@/events/event.service';
|
import { EventService } from '@/events/event.service';
|
||||||
import { Logger } from '@/logging/logger.service';
|
import { Logger } from '@/logging/logger.service';
|
||||||
|
import type { LogMetadata } from '@/logging/types';
|
||||||
import { RedisClientService } from '@/services/redis-client.service';
|
import { RedisClientService } from '@/services/redis-client.service';
|
||||||
|
|
||||||
import type { PubSub } from './pubsub.types';
|
import type { PubSub } from './pubsub.types';
|
||||||
|
@ -72,7 +73,7 @@ export class Subscriber {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
this.logger.error(`Received malformed message via channel ${channel}`, {
|
this.logger.error('Received malformed pubsub message', {
|
||||||
msg: str,
|
msg: str,
|
||||||
channel,
|
channel,
|
||||||
});
|
});
|
||||||
|
@ -89,12 +90,18 @@ export class Subscriber {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msgName = 'command' in msg ? msg.command : msg.response;
|
let msgName = 'command' in msg ? msg.command : msg.response;
|
||||||
|
|
||||||
this.logger.debug(`Received message ${msgName} via channel ${channel}`, {
|
const metadata: LogMetadata = { msg: msgName, channel };
|
||||||
msg,
|
|
||||||
channel,
|
if ('command' in msg && msg.command === 'relay-execution-lifecycle-event') {
|
||||||
});
|
const { args, type } = msg.payload;
|
||||||
|
msgName += ` (${type})`;
|
||||||
|
metadata.type = type;
|
||||||
|
metadata.executionId = args.executionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logger.debug(`Received pubsub msg: ${msgName}`, metadata);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue