@temporalio/workflow 1.9.3 → 1.10.1

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/lib/logs.d.ts CHANGED
@@ -34,6 +34,13 @@ export interface LoggerSinksInternal extends Sinks {
34
34
  * This logger is replay-aware and will omit log messages on workflow replay. Messages emitted by this logger are
35
35
  * funnelled through a sink that forwards them to the logger registered on {@link Runtime.logger}.
36
36
  *
37
+ * Attributes from the current Workflow Execution context are automatically included as metadata on every log
38
+ * entries. An extra `sdkComponent` metadata attribute is also added, with value `workflow`; this can be used for
39
+ * fine-grained filtering of log entries further downstream.
40
+ *
41
+ * To customize log attributes, register a {@link WorkflowOutboundCallsInterceptor} that intercepts the
42
+ * `getLogAttributes()` method.
43
+ *
37
44
  * Notice that since sinks are used to power this logger, any log attributes must be transferable via the
38
45
  * {@link https://nodejs.org/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist | postMessage}
39
46
  * API.
package/lib/logs.js CHANGED
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.workflowLogAttributes = exports.executeWithLifecycleLogging = exports.log = void 0;
4
4
  const interceptors_1 = require("@temporalio/common/lib/interceptors");
5
+ const common_1 = require("@temporalio/common");
5
6
  const stack_helpers_1 = require("./stack-helpers");
6
7
  const sinks_1 = require("./sinks");
7
8
  const errors_1 = require("./errors");
@@ -19,6 +20,13 @@ const LogTimestamp = Symbol.for('log_timestamp');
19
20
  * This logger is replay-aware and will omit log messages on workflow replay. Messages emitted by this logger are
20
21
  * funnelled through a sink that forwards them to the logger registered on {@link Runtime.logger}.
21
22
  *
23
+ * Attributes from the current Workflow Execution context are automatically included as metadata on every log
24
+ * entries. An extra `sdkComponent` metadata attribute is also added, with value `workflow`; this can be used for
25
+ * fine-grained filtering of log entries further downstream.
26
+ *
27
+ * To customize log attributes, register a {@link WorkflowOutboundCallsInterceptor} that intercepts the
28
+ * `getLogAttributes()` method.
29
+ *
22
30
  * Notice that since sinks are used to power this logger, any log attributes must be transferable via the
23
31
  * {@link https://nodejs.org/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist | postMessage}
24
32
  * API.
@@ -35,6 +43,7 @@ exports.log = Object.fromEntries(['trace', 'debug', 'info', 'warn', 'error'].map
35
43
  return loggerSink[level](message, {
36
44
  // Inject the call time in nanosecond resolution as expected by the worker logger.
37
45
  [LogTimestamp]: activator.getTimeOfDay(),
46
+ sdkComponent: common_1.SdkComponent.workflow,
38
47
  ...getLogAttributes(workflowLogAttributes(activator.info)),
39
48
  ...attrs,
40
49
  });
@@ -42,24 +51,24 @@ exports.log = Object.fromEntries(['trace', 'debug', 'info', 'warn', 'error'].map
42
51
  ];
43
52
  }));
44
53
  function executeWithLifecycleLogging(fn) {
45
- exports.log.debug('Workflow started');
54
+ exports.log.debug('Workflow started', { sdkComponent: common_1.SdkComponent.worker });
46
55
  const p = fn().then((res) => {
47
- exports.log.debug('Workflow completed');
56
+ exports.log.debug('Workflow completed', { sdkComponent: common_1.SdkComponent.worker });
48
57
  return res;
49
58
  }, (error) => {
50
59
  // Avoid using instanceof checks in case the modules they're defined in loaded more than once,
51
60
  // e.g. by jest or when multiple versions are installed.
52
61
  if (typeof error === 'object' && error != null) {
53
62
  if ((0, errors_1.isCancellation)(error)) {
54
- exports.log.debug('Workflow completed as cancelled');
63
+ exports.log.debug('Workflow completed as cancelled', { sdkComponent: common_1.SdkComponent.worker });
55
64
  throw error;
56
65
  }
57
66
  else if (error instanceof interfaces_1.ContinueAsNew) {
58
- exports.log.debug('Workflow continued as new');
67
+ exports.log.debug('Workflow continued as new', { sdkComponent: common_1.SdkComponent.worker });
59
68
  throw error;
60
69
  }
61
70
  }
62
- exports.log.warn('Workflow failed', { error });
71
+ exports.log.warn('Workflow failed', { error, sdkComponent: common_1.SdkComponent.worker });
63
72
  throw error;
64
73
  });
65
74
  // Avoid showing this interceptor in stack trace query
package/lib/logs.js.map CHANGED
@@ -1 +1 @@
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C,KAAK,EAAE,EAAE;QACR,8FAA8F;QAC9F,wDAAwD;QACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAC/C,IAAI,IAAA,uBAAc,EAAC,KAAK,CAAC,EAAE,CAAC;gBAC1B,WAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,EAAE,YAAY,EAAE,qBAAY,CAAC,MAAM,EAAE,CAAC,CAAC;gBACpF,MAAM,KAAK,CAAC;YACd,CAAC;iBAAM,IAAI,KAAK,YAAY,0BAAa,EAAE,CAAC;gBAC1C,WAAG,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,YAAY,EAAE,qBAAY,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC9E,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,WAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,qBAAY,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,MAAM,KAAK,CAAC;IACd,CAAC,CACF,CAAC;IACF,sDAAsD;IACtD,IAAA,8BAAc,EAAC,CAAC,CAAC,CAAC;IAClB,OAAO,CAAC,CAAC;AACX,CAAC;AA1BD,kEA0BC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,IAAkB;IACtD,OAAO;QACL,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC;AACJ,CAAC;AARD,sDAQC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/workflow",
3
- "version": "1.9.3",
3
+ "version": "1.10.1",
4
4
  "description": "Temporal.io SDK Workflow sub-package",
5
5
  "keywords": [
6
6
  "temporal",
@@ -22,8 +22,8 @@
22
22
  "types": "lib/index.d.ts",
23
23
  "scripts": {},
24
24
  "dependencies": {
25
- "@temporalio/common": "1.9.3",
26
- "@temporalio/proto": "1.9.3"
25
+ "@temporalio/common": "1.10.1",
26
+ "@temporalio/proto": "1.10.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "source-map": "^0.7.4"
@@ -35,5 +35,5 @@
35
35
  "src",
36
36
  "lib"
37
37
  ],
38
- "gitHead": "e7e46639c1ba23b86f367a051fb54d736c5f21ce"
38
+ "gitHead": "a39419f4f9398bd69cc313700af75aea268f80b1"
39
39
  }
package/src/logs.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { composeInterceptors } from '@temporalio/common/lib/interceptors';
2
+ import { SdkComponent } from '@temporalio/common';
2
3
  import { untrackPromise } from './stack-helpers';
3
4
  import { type Sink, type Sinks, proxySinks } from './sinks';
4
5
  import { isCancellation } from './errors';
@@ -50,6 +51,13 @@ const LogTimestamp = Symbol.for('log_timestamp');
50
51
  * This logger is replay-aware and will omit log messages on workflow replay. Messages emitted by this logger are
51
52
  * funnelled through a sink that forwards them to the logger registered on {@link Runtime.logger}.
52
53
  *
54
+ * Attributes from the current Workflow Execution context are automatically included as metadata on every log
55
+ * entries. An extra `sdkComponent` metadata attribute is also added, with value `workflow`; this can be used for
56
+ * fine-grained filtering of log entries further downstream.
57
+ *
58
+ * To customize log attributes, register a {@link WorkflowOutboundCallsInterceptor} that intercepts the
59
+ * `getLogAttributes()` method.
60
+ *
53
61
  * Notice that since sinks are used to power this logger, any log attributes must be transferable via the
54
62
  * {@link https://nodejs.org/api/worker_threads.html#worker_threads_port_postmessage_value_transferlist | postMessage}
55
63
  * API.
@@ -67,6 +75,7 @@ export const log: WorkflowLogger = Object.fromEntries(
67
75
  return loggerSink[level](message, {
68
76
  // Inject the call time in nanosecond resolution as expected by the worker logger.
69
77
  [LogTimestamp]: activator.getTimeOfDay(),
78
+ sdkComponent: SdkComponent.workflow,
70
79
  ...getLogAttributes(workflowLogAttributes(activator.info)),
71
80
  ...attrs,
72
81
  });
@@ -76,10 +85,10 @@ export const log: WorkflowLogger = Object.fromEntries(
76
85
  ) as any;
77
86
 
78
87
  export function executeWithLifecycleLogging(fn: () => Promise<unknown>): Promise<unknown> {
79
- log.debug('Workflow started');
88
+ log.debug('Workflow started', { sdkComponent: SdkComponent.worker });
80
89
  const p = fn().then(
81
90
  (res) => {
82
- log.debug('Workflow completed');
91
+ log.debug('Workflow completed', { sdkComponent: SdkComponent.worker });
83
92
  return res;
84
93
  },
85
94
  (error) => {
@@ -87,14 +96,14 @@ export function executeWithLifecycleLogging(fn: () => Promise<unknown>): Promise
87
96
  // e.g. by jest or when multiple versions are installed.
88
97
  if (typeof error === 'object' && error != null) {
89
98
  if (isCancellation(error)) {
90
- log.debug('Workflow completed as cancelled');
99
+ log.debug('Workflow completed as cancelled', { sdkComponent: SdkComponent.worker });
91
100
  throw error;
92
101
  } else if (error instanceof ContinueAsNew) {
93
- log.debug('Workflow continued as new');
102
+ log.debug('Workflow continued as new', { sdkComponent: SdkComponent.worker });
94
103
  throw error;
95
104
  }
96
105
  }
97
- log.warn('Workflow failed', { error });
106
+ log.warn('Workflow failed', { error, sdkComponent: SdkComponent.worker });
98
107
  throw error;
99
108
  }
100
109
  );