@codefresh-io/cf-telemetry 1.0.3 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -10,4 +10,5 @@ export declare const mongodb: {
10
10
  };
11
11
  export declare const logs: {
12
12
  Logger: typeof log.Logger;
13
+ runInContext: <R, TArgs extends unknown[]>({ initiator, target, account_id }: import("./logger/types").LogMetadata, callback: (...args: TArgs) => R, ...args: TArgs) => R;
13
14
  };
package/dist/index.js CHANGED
@@ -57,5 +57,6 @@ exports.mongodb = {
57
57
  };
58
58
  exports.logs = {
59
59
  Logger: log.Logger,
60
+ runInContext: log.runInContext,
60
61
  };
61
62
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,yDAA2C;AAC3C,2DAA6C;AAC7C,sDAAwC;AAEjC,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC/C,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/C,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;KACpD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC,CAAC;AARW,QAAA,IAAI,QAQf;AAEW,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,OAAO;CACtB,CAAC;AAEW,QAAA,OAAO,GAAG;IACrB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;CACjD,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,MAAM,EAAE,GAAG,CAAC,MAAM;CACnB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAgC;AAChC,yDAA2C;AAC3C,2DAA6C;AAC7C,sDAAwC;AAEjC,MAAM,IAAI,GAAG,KAAK,IAAmB,EAAE;IAC5C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IAC/C,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/C,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC;KACpD,CAAC,CAAC;IACH,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;AAChD,CAAC,CAAC;AARW,QAAA,IAAI,QAQf;AAEW,QAAA,UAAU,GAAG;IACxB,QAAQ,EAAE,IAAI,CAAC,QAAQ;IACvB,OAAO,EAAE,IAAI,CAAC,OAAO;CACtB,CAAC;AAEW,QAAA,OAAO,GAAG;IACrB,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;CACjD,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,MAAM,EAAE,GAAG,CAAC,MAAM;IAClB,YAAY,EAAE,GAAG,CAAC,YAAY;CAC/B,CAAC"}
@@ -1,4 +1,8 @@
1
1
  export declare const config: {
2
2
  readonly level: "debug" | "info" | "warn" | "error";
3
3
  readonly shouldPrettify: boolean;
4
+ readonly sync: boolean;
5
+ readonly defaultInitiator: {
6
+ type: string;
7
+ };
4
8
  };
@@ -10,5 +10,7 @@ if (!isKnownLevel)
10
10
  exports.config = {
11
11
  level: isKnownLevel ? detectedLevel : 'info',
12
12
  shouldPrettify: process.env['CF_TELEMETRY_LOGS_PRETTIFY'] === 'true',
13
+ sync: process.env['CF_TELEMETRY_LOGS_SYNC'] === 'true',
14
+ defaultInitiator: { type: 'system' },
13
15
  };
14
16
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/logger/config.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,MAAM,CAAC;AACvE,8DAA8D;AAC9D,MAAM,YAAY,GAAG,aAAK,CAAC,QAAQ,CAAC,aAAoB,CAAC,CAAC;AAC1D,IAAI,CAAC,YAAY;IAAE,OAAO,CAAC,IAAI,CAAC,sBAAsB,aAAa,yBAAyB,CAAC,CAAC;AAEjF,QAAA,MAAM,GAAG;IACpB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,aAAsB,CAAC,CAAC,CAAC,MAAM;IACrD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,KAAK,MAAM;CAC5D,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/logger/config.ts"],"names":[],"mappings":";;;AAAA,mCAA6C;AAE7C,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,MAAM,CAAC;AACvE,8DAA8D;AAC9D,MAAM,YAAY,GAAG,aAAK,CAAC,QAAQ,CAAC,aAAoB,CAAC,CAAC;AAC1D,IAAI,CAAC,YAAY;IAAE,OAAO,CAAC,IAAI,CAAC,sBAAsB,aAAa,yBAAyB,CAAC,CAAC;AAEjF,QAAA,MAAM,GAAG;IACpB,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,aAAsB,CAAC,CAAC,CAAC,MAAM;IACrD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,KAAK,MAAM;IACpE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,KAAK,MAAM;IACtD,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAqC;CAC/D,CAAC"}
@@ -1 +1,2 @@
1
1
  export { Logger } from './logger';
2
+ export { runInContext } from './run-in-context';
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Logger = void 0;
3
+ exports.runInContext = exports.Logger = void 0;
4
4
  var logger_1 = require("./logger");
