@temporalio/interceptors-opentelemetry 1.14.0 → 1.14.2-canary-release-testing.0
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/client/index.js +11 -11
- package/lib/client/index.js.map +1 -1
- package/lib/worker/index.d.ts +1 -1
- package/lib/worker/index.js +2 -2
- package/lib/worker/index.js.map +1 -1
- package/lib/workflow/context-manager.d.ts +2 -2
- package/lib/workflow/context-manager.js +2 -8
- package/lib/workflow/context-manager.js.map +1 -1
- package/lib/workflow/definitions.d.ts +1 -1
- package/lib/workflow/index.d.ts +0 -2
- package/lib/workflow/index.js +17 -25
- package/lib/workflow/index.js.map +1 -1
- package/lib/workflow/runtime.js +2 -3
- package/lib/workflow/runtime.js.map +1 -1
- package/lib/workflow/span-exporter.d.ts +1 -1
- package/lib/workflow/span-exporter.js +6 -6
- package/lib/workflow/span-exporter.js.map +1 -1
- package/lib/workflow/workflow-imports-impl.d.ts +9 -0
- package/lib/workflow/workflow-imports-impl.js +20 -0
- package/lib/workflow/workflow-imports-impl.js.map +1 -0
- package/lib/workflow/workflow-imports.d.ts +19 -0
- package/lib/workflow/workflow-imports.js +26 -0
- package/lib/workflow/workflow-imports.js.map +1 -0
- package/package.json +10 -11
- package/src/client/index.ts +1 -1
- package/src/worker/index.ts +6 -1
- package/src/workflow/context-manager.ts +6 -13
- package/src/workflow/definitions.ts +1 -1
- package/src/workflow/index.ts +14 -25
- package/src/workflow/runtime.ts +2 -4
- package/src/workflow/span-exporter.ts +6 -7
- package/src/workflow/workflow-imports-impl.ts +9 -0
- package/src/workflow/workflow-imports.ts +42 -0
- package/lib/workflow/workflow-module-loader.d.ts +0 -28
- package/lib/workflow/workflow-module-loader.js +0 -56
- package/lib/workflow/workflow-module-loader.js.map +0 -1
- package/src/workflow/workflow-module-loader.ts +0 -64
package/lib/client/index.js
CHANGED
|
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.OpenTelemetryWorkflowClientInterceptor = void 0;
|
|
27
27
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
28
28
|
const instrumentation_1 = require("../instrumentation");
|
|
29
|
-
const
|
|
29
|
+
const definitions_1 = require("../workflow/definitions");
|
|
30
30
|
/**
|
|
31
31
|
* Intercepts calls to start a Workflow.
|
|
32
32
|
*
|
|
@@ -40,7 +40,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
40
40
|
async start(input, next) {
|
|
41
41
|
return await (0, instrumentation_1.instrument)({
|
|
42
42
|
tracer: this.tracer,
|
|
43
|
-
spanName: `${
|
|
43
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
44
44
|
fn: async (span) => {
|
|
45
45
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
46
46
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
@@ -53,7 +53,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
53
53
|
async signal(input, next) {
|
|
54
54
|
return await (0, instrumentation_1.instrument)({
|
|
55
55
|
tracer: this.tracer,
|
|
56
|
-
spanName: `${
|
|
56
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL}${definitions_1.SPAN_DELIMITER}${input.signalName}`,
|
|
57
57
|
fn: async (span) => {
|
|
58
58
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
59
59
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
@@ -64,7 +64,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
64
64
|
async startWithDetails(input, next) {
|
|
65
65
|
return await (0, instrumentation_1.instrument)({
|
|
66
66
|
tracer: this.tracer,
|
|
67
|
-
spanName: `${
|
|
67
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
68
68
|
fn: async (span) => {
|
|
69
69
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
70
70
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
@@ -77,7 +77,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
77
77
|
async startUpdate(input, next) {
|
|
78
78
|
return await (0, instrumentation_1.instrument)({
|
|
79
79
|
tracer: this.tracer,
|
|
80
|
-
spanName: `${
|
|
80
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_START_UPDATE}${definitions_1.SPAN_DELIMITER}${input.updateName}`,
|
|
81
81
|
fn: async (span) => {
|
|
82
82
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
83
83
|
if (input.options.updateId) {
|
|
@@ -93,7 +93,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
93
93
|
async startUpdateWithStart(input, next) {
|
|
94
94
|
return await (0, instrumentation_1.instrument)({
|
|
95
95
|
tracer: this.tracer,
|
|
96
|
-
spanName: `${
|
|
96
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_UPDATE_WITH_START}${definitions_1.SPAN_DELIMITER}${input.updateName}`,
|
|
97
97
|
fn: async (span) => {
|
|
98
98
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowStartOptions.workflowId);
|
|
99
99
|
if (input.updateOptions.updateId) {
|
|
@@ -112,7 +112,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
112
112
|
async signalWithStart(input, next) {
|
|
113
113
|
return await (0, instrumentation_1.instrument)({
|
|
114
114
|
tracer: this.tracer,
|
|
115
|
-
spanName: `${
|
|
115
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL_WITH_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
116
116
|
fn: async (span) => {
|
|
117
117
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
118
118
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
@@ -125,7 +125,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
125
125
|
async query(input, next) {
|
|
126
126
|
return await (0, instrumentation_1.instrument)({
|
|
127
127
|
tracer: this.tracer,
|
|
128
|
-
spanName: `${
|
|
128
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_QUERY}${definitions_1.SPAN_DELIMITER}${input.queryType}`,
|
|
129
129
|
fn: async (span) => {
|
|
130
130
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
131
131
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
@@ -139,7 +139,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
139
139
|
async terminate(input, next) {
|
|
140
140
|
return await (0, instrumentation_1.instrument)({
|
|
141
141
|
tracer: this.tracer,
|
|
142
|
-
spanName:
|
|
142
|
+
spanName: definitions_1.SpanName.WORKFLOW_TERMINATE,
|
|
143
143
|
fn: async (span) => {
|
|
144
144
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
145
145
|
if (input.workflowExecution.runId) {
|
|
@@ -155,7 +155,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
155
155
|
async cancel(input, next) {
|
|
156
156
|
return await (0, instrumentation_1.instrument)({
|
|
157
157
|
tracer: this.tracer,
|
|
158
|
-
spanName:
|
|
158
|
+
spanName: definitions_1.SpanName.WORKFLOW_CANCEL,
|
|
159
159
|
fn: async (span) => {
|
|
160
160
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
161
161
|
if (input.workflowExecution.runId) {
|
|
@@ -168,7 +168,7 @@ class OpenTelemetryWorkflowClientInterceptor {
|
|
|
168
168
|
async describe(input, next) {
|
|
169
169
|
return await (0, instrumentation_1.instrument)({
|
|
170
170
|
tracer: this.tracer,
|
|
171
|
-
spanName:
|
|
171
|
+
spanName: definitions_1.SpanName.WORKFLOW_DESCRIBE,
|
|
172
172
|
fn: async (span) => {
|
|
173
173
|
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
174
174
|
if (input.workflowExecution.runId) {
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAoB3C,wDAO4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAoB3C,wDAO4B;AAC5B,yDAAmE;AAMnE;;;;GAIG;AACH,MAAa,sCAAsC;IAC9B,MAAM,CAAc;IAEvC,YAAY,OAA4B;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,gCAAgC,CAAC,CAAC;IAC1F,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAyB,EAAE,IAA8C;QACnF,OAAO,MAAM,IAAA,4BAAU,EAAC;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,GAAG,sBAAQ,CAAC,cAAc,GAAG,4BAAc,GAAG,KAAK,CAAC,YAAY,EAAE;YAC5E,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACjB,MAAM,OAAO,GAAG,IAAA,oCAAkB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAClD,IAAI,CAAC,YAAY,CAAC,sCAAoB,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAClE,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC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AClC,IAAI,CAAC,YAAY,CAAC,iCAAe,EAAE,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;gBACpE,CAAC;gBACD,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAlLD,wFAkLC"}
|
package/lib/worker/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Resource } from '@opentelemetry/resources';
|
|
|
3
3
|
import type { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
4
4
|
import type { Context as ActivityContext } from '@temporalio/activity';
|
|
5
5
|
import type { Next, ActivityInboundCallsInterceptor, ActivityOutboundCallsInterceptor, InjectedSink, GetLogAttributesInput, GetMetricTagsInput, ActivityExecuteInput } from '@temporalio/worker';
|
|
6
|
-
import { type OpenTelemetryWorkflowExporter } from '../workflow';
|
|
6
|
+
import { type OpenTelemetryWorkflowExporter } from '../workflow/definitions';
|
|
7
7
|
export interface InterceptorOptions {
|
|
8
8
|
readonly tracer?: otel.Tracer;
|
|
9
9
|
}
|
package/lib/worker/index.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.OpenTelemetryActivityOutboundInterceptor = exports.OpenTelemetryActivity
|
|
|
27
27
|
exports.makeWorkflowExporter = makeWorkflowExporter;
|
|
28
28
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
29
29
|
const instrumentation_1 = require("../instrumentation");
|
|
30
|
-
const
|
|
30
|
+
const definitions_1 = require("../workflow/definitions");
|
|
31
31
|
/**
|
|
32
32
|
* Intercepts calls to start an Activity.
|
|
33
33
|
*
|
|
@@ -43,7 +43,7 @@ class OpenTelemetryActivityInboundInterceptor {
|
|
|
43
43
|
}
|
|
44
44
|
async execute(input, next) {
|
|
45
45
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
46
|
-
const spanName = `${
|
|
46
|
+
const spanName = `${definitions_1.SpanName.ACTIVITY_EXECUTE}${definitions_1.SPAN_DELIMITER}${this.ctx.info.activityType}`;
|
|
47
47
|
return await (0, instrumentation_1.instrument)({
|
|
48
48
|
tracer: this.tracer,
|
|
49
49
|
spanName,
|
package/lib/worker/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/worker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgHA,oDAiBC;AAjID,yDAA2C;AAa3C,wDAM4B;AAC5B,yDAKiC;AAMjC;;;;;GAKG;AACH,MAAa,uCAAuC;IAI7B;IAHF,MAAM,CAAc;IAEvC,YACqB,GAAoB,EACvC,OAA4B;QADT,QAAG,GAAH,GAAG,CAAiB;QAGvC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;IAC5F,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAA2B,EAAE,IAAsD;QAC/F,MAAM,OAAO,GAAG,IAAA,2CAAyB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzD,MAAM,QAAQ,GAAG,GAAG,sBAAQ,CAAC,gBAAgB,GAAG,4BAAc,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC9F,OAAO,MAAM,IAAA,4BAAU,EAAC;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ;YACR,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE;gBACX,IAAI,CAAC,YAAY,CAAC,sCAAoB,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;gBACpF,IAAI,CAAC,YAAY,CAAC,iCAAe,EAAE,IAAI,CAAC,GAAG,CAAC,I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OAAO,IAAI,CAAC;gBACV,QAAQ,EAAE,WAAW,CAAC,OAAO;gBAC7B,OAAO,EAAE,WAAW,CAAC,MAAM;gBAC3B,WAAW,EAAE,IAAI,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE;gBACtD,GAAG,KAAK;aACT,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAtCD,4FAsCC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,QAAsB,EACtB,QAAkB;IAElB,OAAO;QACL,MAAM,EAAE;YACN,EAAE,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;gBACrB,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;oBACxC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;oBAC3C,qFAAqF;oBACrF,OAAO,mBAAmB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;gBACnD,CAAC,CAAC,CAAC;gBACH,0CAA0C;gBAC1C,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC1C,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,YAA8B,EAAE,QAAkB;IAC7E,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,YAAY,CAAC;IAC9C,OAAO;QACL,WAAW;YACT,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,QAAQ;QACR,GAAG,IAAI;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type AsyncLocalStorage } from 'async_hooks';
|
|
1
2
|
import * as otel from '@opentelemetry/api';
|
|
2
3
|
export declare class ContextManager implements otel.ContextManager {
|
|
3
|
-
protected storage:
|
|
4
|
-
constructor();
|
|
4
|
+
protected storage: AsyncLocalStorage<otel.Context>;
|
|
5
5
|
active(): otel.Context;
|
|
6
6
|
bind<T>(context: otel.Context, target: T): T;
|
|
7
7
|
enable(): this;
|
|
@@ -25,15 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.ContextManager = void 0;
|
|
27
27
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
28
|
-
const workflow_module_loader_1 = require("./workflow-module-loader");
|
|
29
|
-
const AsyncLocalStorage = (0, workflow_module_loader_1.getWorkflowModuleIfAvailable)()?.AsyncLocalStorage;
|
|
30
28
|
class ContextManager {
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
storage = AsyncLocalStorage ? new AsyncLocalStorage() : undefined;
|
|
34
|
-
constructor() {
|
|
35
|
-
(0, workflow_module_loader_1.ensureWorkflowModuleLoaded)();
|
|
36
|
-
}
|
|
29
|
+
// The workflow sandbox provides AsyncLocalStorage through globalThis.
|
|
30
|
+
storage = new globalThis.AsyncLocalStorage();
|
|
37
31
|
active() {
|
|
38
32
|
return this.storage.getStore() || otel.ROOT_CONTEXT;
|
|
39
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../src/workflow/context-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"context-manager.js","sourceRoot":"","sources":["../../src/workflow/context-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAE3C,MAAa,cAAc;IACzB,sEAAsE;IAC5D,OAAO,GAAoC,IAAK,UAAkB,CAAC,iBAAiB,EAAE,CAAC;IAEjG,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACtD,CAAC;IAED,IAAI,CAAI,OAAqB,EAAE,MAAS;QACtC,IAAI,OAAO,MAAM,KAAK,UAAU,EAAE,CAAC;YACjC,MAAM,IAAI,SAAS,CAAC,2CAA2C,OAAO,MAAM,EAAE,CAAC,CAAC;QAClF,CAAC;QAED,8JAA8J;QAC9J,MAAM,cAAc,GAAG,CAAC,GAAG,IAAe,EAAE,EAAE;YAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5D,CAAC,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,QAAQ,EAAE;YAC9C,UAAU,EAAE,KAAK;YACjB,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,MAAM,CAAC,MAAM;SACrB,CAAC,CAAC;QACH;;;WAGG;QACH,8DAA8D;QAC9D,OAAO,cAAqB,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CACF,OAAqB,EACrB,EAAK,EACL,OAA8B,EAC9B,GAAG,IAAO;QAEV,MAAM,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAChD,CAAC;CACF;AAjDD,wCAiDC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as otel from '@opentelemetry/api';
|
|
2
2
|
import * as tracing from '@opentelemetry/sdk-trace-base';
|
|
3
3
|
import { InstrumentationLibrary } from '@opentelemetry/core';
|
|
4
|
-
import { Sink, Sinks } from '@temporalio/workflow';
|
|
4
|
+
import type { Sink, Sinks } from '@temporalio/workflow';
|
|
5
5
|
/**
|
|
6
6
|
* Serializable version of the opentelemetry Span for cross isolate copying
|
|
7
7
|
*/
|
package/lib/workflow/index.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export * from './definitions';
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInterceptor {
|
|
14
14
|
protected readonly tracer: otel.Tracer;
|
|
15
|
-
constructor();
|
|
16
15
|
execute(input: WorkflowExecuteInput, next: Next<WorkflowInboundCallsInterceptor, 'execute'>): Promise<unknown>;
|
|
17
16
|
handleSignal(input: SignalInput, next: Next<WorkflowInboundCallsInterceptor, 'handleSignal'>): Promise<void>;
|
|
18
17
|
handleUpdate(input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'handleUpdate'>): Promise<unknown>;
|
|
@@ -28,7 +27,6 @@ export declare class OpenTelemetryInboundInterceptor implements WorkflowInboundC
|
|
|
28
27
|
*/
|
|
29
28
|
export declare class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsInterceptor {
|
|
30
29
|
protected readonly tracer: otel.Tracer;
|
|
31
|
-
constructor();
|
|
32
30
|
scheduleActivity(input: ActivityInput, next: Next<WorkflowOutboundCallsInterceptor, 'scheduleActivity'>): Promise<unknown>;
|
|
33
31
|
scheduleLocalActivity(input: LocalActivityInput, next: Next<WorkflowOutboundCallsInterceptor, 'scheduleLocalActivity'>): Promise<unknown>;
|
|
34
32
|
startNexusOperation(input: StartNexusOperationInput, next: Next<WorkflowOutboundCallsInterceptor, 'startNexusOperation'>): Promise<StartNexusOperationOutput>;
|
package/lib/workflow/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const instrumentation_1 = require("../instrumentation");
|
|
|
36
36
|
const context_manager_1 = require("./context-manager");
|
|
37
37
|
const definitions_1 = require("./definitions");
|
|
38
38
|
const span_exporter_1 = require("./span-exporter");
|
|
39
|
-
const
|
|
39
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
40
40
|
__exportStar(require("./definitions"), exports);
|
|
41
41
|
let tracer = undefined;
|
|
42
42
|
let contextManager = undefined;
|
|
@@ -62,28 +62,24 @@ function getTracer() {
|
|
|
62
62
|
*/
|
|
63
63
|
class OpenTelemetryInboundInterceptor {
|
|
64
64
|
tracer = getTracer();
|
|
65
|
-
constructor() {
|
|
66
|
-
(0, workflow_module_loader_1.ensureWorkflowModuleLoaded)();
|
|
67
|
-
}
|
|
68
65
|
async execute(input, next) {
|
|
69
|
-
const { workflowInfo, ContinueAsNew } = (0, workflow_module_loader_1.getWorkflowModule)();
|
|
70
66
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
71
|
-
if (!(0,
|
|
67
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
72
68
|
await Promise.resolve();
|
|
73
69
|
return await (0, instrumentation_1.instrument)({
|
|
74
70
|
tracer: this.tracer,
|
|
75
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_EXECUTE}${definitions_1.SPAN_DELIMITER}${workflowInfo().workflowType}`,
|
|
71
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_EXECUTE}${definitions_1.SPAN_DELIMITER}${(0, workflow_imports_1.workflowInfo)().workflowType}`,
|
|
76
72
|
fn: () => next(input),
|
|
77
73
|
context,
|
|
78
|
-
acceptableErrors: (err) => err instanceof ContinueAsNew,
|
|
74
|
+
acceptableErrors: (err) => err instanceof workflow_imports_1.ContinueAsNew,
|
|
79
75
|
});
|
|
80
76
|
}
|
|
81
77
|
async handleSignal(input, next) {
|
|
82
78
|
// Tracing of inbound signals was added in v1.11.5.
|
|
83
|
-
if (!(0,
|
|
79
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsTracesInboundSignals))
|
|
84
80
|
return next(input);
|
|
85
81
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
86
|
-
if (!(0,
|
|
82
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
87
83
|
await Promise.resolve();
|
|
88
84
|
return await (0, instrumentation_1.instrument)({
|
|
89
85
|
tracer: this.tracer,
|
|
@@ -93,7 +89,7 @@ class OpenTelemetryInboundInterceptor {
|
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
91
|
async handleUpdate(input, next) {
|
|
96
|
-
if (!(0,
|
|
92
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods))
|
|
97
93
|
return next(input);
|
|
98
94
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
99
95
|
return await (0, instrumentation_1.instrument)({
|
|
@@ -107,7 +103,7 @@ class OpenTelemetryInboundInterceptor {
|
|
|
107
103
|
});
|
|
108
104
|
}
|
|
109
105
|
validateUpdate(input, next) {
|
|
110
|
-
if (!(0,
|
|
106
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods))
|
|
111
107
|
return next(input);
|
|
112
108
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
113
109
|
(0, instrumentation_1.instrumentSync)({
|
|
@@ -121,7 +117,7 @@ class OpenTelemetryInboundInterceptor {
|
|
|
121
117
|
});
|
|
122
118
|
}
|
|
123
119
|
async handleQuery(input, next) {
|
|
124
|
-
if (!(0,
|
|
120
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods))
|
|
125
121
|
return next(input);
|
|
126
122
|
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
127
123
|
return await (0, instrumentation_1.instrument)({
|
|
@@ -142,16 +138,13 @@ exports.OpenTelemetryInboundInterceptor = OpenTelemetryInboundInterceptor;
|
|
|
142
138
|
*/
|
|
143
139
|
class OpenTelemetryOutboundInterceptor {
|
|
144
140
|
tracer = getTracer();
|
|
145
|
-
constructor() {
|
|
146
|
-
(0, workflow_module_loader_1.ensureWorkflowModuleLoaded)();
|
|
147
|
-
}
|
|
148
141
|
async scheduleActivity(input, next) {
|
|
149
142
|
return await (0, instrumentation_1.instrument)({
|
|
150
143
|
tracer: this.tracer,
|
|
151
144
|
spanName: `${definitions_1.SpanName.ACTIVITY_START}${definitions_1.SPAN_DELIMITER}${input.activityType}`,
|
|
152
145
|
fn: async () => {
|
|
153
146
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
154
|
-
if (!(0,
|
|
147
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
155
148
|
await Promise.resolve();
|
|
156
149
|
return next({
|
|
157
150
|
...input,
|
|
@@ -162,14 +155,14 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
162
155
|
}
|
|
163
156
|
async scheduleLocalActivity(input, next) {
|
|
164
157
|
// Tracing of local activities was added in v1.11.6.
|
|
165
|
-
if (!(0,
|
|
158
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsTracesLocalActivities))
|
|
166
159
|
return next(input);
|
|
167
160
|
return await (0, instrumentation_1.instrument)({
|
|
168
161
|
tracer: this.tracer,
|
|
169
162
|
spanName: `${definitions_1.SpanName.ACTIVITY_START}${definitions_1.SPAN_DELIMITER}${input.activityType}`,
|
|
170
163
|
fn: async () => {
|
|
171
164
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
172
|
-
if (!(0,
|
|
165
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
173
166
|
await Promise.resolve();
|
|
174
167
|
return next({
|
|
175
168
|
...input,
|
|
@@ -179,7 +172,7 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
179
172
|
});
|
|
180
173
|
}
|
|
181
174
|
async startNexusOperation(input, next) {
|
|
182
|
-
if (!(0,
|
|
175
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods))
|
|
183
176
|
return next(input);
|
|
184
177
|
return await (0, instrumentation_1.instrument)({
|
|
185
178
|
tracer: this.tracer,
|
|
@@ -198,7 +191,7 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
198
191
|
spanName: `${definitions_1.SpanName.CHILD_WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
199
192
|
fn: async () => {
|
|
200
193
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
201
|
-
if (!(0,
|
|
194
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
202
195
|
await Promise.resolve();
|
|
203
196
|
return next({
|
|
204
197
|
...input,
|
|
@@ -208,20 +201,19 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
208
201
|
});
|
|
209
202
|
}
|
|
210
203
|
async continueAsNew(input, next) {
|
|
211
|
-
const { ContinueAsNew } = (0, workflow_module_loader_1.getWorkflowModule)();
|
|
212
204
|
return await (0, instrumentation_1.instrument)({
|
|
213
205
|
tracer: this.tracer,
|
|
214
206
|
spanName: `${definitions_1.SpanName.CONTINUE_AS_NEW}${definitions_1.SPAN_DELIMITER}${input.options.workflowType}`,
|
|
215
207
|
fn: async () => {
|
|
216
208
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
217
|
-
if (!(0,
|
|
209
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
218
210
|
await Promise.resolve();
|
|
219
211
|
return next({
|
|
220
212
|
...input,
|
|
221
213
|
headers,
|
|
222
214
|
});
|
|
223
215
|
},
|
|
224
|
-
acceptableErrors: (err) => err instanceof ContinueAsNew,
|
|
216
|
+
acceptableErrors: (err) => err instanceof workflow_imports_1.ContinueAsNew,
|
|
225
217
|
});
|
|
226
218
|
}
|
|
227
219
|
async signalWorkflow(input, next) {
|
|
@@ -230,7 +222,7 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
230
222
|
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL}${definitions_1.SPAN_DELIMITER}${input.signalName}`,
|
|
231
223
|
fn: async () => {
|
|
232
224
|
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
233
|
-
if (!(0,
|
|
225
|
+
if (!(0, workflow_imports_1.getActivator)().hasFlag(workflow_imports_1.SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields))
|
|
234
226
|
await Promise.resolve();
|
|
235
227
|
return next({
|
|
236
228
|
...input,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,uDAAuD;AACvD,qBAAmB,CAAC,uDAAuD;AAC3E,yDAA2C;AAC3C,uEAAyD;AAqBzD,wDAS4B;AAC5B,uDAAmD;AACnD,+CAAyD;AACzD,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiC;AACjC,uDAAuD;AACvD,qBAAmB,CAAC,uDAAuD;AAC3E,yDAA2C;AAC3C,uEAAyD;AAqBzD,wDAS4B;AAC5B,uDAAmD;AACnD,+CAAyD;AACzD,mDAA+C;AAC/C,yD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QAAQ,CAAC,EAAE,CAAC,EAAE;gBACtD,GAAG,KAAK;aACT,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AA3JD,4EA2JC;AAED,MAAa,iCAAiC;IAC5C,KAAK,CAAC,OAAO,CAAC,KAAmB,EAAE,IAAmD;QACpF,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,CAAC;IACd,CAAC;CACF;AAPD,8EAOC"}
|
package/lib/workflow/runtime.js
CHANGED
|
@@ -4,9 +4,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Sets global variables required for importing opentelemetry in isolate
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
if (inWorkflowContext?.()) {
|
|
7
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
8
|
+
if ((0, workflow_imports_1.inWorkflowContext)()) {
|
|
10
9
|
// Required by opentelemetry (pretend to be a browser)
|
|
11
10
|
Object.assign(globalThis, {
|
|
12
11
|
performance: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/workflow/runtime.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/workflow/runtime.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,yDAAuD;AAEvD,IAAI,IAAA,oCAAiB,GAAE,EAAE,CAAC;IACxB,sDAAsD;IACtD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,WAAW,EAAE;YACX,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,GAAG;gBACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;YACtC,CAAC;SACF;QACD,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,7 +2,7 @@ import * as tracing from '@opentelemetry/sdk-trace-base';
|
|
|
2
2
|
import { ExportResult } from '@opentelemetry/core';
|
|
3
3
|
import { SerializableSpan } from './definitions';
|
|
4
4
|
export declare class SpanExporter implements tracing.SpanExporter {
|
|
5
|
-
|
|
5
|
+
private exporter?;
|
|
6
6
|
export(spans: tracing.ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
7
7
|
shutdown(): Promise<void>;
|
|
8
8
|
makeSerializable(span: tracing.ReadableSpan): SerializableSpan;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SpanExporter = void 0;
|
|
4
4
|
const core_1 = require("@opentelemetry/core");
|
|
5
|
-
const
|
|
6
|
-
const exporter = (0, workflow_module_loader_1.getWorkflowModuleIfAvailable)()?.proxySinks()?.exporter;
|
|
5
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
7
6
|
class SpanExporter {
|
|
8
|
-
|
|
9
|
-
(0, workflow_module_loader_1.ensureWorkflowModuleLoaded)();
|
|
10
|
-
}
|
|
7
|
+
exporter;
|
|
11
8
|
export(spans, resultCallback) {
|
|
12
|
-
|
|
9
|
+
if (!this.exporter) {
|
|
10
|
+
this.exporter = (0, workflow_imports_1.proxySinks)().exporter;
|
|
11
|
+
}
|
|
12
|
+
this.exporter.export(spans.map((span) => this.makeSerializable(span)));
|
|
13
13
|
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
14
14
|
}
|
|
15
15
|
async shutdown() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-exporter.js","sourceRoot":"","sources":["../../src/workflow/span-exporter.ts"],"names":[],"mappings":";;;AACA,8CAAqE;AAErE,
|
|
1
|
+
{"version":3,"file":"span-exporter.js","sourceRoot":"","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ACJ,CAAC;CACF;AAnCD,oCAmCC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real workflow imports for otel interceptors.
|
|
3
|
+
* This replaces the stub via webpack alias when bundled.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { inWorkflowContext, proxySinks, workflowInfo, AsyncLocalStorage, ContinueAsNew } from '@temporalio/workflow';
|
|
8
|
+
export { SdkFlags } from '@temporalio/workflow/lib/flags';
|
|
9
|
+
export { getActivator } from '@temporalio/workflow/lib/global-attributes';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActivator = exports.SdkFlags = exports.ContinueAsNew = exports.AsyncLocalStorage = exports.workflowInfo = exports.proxySinks = exports.inWorkflowContext = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Real workflow imports for otel interceptors.
|
|
6
|
+
* This replaces the stub via webpack alias when bundled.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
var workflow_1 = require("@temporalio/workflow");
|
|
11
|
+
Object.defineProperty(exports, "inWorkflowContext", { enumerable: true, get: function () { return workflow_1.inWorkflowContext; } });
|
|
12
|
+
Object.defineProperty(exports, "proxySinks", { enumerable: true, get: function () { return workflow_1.proxySinks; } });
|
|
13
|
+
Object.defineProperty(exports, "workflowInfo", { enumerable: true, get: function () { return workflow_1.workflowInfo; } });
|
|
14
|
+
Object.defineProperty(exports, "AsyncLocalStorage", { enumerable: true, get: function () { return workflow_1.AsyncLocalStorage; } });
|
|
15
|
+
Object.defineProperty(exports, "ContinueAsNew", { enumerable: true, get: function () { return workflow_1.ContinueAsNew; } });
|
|
16
|
+
var flags_1 = require("@temporalio/workflow/lib/flags");
|
|
17
|
+
Object.defineProperty(exports, "SdkFlags", { enumerable: true, get: function () { return flags_1.SdkFlags; } });
|
|
18
|
+
var global_attributes_1 = require("@temporalio/workflow/lib/global-attributes");
|
|
19
|
+
Object.defineProperty(exports, "getActivator", { enumerable: true, get: function () { return global_attributes_1.getActivator; } });
|
|
20
|
+
//# sourceMappingURL=workflow-imports-impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-imports-impl.js","sourceRoot":"","sources":["../../src/workflow/workflow-imports-impl.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,iDAAqH;AAA5G,6GAAA,iBAAiB,OAAA;AAAE,sGAAA,UAAU,OAAA;AAAE,wGAAA,YAAY,OAAA;AAAE,6GAAA,iBAAiB,OAAA;AAAE,yGAAA,aAAa,OAAA;AACtF,wDAA0D;AAAjD,iGAAA,QAAQ,OAAA;AACjB,gFAA0E;AAAjE,iHAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow imports stub module.
|
|
3
|
+
*
|
|
4
|
+
* This module provides stubs for workflow functionality needed by interceptors.
|
|
5
|
+
* When bundled by the workflow bundler, this is replaced with the real
|
|
6
|
+
* implementation via NormalModuleReplacementPlugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { inWorkflowContext as inWorkflowContextT, workflowInfo as workflowInfoT, proxySinks as proxySinksT, AsyncLocalStorage as AsyncLocalStorageT, ContinueAsNew as ContinueAsNewT } from '@temporalio/workflow';
|
|
11
|
+
import type { getActivator as getActivatorT } from '@temporalio/workflow/lib/global-attributes';
|
|
12
|
+
import type { SdkFlags as SdkFlagsT } from '@temporalio/workflow/lib/flags';
|
|
13
|
+
export declare const inWorkflowContext: typeof inWorkflowContextT;
|
|
14
|
+
export declare const workflowInfo: typeof workflowInfoT;
|
|
15
|
+
export declare const ContinueAsNew: typeof ContinueAsNewT;
|
|
16
|
+
export declare const AsyncLocalStorage: typeof AsyncLocalStorageT;
|
|
17
|
+
export declare const getActivator: typeof getActivatorT;
|
|
18
|
+
export declare const proxySinks: typeof proxySinksT;
|
|
19
|
+
export declare const SdkFlags: typeof SdkFlagsT;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SdkFlags = exports.proxySinks = exports.getActivator = exports.AsyncLocalStorage = exports.ContinueAsNew = exports.workflowInfo = exports.inWorkflowContext = void 0;
|
|
4
|
+
const common_1 = require("@temporalio/common");
|
|
5
|
+
// always returns false since if using this implementation, we are outside of workflow context
|
|
6
|
+
const inWorkflowContext = () => false;
|
|
7
|
+
exports.inWorkflowContext = inWorkflowContext;
|
|
8
|
+
// All of the following stubs will throw if used
|
|
9
|
+
const workflowInfo = () => {
|
|
10
|
+
throw new common_1.IllegalStateError('Workflow.workflowInfo(...) may only be used from a Workflow Execution.');
|
|
11
|
+
};
|
|
12
|
+
exports.workflowInfo = workflowInfo;
|
|
13
|
+
exports.ContinueAsNew = class ContinueAsNew {
|
|
14
|
+
};
|
|
15
|
+
exports.AsyncLocalStorage = class AsyncLocalStorage {
|
|
16
|
+
};
|
|
17
|
+
const getActivator = () => {
|
|
18
|
+
throw new common_1.IllegalStateError('Workflow uninitialized');
|
|
19
|
+
};
|
|
20
|
+
exports.getActivator = getActivator;
|
|
21
|
+
const proxySinks = () => {
|
|
22
|
+
throw new common_1.IllegalStateError('Proxied sinks functions may only be used from a Workflow Execution.');
|
|
23
|
+
};
|
|
24
|
+
exports.proxySinks = proxySinks;
|
|
25
|
+
exports.SdkFlags = {};
|
|
26
|
+
//# sourceMappingURL=workflow-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-imports.js","sourceRoot":"","sources":["../../src/workflow/workflow-imports.ts"],"names":[],"mappings":";;;AAmBA,+CAAuD;AAEvD,8FAA8F;AACvF,MAAM,iBAAiB,GAA8B,GAAG,EAAE,CAAC,KAAK,CAAC;AAA3D,QAAA,iBAAiB,qBAA0C;AAExE,gDAAgD;AACzC,MAAM,YAAY,GAAyB,GAAG,EAAE;IACrD,MAAM,IAAI,0BAAiB,CAAC,wEAAwE,CAAC,CAAC;AACxG,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEW,QAAA,aAAa,GAAG,MAAM,aAAa;CAAuC,CAAC;AAE3E,QAAA,iBAAiB,GAAG,MAAM,iBAAiB;CAA2C,CAAC;AAE7F,MAAM,YAAY,GAAyB,GAAG,EAAE;IACrD,MAAM,IAAI,0BAAiB,CAAC,wBAAwB,CAAC,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,YAAY,gBAEvB;AAEK,MAAM,UAAU,GAAuB,GAAG,EAAE;IACjD,MAAM,IAAI,0BAAiB,CAAC,qEAAqE,CAAC,CAAC;AACrG,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEW,QAAA,QAAQ,GAAqB,EAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/interceptors-opentelemetry",
|
|
3
|
-
"version": "1.14.0",
|
|
3
|
+
"version": "1.14.2-canary-release-testing.0",
|
|
4
4
|
"description": "Temporal.io SDK interceptors bundle for tracing with opentelemetry",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
|
-
"scripts": {},
|
|
8
7
|
"keywords": [
|
|
9
8
|
"temporal",
|
|
10
9
|
"workflow",
|
|
@@ -20,15 +19,15 @@
|
|
|
20
19
|
"@opentelemetry/sdk-trace-base": "^1.25.1"
|
|
21
20
|
},
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@temporalio/activity": "1.14.0",
|
|
24
|
-
"@temporalio/
|
|
25
|
-
"@temporalio/
|
|
26
|
-
"@temporalio/
|
|
27
|
-
"@temporalio/
|
|
22
|
+
"@temporalio/activity": "1.14.2-canary-release-testing.0",
|
|
23
|
+
"@temporalio/common": "1.14.2-canary-release-testing.0",
|
|
24
|
+
"@temporalio/workflow": "1.14.2-canary-release-testing.0",
|
|
25
|
+
"@temporalio/client": "1.14.2-canary-release-testing.0",
|
|
26
|
+
"@temporalio/worker": "1.14.2-canary-release-testing.0"
|
|
28
27
|
},
|
|
29
28
|
"peerDependencies": {
|
|
30
|
-
"@temporalio/common": "1.14.0",
|
|
31
|
-
"@temporalio/workflow": "1.14.0"
|
|
29
|
+
"@temporalio/common": "1.14.2-canary-release-testing.0",
|
|
30
|
+
"@temporalio/workflow": "1.14.2-canary-release-testing.0"
|
|
32
31
|
},
|
|
33
32
|
"peerDependenciesMeta": {
|
|
34
33
|
"@temporalio/workflow": {
|
|
@@ -54,5 +53,5 @@
|
|
|
54
53
|
"src",
|
|
55
54
|
"lib"
|
|
56
55
|
],
|
|
57
|
-
"
|
|
58
|
-
}
|
|
56
|
+
"scripts": {}
|
|
57
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
UPDATE_ID_ATTR_KEY,
|
|
27
27
|
TERMINATE_REASON_ATTR_KEY,
|
|
28
28
|
} from '../instrumentation';
|
|
29
|
-
import { SpanName, SPAN_DELIMITER } from '../workflow';
|
|
29
|
+
import { SpanName, SPAN_DELIMITER } from '../workflow/definitions';
|
|
30
30
|
|
|
31
31
|
export interface InterceptorOptions {
|
|
32
32
|
readonly tracer?: otel.Tracer;
|
package/src/worker/index.ts
CHANGED
|
@@ -18,7 +18,12 @@ import {
|
|
|
18
18
|
RUN_ID_ATTR_KEY,
|
|
19
19
|
ACTIVITY_ID_ATTR_KEY,
|
|
20
20
|
} from '../instrumentation';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
type OpenTelemetryWorkflowExporter,
|
|
23
|
+
type SerializableSpan,
|
|
24
|
+
SpanName,
|
|
25
|
+
SPAN_DELIMITER,
|
|
26
|
+
} from '../workflow/definitions';
|
|
22
27
|
|
|
23
28
|
export interface InterceptorOptions {
|
|
24
29
|
readonly tracer?: otel.Tracer;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
+
import { type AsyncLocalStorage } from 'async_hooks';
|
|
1
2
|
import * as otel from '@opentelemetry/api';
|
|
2
|
-
import { ensureWorkflowModuleLoaded, getWorkflowModuleIfAvailable } from './workflow-module-loader';
|
|
3
|
-
|
|
4
|
-
const AsyncLocalStorage = getWorkflowModuleIfAvailable()?.AsyncLocalStorage;
|
|
5
3
|
|
|
6
4
|
export class ContextManager implements otel.ContextManager {
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
protected storage = AsyncLocalStorage ? new AsyncLocalStorage<otel.Context>() : undefined;
|
|
10
|
-
|
|
11
|
-
public constructor() {
|
|
12
|
-
ensureWorkflowModuleLoaded();
|
|
13
|
-
}
|
|
5
|
+
// The workflow sandbox provides AsyncLocalStorage through globalThis.
|
|
6
|
+
protected storage: AsyncLocalStorage<otel.Context> = new (globalThis as any).AsyncLocalStorage();
|
|
14
7
|
|
|
15
8
|
active(): otel.Context {
|
|
16
|
-
return this.storage
|
|
9
|
+
return this.storage.getStore() || otel.ROOT_CONTEXT;
|
|
17
10
|
}
|
|
18
11
|
|
|
19
12
|
bind<T>(context: otel.Context, target: T): T {
|
|
@@ -44,7 +37,7 @@ export class ContextManager implements otel.ContextManager {
|
|
|
44
37
|
}
|
|
45
38
|
|
|
46
39
|
disable(): this {
|
|
47
|
-
this.storage
|
|
40
|
+
this.storage.disable();
|
|
48
41
|
return this;
|
|
49
42
|
}
|
|
50
43
|
|
|
@@ -55,6 +48,6 @@ export class ContextManager implements otel.ContextManager {
|
|
|
55
48
|
...args: A
|
|
56
49
|
): ReturnType<F> {
|
|
57
50
|
const cb = thisArg == null ? fn : fn.bind(thisArg);
|
|
58
|
-
return this.storage
|
|
51
|
+
return this.storage.run(context, cb, ...args);
|
|
59
52
|
}
|
|
60
53
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as otel from '@opentelemetry/api';
|
|
2
2
|
import * as tracing from '@opentelemetry/sdk-trace-base';
|
|
3
3
|
import { InstrumentationLibrary } from '@opentelemetry/core'; // eslint-disable deprecation/deprecation
|
|
4
|
-
import { Sink, Sinks } from '@temporalio/workflow';
|
|
4
|
+
import type { Sink, Sinks } from '@temporalio/workflow';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Serializable version of the opentelemetry Span for cross isolate copying
|
package/src/workflow/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
import { ContextManager } from './context-manager';
|
|
37
37
|
import { SpanName, SPAN_DELIMITER } from './definitions';
|
|
38
38
|
import { SpanExporter } from './span-exporter';
|
|
39
|
-
import {
|
|
39
|
+
import { workflowInfo, ContinueAsNew, getActivator, SdkFlags } from './workflow-imports';
|
|
40
40
|
|
|
41
41
|
export * from './definitions';
|
|
42
42
|
|
|
@@ -67,18 +67,12 @@ function getTracer(): otel.Tracer {
|
|
|
67
67
|
export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInterceptor {
|
|
68
68
|
protected readonly tracer = getTracer();
|
|
69
69
|
|
|
70
|
-
public constructor() {
|
|
71
|
-
ensureWorkflowModuleLoaded();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
70
|
public async execute(
|
|
75
71
|
input: WorkflowExecuteInput,
|
|
76
72
|
next: Next<WorkflowInboundCallsInterceptor, 'execute'>
|
|
77
73
|
): Promise<unknown> {
|
|
78
|
-
const { workflowInfo, ContinueAsNew } = getWorkflowModule();
|
|
79
|
-
|
|
80
74
|
const context = extractContextFromHeaders(input.headers);
|
|
81
|
-
if (!
|
|
75
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
82
76
|
|
|
83
77
|
return await instrument({
|
|
84
78
|
tracer: this.tracer,
|
|
@@ -94,10 +88,10 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
|
|
|
94
88
|
next: Next<WorkflowInboundCallsInterceptor, 'handleSignal'>
|
|
95
89
|
): Promise<void> {
|
|
96
90
|
// Tracing of inbound signals was added in v1.11.5.
|
|
97
|
-
if (!
|
|
91
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsTracesInboundSignals)) return next(input);
|
|
98
92
|
|
|
99
93
|
const context = extractContextFromHeaders(input.headers);
|
|
100
|
-
if (!
|
|
94
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
101
95
|
|
|
102
96
|
return await instrument({
|
|
103
97
|
tracer: this.tracer,
|
|
@@ -111,7 +105,7 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
|
|
|
111
105
|
input: UpdateInput,
|
|
112
106
|
next: Next<WorkflowInboundCallsInterceptor, 'handleUpdate'>
|
|
113
107
|
): Promise<unknown> {
|
|
114
|
-
if (!
|
|
108
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods)) return next(input);
|
|
115
109
|
|
|
116
110
|
const context = extractContextFromHeaders(input.headers);
|
|
117
111
|
|
|
@@ -127,7 +121,7 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
|
|
|
127
121
|
}
|
|
128
122
|
|
|
129
123
|
public validateUpdate(input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'validateUpdate'>): void {
|
|
130
|
-
if (!
|
|
124
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods)) return next(input);
|
|
131
125
|
|
|
132
126
|
const context = extractContextFromHeaders(input.headers);
|
|
133
127
|
instrumentSync({
|
|
@@ -145,7 +139,7 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
|
|
|
145
139
|
input: QueryInput,
|
|
146
140
|
next: Next<WorkflowInboundCallsInterceptor, 'handleQuery'>
|
|
147
141
|
): Promise<unknown> {
|
|
148
|
-
if (!
|
|
142
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods)) return next(input);
|
|
149
143
|
|
|
150
144
|
const context = extractContextFromHeaders(input.headers);
|
|
151
145
|
|
|
@@ -168,10 +162,6 @@ export class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInte
|
|
|
168
162
|
export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsInterceptor {
|
|
169
163
|
protected readonly tracer = getTracer();
|
|
170
164
|
|
|
171
|
-
public constructor() {
|
|
172
|
-
ensureWorkflowModuleLoaded();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
165
|
public async scheduleActivity(
|
|
176
166
|
input: ActivityInput,
|
|
177
167
|
next: Next<WorkflowOutboundCallsInterceptor, 'scheduleActivity'>
|
|
@@ -181,7 +171,7 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
181
171
|
spanName: `${SpanName.ACTIVITY_START}${SPAN_DELIMITER}${input.activityType}`,
|
|
182
172
|
fn: async () => {
|
|
183
173
|
const headers = headersWithContext(input.headers);
|
|
184
|
-
if (!
|
|
174
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
185
175
|
|
|
186
176
|
return next({
|
|
187
177
|
...input,
|
|
@@ -196,14 +186,14 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
196
186
|
next: Next<WorkflowOutboundCallsInterceptor, 'scheduleLocalActivity'>
|
|
197
187
|
): Promise<unknown> {
|
|
198
188
|
// Tracing of local activities was added in v1.11.6.
|
|
199
|
-
if (!
|
|
189
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsTracesLocalActivities)) return next(input);
|
|
200
190
|
|
|
201
191
|
return await instrument({
|
|
202
192
|
tracer: this.tracer,
|
|
203
193
|
spanName: `${SpanName.ACTIVITY_START}${SPAN_DELIMITER}${input.activityType}`,
|
|
204
194
|
fn: async () => {
|
|
205
195
|
const headers = headersWithContext(input.headers);
|
|
206
|
-
if (!
|
|
196
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
207
197
|
|
|
208
198
|
return next({
|
|
209
199
|
...input,
|
|
@@ -217,7 +207,7 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
217
207
|
input: StartNexusOperationInput,
|
|
218
208
|
next: Next<WorkflowOutboundCallsInterceptor, 'startNexusOperation'>
|
|
219
209
|
): Promise<StartNexusOperationOutput> {
|
|
220
|
-
if (!
|
|
210
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceptorsInstrumentsAllMethods)) return next(input);
|
|
221
211
|
|
|
222
212
|
return await instrument({
|
|
223
213
|
tracer: this.tracer,
|
|
@@ -240,7 +230,7 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
240
230
|
spanName: `${SpanName.CHILD_WORKFLOW_START}${SPAN_DELIMITER}${input.workflowType}`,
|
|
241
231
|
fn: async () => {
|
|
242
232
|
const headers = headersWithContext(input.headers);
|
|
243
|
-
if (!
|
|
233
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
244
234
|
|
|
245
235
|
return next({
|
|
246
236
|
...input,
|
|
@@ -254,13 +244,12 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
254
244
|
input: ContinueAsNewInput,
|
|
255
245
|
next: Next<WorkflowOutboundCallsInterceptor, 'continueAsNew'>
|
|
256
246
|
): Promise<never> {
|
|
257
|
-
const { ContinueAsNew } = getWorkflowModule();
|
|
258
247
|
return await instrument({
|
|
259
248
|
tracer: this.tracer,
|
|
260
249
|
spanName: `${SpanName.CONTINUE_AS_NEW}${SPAN_DELIMITER}${input.options.workflowType}`,
|
|
261
250
|
fn: async () => {
|
|
262
251
|
const headers = headersWithContext(input.headers);
|
|
263
|
-
if (!
|
|
252
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
264
253
|
|
|
265
254
|
return next({
|
|
266
255
|
...input,
|
|
@@ -280,7 +269,7 @@ export class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsIn
|
|
|
280
269
|
spanName: `${SpanName.WORKFLOW_SIGNAL}${SPAN_DELIMITER}${input.signalName}`,
|
|
281
270
|
fn: async () => {
|
|
282
271
|
const headers = headersWithContext(input.headers);
|
|
283
|
-
if (!
|
|
272
|
+
if (!getActivator().hasFlag(SdkFlags.OpenTelemetryInterceporsAvoidsExtraYields)) await Promise.resolve();
|
|
284
273
|
|
|
285
274
|
return next({
|
|
286
275
|
...input,
|
package/src/workflow/runtime.ts
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Sets global variables required for importing opentelemetry in isolate
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { inWorkflowContext } from './workflow-imports';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (inWorkflowContext?.()) {
|
|
7
|
+
if (inWorkflowContext()) {
|
|
10
8
|
// Required by opentelemetry (pretend to be a browser)
|
|
11
9
|
Object.assign(globalThis, {
|
|
12
10
|
performance: {
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import * as tracing from '@opentelemetry/sdk-trace-base';
|
|
2
2
|
import { ExportResult, ExportResultCode } from '@opentelemetry/core';
|
|
3
3
|
import { OpenTelemetrySinks, SerializableSpan } from './definitions';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const exporter = getWorkflowModuleIfAvailable()?.proxySinks<OpenTelemetrySinks>()?.exporter;
|
|
4
|
+
import { proxySinks } from './workflow-imports';
|
|
7
5
|
|
|
8
6
|
export class SpanExporter implements tracing.SpanExporter {
|
|
9
|
-
|
|
10
|
-
ensureWorkflowModuleLoaded();
|
|
11
|
-
}
|
|
7
|
+
private exporter?: OpenTelemetrySinks['exporter'];
|
|
12
8
|
|
|
13
9
|
public export(spans: tracing.ReadableSpan[], resultCallback: (result: ExportResult) => void): void {
|
|
14
|
-
|
|
10
|
+
if (!this.exporter) {
|
|
11
|
+
this.exporter = proxySinks<OpenTelemetrySinks>().exporter;
|
|
12
|
+
}
|
|
13
|
+
this.exporter.export(spans.map((span) => this.makeSerializable(span)));
|
|
15
14
|
resultCallback({ code: ExportResultCode.SUCCESS });
|
|
16
15
|
}
|
|
17
16
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real workflow imports for otel interceptors.
|
|
3
|
+
* This replaces the stub via webpack alias when bundled.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
export { inWorkflowContext, proxySinks, workflowInfo, AsyncLocalStorage, ContinueAsNew } from '@temporalio/workflow';
|
|
8
|
+
export { SdkFlags } from '@temporalio/workflow/lib/flags';
|
|
9
|
+
export { getActivator } from '@temporalio/workflow/lib/global-attributes';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow imports stub module.
|
|
3
|
+
*
|
|
4
|
+
* This module provides stubs for workflow functionality needed by interceptors.
|
|
5
|
+
* When bundled by the workflow bundler, this is replaced with the real
|
|
6
|
+
* implementation via NormalModuleReplacementPlugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type {
|
|
11
|
+
inWorkflowContext as inWorkflowContextT,
|
|
12
|
+
workflowInfo as workflowInfoT,
|
|
13
|
+
proxySinks as proxySinksT,
|
|
14
|
+
AsyncLocalStorage as AsyncLocalStorageT,
|
|
15
|
+
ContinueAsNew as ContinueAsNewT,
|
|
16
|
+
} from '@temporalio/workflow';
|
|
17
|
+
import type { getActivator as getActivatorT } from '@temporalio/workflow/lib/global-attributes';
|
|
18
|
+
import type { SdkFlags as SdkFlagsT } from '@temporalio/workflow/lib/flags';
|
|
19
|
+
|
|
20
|
+
import { IllegalStateError } from '@temporalio/common';
|
|
21
|
+
|
|
22
|
+
// always returns false since if using this implementation, we are outside of workflow context
|
|
23
|
+
export const inWorkflowContext: typeof inWorkflowContextT = () => false;
|
|
24
|
+
|
|
25
|
+
// All of the following stubs will throw if used
|
|
26
|
+
export const workflowInfo: typeof workflowInfoT = () => {
|
|
27
|
+
throw new IllegalStateError('Workflow.workflowInfo(...) may only be used from a Workflow Execution.');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const ContinueAsNew = class ContinueAsNew {} as unknown as typeof ContinueAsNewT;
|
|
31
|
+
|
|
32
|
+
export const AsyncLocalStorage = class AsyncLocalStorage {} as unknown as typeof AsyncLocalStorageT;
|
|
33
|
+
|
|
34
|
+
export const getActivator: typeof getActivatorT = () => {
|
|
35
|
+
throw new IllegalStateError('Workflow uninitialized');
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const proxySinks: typeof proxySinksT = () => {
|
|
39
|
+
throw new IllegalStateError('Proxied sinks functions may only be used from a Workflow Execution.');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const SdkFlags: typeof SdkFlagsT = {} as typeof SdkFlagsT;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for working with a possibly missing `@temporalio/workflow` peer dependency
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type * as WorkflowModule from '@temporalio/workflow';
|
|
6
|
-
import type { SdkFlags as SdkFlagsT } from '@temporalio/workflow/lib/flags';
|
|
7
|
-
type SdkFlags = typeof SdkFlagsT;
|
|
8
|
-
/**
|
|
9
|
-
* Returns `@temporalio/workflow` module if present.
|
|
10
|
-
* Throws if the module failed to load
|
|
11
|
-
*/
|
|
12
|
-
export declare function getWorkflowModule(): typeof WorkflowModule;
|
|
13
|
-
/**
|
|
14
|
-
* Returns if an SDK flag was set
|
|
15
|
-
*
|
|
16
|
-
* Expects to be called only after `ensureWorkflowModuleLoaded`.
|
|
17
|
-
* Will throw if `@temporalio/workflow` is not available
|
|
18
|
-
*/
|
|
19
|
-
export declare function hasSdkFlag(flag: keyof SdkFlags): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Checks if the workflow module loaded successfully and throws if not.
|
|
22
|
-
*/
|
|
23
|
-
export declare function ensureWorkflowModuleLoaded(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Returns the workflow module if available, or undefined if it failed to load.
|
|
26
|
-
*/
|
|
27
|
-
export declare function getWorkflowModuleIfAvailable(): typeof WorkflowModule | undefined;
|
|
28
|
-
export {};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getWorkflowModule = getWorkflowModule;
|
|
4
|
-
exports.hasSdkFlag = hasSdkFlag;
|
|
5
|
-
exports.ensureWorkflowModuleLoaded = ensureWorkflowModuleLoaded;
|
|
6
|
-
exports.getWorkflowModuleIfAvailable = getWorkflowModuleIfAvailable;
|
|
7
|
-
// @temporalio/workflow is an optional peer dependency.
|
|
8
|
-
// It can be missing as long as the user isn't attempting to construct a workflow interceptor.
|
|
9
|
-
// If we start shipping ES modules alongside CJS, we will have to reconsider
|
|
10
|
-
// this dynamic import as `import` is async for ES modules.
|
|
11
|
-
let workflowModule;
|
|
12
|
-
let workflowModuleLoadError;
|
|
13
|
-
try {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
15
|
-
workflowModule = require('@temporalio/workflow');
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
// Capture the module not found error to rethrow if the module is required
|
|
19
|
-
workflowModuleLoadError = err;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns `@temporalio/workflow` module if present.
|
|
23
|
-
* Throws if the module failed to load
|
|
24
|
-
*/
|
|
25
|
-
function getWorkflowModule() {
|
|
26
|
-
if (workflowModuleLoadError) {
|
|
27
|
-
throw workflowModuleLoadError;
|
|
28
|
-
}
|
|
29
|
-
return workflowModule;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Returns if an SDK flag was set
|
|
33
|
-
*
|
|
34
|
-
* Expects to be called only after `ensureWorkflowModuleLoaded`.
|
|
35
|
-
* Will throw if `@temporalio/workflow` is not available
|
|
36
|
-
*/
|
|
37
|
-
function hasSdkFlag(flag) {
|
|
38
|
-
const { SdkFlags } = require('@temporalio/workflow/lib/flags'); // eslint-disable-line @typescript-eslint/no-require-imports
|
|
39
|
-
const { getActivator } = require('@temporalio/workflow/lib/global-attributes'); // eslint-disable-line @typescript-eslint/no-require-imports
|
|
40
|
-
return getActivator().hasFlag(SdkFlags[flag]);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Checks if the workflow module loaded successfully and throws if not.
|
|
44
|
-
*/
|
|
45
|
-
function ensureWorkflowModuleLoaded() {
|
|
46
|
-
if (workflowModuleLoadError) {
|
|
47
|
-
throw workflowModuleLoadError;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns the workflow module if available, or undefined if it failed to load.
|
|
52
|
-
*/
|
|
53
|
-
function getWorkflowModuleIfAvailable() {
|
|
54
|
-
return workflowModule;
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=workflow-module-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-module-loader.js","sourceRoot":"","sources":["../../src/workflow/workflow-module-loader.ts"],"names":[],"mappings":";;AA4BA,8CAKC;AAQD,gCAMC;AAKD,gEAIC;AAKD,oEAEC;AAtDD,uDAAuD;AACvD,8FAA8F;AAC9F,4EAA4E;AAC5E,2DAA2D;AAC3D,IAAI,cAAiD,CAAC;AACtD,IAAI,uBAAwC,CAAC;AAE7C,IAAI,CAAC;IACH,iEAAiE;IACjE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;AACnD,CAAC;AAAC,OAAO,GAAG,EAAE,CAAC;IACb,0EAA0E;IAC1E,uBAAuB,GAAG,GAAG,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB;IAC/B,IAAI,uBAAuB,EAAE,CAAC;QAC5B,MAAM,uBAAuB,CAAC;IAChC,CAAC;IACD,OAAO,cAAe,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAoB;IAC7C,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,gCAAgC,CAAoD,CAAC,CAAC,4DAA4D;IAC/K,MAAM,EAAE,YAAY,EAAE,GACpB,OAAO,CAAC,4CAA4C,CAAgE,CAAC,CAAC,4DAA4D;IAEpL,OAAO,YAAY,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC;AAED;;GAEG;AACH,SAAgB,0BAA0B;IACxC,IAAI,uBAAuB,EAAE,CAAC;QAC5B,MAAM,uBAAuB,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,4BAA4B;IAC1C,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utilities for working with a possibly missing `@temporalio/workflow` peer dependency
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import type * as WorkflowModule from '@temporalio/workflow';
|
|
6
|
-
import type { SdkFlags as SdkFlagsT } from '@temporalio/workflow/lib/flags';
|
|
7
|
-
|
|
8
|
-
type SdkFlags = typeof SdkFlagsT;
|
|
9
|
-
|
|
10
|
-
// @temporalio/workflow is an optional peer dependency.
|
|
11
|
-
// It can be missing as long as the user isn't attempting to construct a workflow interceptor.
|
|
12
|
-
// If we start shipping ES modules alongside CJS, we will have to reconsider
|
|
13
|
-
// this dynamic import as `import` is async for ES modules.
|
|
14
|
-
let workflowModule: typeof WorkflowModule | undefined;
|
|
15
|
-
let workflowModuleLoadError: any | undefined;
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
19
|
-
workflowModule = require('@temporalio/workflow');
|
|
20
|
-
} catch (err) {
|
|
21
|
-
// Capture the module not found error to rethrow if the module is required
|
|
22
|
-
workflowModuleLoadError = err;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Returns `@temporalio/workflow` module if present.
|
|
27
|
-
* Throws if the module failed to load
|
|
28
|
-
*/
|
|
29
|
-
export function getWorkflowModule(): typeof WorkflowModule {
|
|
30
|
-
if (workflowModuleLoadError) {
|
|
31
|
-
throw workflowModuleLoadError;
|
|
32
|
-
}
|
|
33
|
-
return workflowModule!;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns if an SDK flag was set
|
|
38
|
-
*
|
|
39
|
-
* Expects to be called only after `ensureWorkflowModuleLoaded`.
|
|
40
|
-
* Will throw if `@temporalio/workflow` is not available
|
|
41
|
-
*/
|
|
42
|
-
export function hasSdkFlag(flag: keyof SdkFlags): boolean {
|
|
43
|
-
const { SdkFlags } = require('@temporalio/workflow/lib/flags') as typeof import('@temporalio/workflow/lib/flags'); // eslint-disable-line @typescript-eslint/no-require-imports
|
|
44
|
-
const { getActivator } =
|
|
45
|
-
require('@temporalio/workflow/lib/global-attributes') as typeof import('@temporalio/workflow/lib/global-attributes'); // eslint-disable-line @typescript-eslint/no-require-imports
|
|
46
|
-
|
|
47
|
-
return getActivator().hasFlag(SdkFlags[flag]);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Checks if the workflow module loaded successfully and throws if not.
|
|
52
|
-
*/
|
|
53
|
-
export function ensureWorkflowModuleLoaded(): void {
|
|
54
|
-
if (workflowModuleLoadError) {
|
|
55
|
-
throw workflowModuleLoadError;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Returns the workflow module if available, or undefined if it failed to load.
|
|
61
|
-
*/
|
|
62
|
-
export function getWorkflowModuleIfAvailable(): typeof WorkflowModule | undefined {
|
|
63
|
-
return workflowModule;
|
|
64
|
-
}
|