5
5
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
6
+ var run_in_context_1 = require("./run-in-context");
7
+ Object.defineProperty(exports, "runInContext", { enumerable: true, get: function () { return run_in_context_1.runInContext; } });
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":";;;AAAA,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AACf,mDAAgD;AAAvC,8GAAA,YAAY,OAAA"}
@@ -1,90 +1,61 @@
1
1
  import type { Logger as ILogger, LoggerOptions, Scope } from './types';
2
2
  export declare class Logger implements ILogger {
3
3
  #private;
4
+ constructor(options?: Scope | LoggerOptions);
4
5
  /**
5
- * Logger constructor.
6
- * @param scope Scope of the logger. Will be prepended to all log messages.
7
- * @param options Logger options.
8
- * @param options.attributes Additional attributes to be added to each log line.
6
+ * `debug` log level.
7
+ * @param err Error object to log.
9
8
  */
10
- constructor(scope?: Scope, options?: LoggerOptions);
9
+ debug(err: Error): void;
11
10
  /**
12
- * Debug log level.
13
- * @param data Additional data to log. Might be omitted.
14
- * @param msg Message string to log. The message string may contain a printf style string
15
- * with support for the following placeholders:
16
- * `%s` – string placeholder
17
- * `%d` – digit placeholder
18
- * `%O`, `%o`, and `%j` – object placeholder.
19
- * Values supplied as additional arguments to the logger method after message string
20
- * will then be interpolated accordingly.
21
- * @param interpolationValues All arguments supplied after `msg` are serialized and interpolated
22
- * according to any supplied printf-style placeholders (`%s`, `%d`, `%o|%O|%j`)
23
- * to form the final output msg value for the JSON log line.
11
+ * `debug` log level.
12
+ * @param msg Message string to log.
13
+ * @param data Optional additional data to log.
24
14
  */
25
- debug(msg: string, ...interpolationValues: unknown[]): void;
26
- debug(data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
15
+ debug(msg: string, data?: unknown): void;
27
16
  /**
28
- * Info log level.
29
- * @param data Additional data to log. Might be omitted.
30
- * @param msg Message string to log. The message string may contain a printf style string
31
- * with support for the following placeholders:
32
- * `%s` – string placeholder
33
- * `%d` – digit placeholder
34
- * `%O`, `%o`, and `%j` – object placeholder.
35
- * Values supplied as additional arguments to the logger method after message string
36
- * will then be interpolated accordingly.
37
- * @param interpolationValues All arguments supplied after `msg` are serialized and interpolated
38
- * according to any supplied printf-style placeholders (`%s`, `%d`, `%o|%O|%j`)
39
- * to form the final output msg value for the JSON log line.
17
+ * `info` log level.
18
+ * @param err Error object to log.
40
19
  */
41
- info(msg: string, ...interpolationValues: unknown[]): void;
42
- info(data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
20
+ info(err: Error): void;
21
+ /**
22
+ * `info` log level.
23
+ * @param msg Message string to log.
24
+ * @param data Optional additional data to log.
25
+ */
26
+ info(msg: string, data?: unknown): void;
43
27
  /**
44
28
  * Alias for `info` log level.
45
29
  */
46
30
  log: {
47
- (msg: string, ...interpolationValues: unknown[]): void;
48
- (data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
31
+ (err: Error): void;
32
+ (msg: string, data?: unknown): void;
49
33
  };
50
34
  /**
51
- * Warn log level.
52
- * @param data Additional data to log. Might be omitted.
53
- * @param msg Message string to log. The message string may contain a printf style string
54
- * with support for the following placeholders:
55
- * `%s` – string placeholder
56
- * `%d` digit placeholder
57
- * `%O`, `%o`, and `%j` object placeholder.
58
- * Values supplied as additional arguments to the logger method after message string
59
- * will then be interpolated accordingly.
60
- * @param interpolationValues All arguments supplied after `msg` are serialized and interpolated
61
- * according to any supplied printf-style placeholders (`%s`, `%d`, `%o|%O|%j`)
62
- * to form the final output msg value for the JSON log line.
35
+ * `warn` log level.
36
+ * @param err Error object to log.
37
+ */
38
+ warn(err: Error): void;
39
+ /**
40
+ * `warn` log level.
41
+ * @param msg Message string to log.
42
+ * @param data Optional additional data to log.
43
+ */
44
+ warn(msg: string, data?: unknown): void;
45
+ /**
46
+ * `error` log level.
47
+ * @param err Error object to log.
63
48
  */
64
- warn(msg: string, ...interpolationValues: unknown[]): void;
65
- warn(data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
49
+ error(err: Error): void;
66
50
  /**
67
- * Error log level.
68
- * @param data Additional data to log. Might be omitted.
69
- * @param msg Message string to log. The message string may contain a printf style string
70
- * with support for the following placeholders:
71
- * `%s` – string placeholder
72
- * `%d` – digit placeholder
73
- * `%O`, `%o`, and `%j` – object placeholder.
74
- * Values supplied as additional arguments to the logger method after message string
75
- * will then be interpolated accordingly.
76
- * @param interpolationValues All arguments supplied after `msg` are serialized and interpolated
77
- * according to any supplied printf-style placeholders (`%s`, `%d`, `%o|%O|%j`)
78
- * to form the final output msg value for the JSON log line.
51
+ * `error` log level.
52
+ * @param msg Message string to log.
53
+ * @param data Optional additional data to log.
79
54
  */
80
- error(msg: string, ...interpolationValues: unknown[]): void;
81
- error(data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
55
+ error(msg: string, data?: unknown): void;
82
56
  /**
83
57
  * Create child logger.
84
- * @param scope Scope of the child logger. Will be appended to the parent scope (`parent:child`).
85
- * @param options Options for the child logger.
86
- * @param options.attributes Additional attributes to be added to each log line. Will override parent attributes if key the same, otherwise will be added.
87
58
  * @returns Child logger
88
59
  */
89
- child(scope?: Scope, options?: LoggerOptions): Logger;
60
+ child(options?: Scope | LoggerOptions): Logger;
90
61
  }
@@ -4,31 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Logger = void 0;
7
- const change_case_all_1 = require("change-case-all");
8
7
  const pino_1 = __importDefault(require("pino"));
9
8
  const config_1 = require("./config");
9
+ const metadata_storage_1 = require("./metadata-storage");
10
10
  class Logger {
11
11
  #options;
12
- #scope;
13
12
  #baseLogger;
14
- /**
15
- * Logger constructor.
16
- * @param scope Scope of the logger. Will be prepended to all log messages.
17
- * @param options Logger options.
18
- * @param options.attributes Additional attributes to be added to each log line.
19
- */
20
- constructor(scope, options = {}) {
21
- this.#options = {
22
- ...options,
23
- attributes: this.#prepareAttributes(options.attributes ?? {}),
24
- };
25
- this.#scope = scope;
13
+ #defaultInitiator = config_1.config.defaultInitiator;
14
+ constructor(options = {}) {
15
+ this.#options = typeof options === 'string' ? { scope: options } : options;
26
16
  this.#baseLogger = (0, pino_1.default)({
27
17
  level: config_1.config.level,
28
- base: {
29
- scope_name: this.#scope,
30
- ...this.#options.attributes,
31
- },
18
+ base: null,
32
19
  formatters: {
33
20
  level: label => ({ level: label }),
34
21
  },
@@ -41,82 +28,69 @@ class Logger {
41
28
  },
42
29
  },
43
30
  },
44
- });
45
- }
46
- #prepareAttributes(attributes) {
47
- return Object.entries(attributes)
48
- .reduce((acc, [key, value]) => {
49
- const snakeKey = change_case_all_1.Case.snake(key);
50
- const prefixedKey = key.startsWith('cf_') ? snakeKey : `cf_${snakeKey}`;
51
- acc[prefixedKey] = value;
52
- return acc;
53
- }, {});
54
- }
55
- #mergeAttributes(target, source) {
56
- return { ...target, ...source };
31
+ }, pino_1.default.destination({ sync: config_1.config.sync }));
57
32
  }
58
33
  #getChildScope(childScope) {
59
- if (!this.#scope)
60
- return childScope;
61
- return `${this.#scope}${childScope ? `:${childScope}` : ''}`;
34
+ return this.#options.scope
35
+ ? `${this.#options.scope}${childScope ? `:${childScope}` : ''}`
36
+ : childScope;
37
+ }
38
+ #getChildOptions(parentOptions, childOptions) {
39
+ if (typeof childOptions === 'string')
40
+ childOptions = { scope: childOptions };
41
+ return {
42
+ ...parentOptions,
43
+ ...childOptions,
44
+ scope: this.#getChildScope(childOptions.scope),
45
+ };
62
46
  }
63
47
  #write(level, ...args) {
64
- const body = {};
65
- if (this.#options.useLastArgAsScope === true
66
- && !this.#scope
67
- && args.length > 1
68
- && typeof args.at(-1) === 'string') {
69
- body['scope_name'] = this.#getChildScope(args.pop());
48
+ const body = {
49
+ msg: undefined,
50
+ data: undefined,
51
+ err: undefined,
52
+ cf: metadata_storage_1.metadataStorage.getStore() ?? {},
53
+ scope_name: this.#options.useLastArgAsScope === true
54
+ && !this.#options.scope
55
+ && args.length > 1
56
+ && typeof args.at(-1) === 'string'
57
+ ? args.pop()
58
+ : this.#options.scope,
59
+ };
60
+ body.cf.initiator ??= this.#defaultInitiator;
61
+ const [msgOrErr, data] = args;
62
+ if (msgOrErr instanceof Error) {
63
+ body.err = msgOrErr;
70
64
  }
71
- const [msg, ...interpolationValues] = args;
72
- if (typeof msg === 'object') {
73
- if (msg instanceof Error) {
74
- body['err'] = msg;
75
- }
76
- else if (msg === null) {
77
- body['msg'] = msg;
78
- }
79
- else {
80
- body['data'] = msg;
81
- }
65
+ else {
66
+ body.msg = msgOrErr;
82
67
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- return this.#baseLogger[level](body, ...interpolationValues);
68
+ body[data && data instanceof Error ? 'err' : 'data'] = data;
84
69
  }
85
- return 'scope_name' in body
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- ? this.#baseLogger[level](body, msg, ...interpolationValues)
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- : this.#baseLogger[level](msg, ...interpolationValues);
70
+ return this.#baseLogger[level](body);
90
71
  }
91
- debug(data, msg, ...interpolationValues) {
92
- this.#write('debug', data, msg, ...interpolationValues);
72
+ debug(...args) {
73
+ this.#write('debug', ...args);
93
74
  }
94
- info(data, msg, ...interpolationValues) {
95
- this.#write('info', data, msg, ...interpolationValues);
75
+ info(...args) {
76
+ this.#write('info', ...args);
96
77
  }
97
78
  /**
98
79
  * Alias for `info` log level.
99
80
  */
100
81
  log = this.info;
101
- warn(data, msg, ...interpolationValues) {
102
- this.#write('warn', data, msg, ...interpolationValues);
82
+ warn(...args) {
83
+ this.#write('warn', ...args);
103
84
  }
104
- error(data, msg, ...interpolationValues) {
105
- this.#write('error', data, msg, ...interpolationValues);
85
+ error(...args) {
86
+ this.#write('error', ...args);
106
87
  }
107
88
  /**
108
89
  * Create child logger.
109
- * @param scope Scope of the child logger. Will be appended to the parent scope (`parent:child`).
110
- * @param options Options for the child logger.
111
- * @param options.attributes Additional attributes to be added to each log line. Will override parent attributes if key the same, otherwise will be added.
112
90
  * @returns Child logger
113
91
  */
114
- child(scope, options = {}) {
115
- const { attributes: childAttributes = {} } = options;
116
- const childScope = this.#getChildScope(scope);
117
- return new Logger(childScope, {
118
- attributes: this.#mergeAttributes(this.#options.attributes, this.#prepareAttributes(childAttributes)),
119
- });
92
+ child(options = {}) {
93
+ return new Logger(this.#getChildOptions(this.#options, options));
120
94
  }
121
95
  }
122
96
  exports.Logger = Logger;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAuC;AACvC,gDAAwB;AACxB,qCAAkC;AAGlC,MAAa,MAAM;IACjB,QAAQ,CAA6C;IACrD,MAAM,CAAoB;IAC1B,WAAW,CAAc;IAEzB;;;;;OAKG;IACH,YAAY,KAAa,EAAE,UAAyB,EAAE;QACpD,IAAI,CAAC,QAAQ,GAAG;YACd,GAAG,OAAO;YACV,UAAU,EAAE,IAAI,CAAC,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G,IAAa;QACpB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAChC,CAAC;IAaD,IAAI,CAAC,GAAG,IAAa;QACnB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC;IAahB,IAAI,CAAC,GAAG,IAAa;QACnB,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/B,CAAC;IAaD,KAAK,CAAC,GAAG,IAAa;QACpB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,UAAiC,EAAE;QACvC,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;CACF;AA/ID,wBA+IC"}
@@ -0,0 +1,3 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import type { LogMetadata } from './types';
3
+ export declare const metadataStorage: AsyncLocalStorage<LogMetadata>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.metadataStorage = void 0;
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
+ exports.metadataStorage = new node_async_hooks_1.AsyncLocalStorage();
6
+ //# sourceMappingURL=metadata-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata-storage.js","sourceRoot":"","sources":["../../src/logger/metadata-storage.ts"],"names":[],"mappings":";;;AAAA,uDAAqD;AAGxC,QAAA,eAAe,GAAG,IAAI,oCAAiB,EAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { LogMetadata } from './types';
2
+ /**
3
+ * Provided metadata will be attached to each log line within the callback.
4
+ * `runInContext` will return the result of the callback.
5
+ * If the callback throws an error, it will be thrown by `runInContext` too.
6
+ *
7
+ * Nested calls of `runInContext` will merge metadata except for `initiator` key which can be provided only once.
8
+ */
9
+ export declare const runInContext: <R, TArgs extends unknown[]>({ initiator, target, account_id }: LogMetadata, callback: (...args: TArgs) => R, ...args: TArgs) => R;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runInContext = void 0;
4
+ const metadata_storage_1 = require("./metadata-storage");
5
+ /**
6
+ * Provided metadata will be attached to each log line within the callback.
7
+ * `runInContext` will return the result of the callback.
8
+ * If the callback throws an error, it will be thrown by `runInContext` too.
9
+ *
10
+ * Nested calls of `runInContext` will merge metadata except for `initiator` key which can be provided only once.
11
+ */
12
+ const runInContext = ({ initiator, target, account_id }, callback, ...args) => {
13
+ return metadata_storage_1.metadataStorage.run({
14
+ ...initiator && { initiator },
15
+ ...metadata_storage_1.metadataStorage.getStore(),
16
+ ...target && { target },
17
+ ...account_id && { account_id },
18
+ }, callback, ...args);
19
+ };
20
+ exports.runInContext = runInContext;
21
+ //# sourceMappingURL=run-in-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-in-context.js","sourceRoot":"","sources":["../../src/logger/run-in-context.ts"],"names":[],"mappings":";;;AAAA,yDAAqD;AAGrD;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAC1B,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAe,EAC9C,QAA+B,EAC/B,GAAG,IAAW,EACX,EAAE;IACL,OAAO,kCAAe,CAAC,GAAG,CACxB;QACE,GAAG,SAAS,IAAI,EAAE,SAAS,EAAE;QAC7B,GAAG,kCAAe,CAAC,QAAQ,EAAE;QAC7B,GAAG,MAAM,IAAI,EAAE,MAAM,EAAE;QACvB,GAAG,UAAU,IAAI,EAAE,UAAU,EAAE;KAChC,EACD,QAAQ,EACR,GAAG,IAAI,CACR,CAAC;AACJ,CAAC,CAAC;AAfW,QAAA,YAAY,gBAevB"}
@@ -1,30 +1,76 @@
1
+ import type { LoggerService } from '@nestjs/common';
1
2
  export declare const Level: readonly ["debug", "info", "warn", "error"];
2
3
  export type Level = (typeof Level[number]);
3
- export type Attributes = Record<string, string>;
4
+ /**
5
+ * Scope name to be used for all log lines.
6
+ */
4
7
  export type Scope = string;
5
8
  export interface LoggerOptions {
6
9
  /**
7
- * Additional attributes to be added to each log line.
8
- * @default {}
10
+ * Scope name to be used for all log lines.
9
11
  */
10
- attributes?: Attributes;
12
+ scope?: Scope;
11
13
  /**
12
- * If scope was not set during logger creation, last argument will be used as scope value.
14
+ * If scope was not set during logger creation,
15
+ * and more than 1 arg is passed to the logger func,
16
+ * the last argument will be used as scope value.
13
17
  * _Recommended to use only in NestJS for app logger (`app.useLogger()`)_.
14
18
  * @default false
15
19
  */
16
20
  useLastArgAsScope?: boolean;
17
21
  }
22
+ export type LogMessage = string;
23
+ export type LogData = unknown;
24
+ export type LogArgs = [LogMessage, LogData?, Scope?] | [Error, Scope?];
18
25
  export interface LogFn {
19
- (data: unknown, msg?: string, ...interpolationValues: unknown[]): void;
20
- (msg: string, ...interpolationValues: unknown[]): void;
26
+ (err: Error, scope?: Scope): void;
27
+ (msg: LogMessage, data?: LogData, scope?: Scope): void;
21
28
  }
22
- export declare class Logger {
23
- constructor(scope?: Scope, options?: LoggerOptions);
29
+ export declare class Logger implements LoggerService {
30
+ constructor(options?: Scope | LoggerOptions);
24
31
  debug: LogFn;
25
32
  info: LogFn;
26
33
  warn: LogFn;
27
34
  error: LogFn;
28
35
  log: LogFn;
29
- child: (scope: Scope, options?: LoggerOptions) => Logger;
36
+ child: (options?: Scope | LoggerOptions) => Logger;
37
+ }
38
+ export interface LogMetadata {
39
+ /**
40
+ * Initiator of the action. E.g. user, system, etc.
41
+ */
42
+ initiator?: {
43
+ /**
44
+ * Type of the initiator. E.g. user, system, etc.
45
+ */
46
+ type: string;
47
+ /**
48
+ * ID of the initiator.
49
+ */
50
+ id?: string;
51
+ };
52
+ /**
53
+ * Codefresh business entity affected by the action. E.g. v1_build, v2_runtime, etc.
54
+ */
55
+ target?: {
56
+ /**
57
+ * Type of the target. E.g. v1_build, v2_runtime, etc.
58
+ */
59
+ type: string;
60
+ /**
61
+ * ID of the target.
62
+ */
63
+ id?: string;
64
+ };
65
+ /**
66
+ * Codefresh Account ID affected by the action.
67
+ */
68
+ account_id?: string;
69
+ }
70
+ export interface LogBody {
71
+ msg?: LogMessage;
72
+ data?: LogData;
73
+ err?: Error;
74
+ cf: LogMetadata;
75
+ scope_name?: Scope;
30
76
  }
@@ -4,4 +4,6 @@ exports.Level = void 0;
4
4
  exports.Level = ['debug', 'info', 'warn', 'error'];
5
5
  ;
6
6
  ;
7
+ ;
8
+ ;
7
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/logger/types.ts"],"names":[],"mappings":";;;AAAa,QAAA,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAsBhE,CAAC;AAYD,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/logger/types.ts"],"names":[],"mappings":";;;AAEa,QAAA,KAAK,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAqBhE,CAAC;AAQD,CAAC;AAWD,CAAC;AAiCD,CAAC"}
@@ -15,7 +15,7 @@ const initPrometheus = async (logger) => {
15
15
  }
16
16
  ;
17
17
  try {
18
- logger.info({ config: config_1.config }, 'Initializing Prometheus');
18
+ logger.info('Initializing Prometheus', { config: config_1.config });
19
19
  if (config_1.config.shouldCollectProcessMetrics)
20
20
  client_1.client.collectDefaultMetrics();
21
21
  const metricsServer = (0, fastify_1.default)();
@@ -31,7 +31,7 @@ const initPrometheus = async (logger) => {
31
31
  logger.info('Prometheus initialized');
32
32
  }
33
33
  catch (exception) {
34
- logger.error(exception, 'Failed to initialize Prometheus');
34
+ logger.error('Failed to initialize Prometheus', exception);
35
35
  }
36
36
  };
37
37
  exports.initPrometheus = initPrometheus;
@@ -1 +1 @@
1
- {"version":3,"file":"init-prometheus.js","sourceRoot":"","sources":["../../../src/metrics/prometheus/init-prometheus.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAE9B,qCAA4C;AAC5C,qCAAkC;AAE3B,MAAM,cAAc,GAAG,KAAK,EAAE,MAAc,EAAiB,EAAE;IACpE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IACpC,IAAI,eAAM,CAAC,OAAO,KAAK,KAAK,EAAE,CAAC;QAC7B,MAAM,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAC;QACnG,OAAO;IACT,CAAC;IAAA,CAAC;IAEF,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAN,eAAM,EAAE,EAAE,yBAAyB,CAAC,CAAC;QACnD,IAAI,eAAM,CAAC,2BAA2B;YAAE,eAAM,CAAC,qBAAqB,EAAE,CAAC;QACvE,MAAM,aAAa,GAAG,IAAA,iBAAO,GAAE,CAAC;QAChC,aAAa,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE;YACtD,KAAK,CAAC,IAAI,CAAC,iBAAQ,CAAC,WAAW,CAAC,CAAC;YACjC,OAAO,iBAAQ,CAAC,OAAO,EAAE,CAAC;QAC5B,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC;YACzC,IAAI,EAAE,eAAM,CAAC,IAAI;YACjB,IAAI,EAAE,eAAM,CAAC,IAAI;SAClB,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,kCAAkC,OAAO,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,SAAS,EAAE,CAAC;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C,OAAO,SAAS,EAAE,CAAC;QACnB,MAAM,CAAC,KAAK,CAAC,iCAAiC,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC;AAxBW,QAAA,cAAc,kBAwBzB"}
@@ -12,7 +12,7 @@ const initPyroscope = async (logger) => {
12
12
  logger.info('Pyroscope is disabled. Set CF_TELEMETRY_PYROSCOPE_ENABLE=true to enable it');
13
13
  return;
14
14
  }
15
- logger.info({ config: config_1.config.config }, 'Initializing Pyroscope');
15
+ logger.info('Initializing Pyroscope', { config: config_1.config.config });
16
16
  nodejs_1.default.init(config_1.config.config);
17
17
  nodejs_1.default.start();
18
18
  logger.info('Pyroscope initialized');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA0C;AAE1C,qCAAkC;AAE3B,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAiB,EAAE;IACnE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,CAAC,eAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;QAC1F,OAAO;IACT,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,eAAM,CAAC,MAAM,EAAE,EAAE,wBAAwB,CAAC,CAAC;IACjE,gBAAS,CAAC,IAAI,CAAC,eAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,gBAAS,CAAC,KAAK,EAAE,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACvC,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/profiles/index.ts"],"names":[],"mappings":";;;;;;AAAA,+DAA0C;AAE1C,qCAAkC;AAE3B,MAAM,aAAa,GAAG,KAAK,EAAE,MAAc,EAAiB,EAAE;IACnE,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,CAAC,eAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,4EAA4E,CAAC,CAAC;QAC1F,OAAO;IACT,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,wBAAwB,EAAE,EAAE,MAAM,EAAE,eAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,gBAAS,CAAC,IAAI,CAAC,eAAM,CAAC,MAAM,CAAC,CAAC;IAC9B,gBAAS,CAAC,KAAK,EAAE,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACvC,CAAC,CAAC;AAXW,QAAA,aAAa,iBAWxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefresh-io/cf-telemetry",
3
- "version": "1.0.3",
3
+ "version": "2.0.0-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/**/*"
@@ -22,26 +22,23 @@
22
22
  "node": ">=20"
23
23
  },
24
24
  "devDependencies": {
25
- "@eslint/js": "^9.18.0",
26
- "@stylistic/eslint-plugin": "^2.12.1",
27
- "@types/node": "^22.10.5",
28
- "eslint": "^9.18.0",
29
- "mongodb": "^6.12.0",
30
- "pino-pretty": "^13.0.0",
25
+ "@eslint/js": "^9.19.0",
26
+ "@nestjs/common": "^11.0.7",
27
+ "@stylistic/eslint-plugin": "^3.0.1",
28
+ "@types/node": "^22.12.0",
29
+ "eslint": "^9.19.0",
30
+ "mongodb": "^6.13.0",
31
31
  "rimraf": "^6.0.1",
32
32
  "typescript": "^5.7.3",
33
- "typescript-eslint": "^8.19.1",
34
- "vitest": "^2.1.8"
33
+ "typescript-eslint": "^8.22.0",
34
+ "vitest": "^3.0.4"
35
35
  },
36
36
  "dependencies": {
37
37
  "@christiangalsterer/mongodb-driver-prometheus-exporter": "^2.3.0",
38
38
  "@pyroscope/nodejs": "^0.4.3",
39
- "change-case-all": "^2.1.0",
40
39
  "fastify": "^5.2.1",
41
40
  "pino": "^9.6.0",
41
+ "pino-pretty": "^13.0.0",
42
42
  "prom-client": "^15.1.3"
43
- },
44
- "peerDependencies": {
45
- "mongodb": "^6.9.0"
46
43
  }
47
44
  }