@temporalio/interceptors-opentelemetry-v2 1.19.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/LICENSE +21 -0
- package/README.md +12 -0
- package/lib/client/index.d.ts +26 -0
- package/lib/client/index.js +185 -0
- package/lib/client/index.js.map +1 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/instrumentation.d.ts +58 -0
- package/lib/instrumentation.js +152 -0
- package/lib/instrumentation.js.map +1 -0
- package/lib/plugin.d.ts +31 -0
- package/lib/plugin.js +66 -0
- package/lib/plugin.js.map +1 -0
- package/lib/worker/index.d.ts +69 -0
- package/lib/worker/index.js +222 -0
- package/lib/worker/index.js.map +1 -0
- package/lib/workflow/context-manager.d.ts +10 -0
- package/lib/workflow/context-manager.js +67 -0
- package/lib/workflow/context-manager.js.map +1 -0
- package/lib/workflow/definitions.d.ts +127 -0
- package/lib/workflow/definitions.js +92 -0
- package/lib/workflow/definitions.js.map +1 -0
- package/lib/workflow/id-generator.d.ts +8 -0
- package/lib/workflow/id-generator.js +30 -0
- package/lib/workflow/id-generator.js.map +1 -0
- package/lib/workflow/index.d.ts +51 -0
- package/lib/workflow/index.js +252 -0
- package/lib/workflow/index.js.map +1 -0
- package/lib/workflow/performance-polyfill.d.ts +16 -0
- package/lib/workflow/performance-polyfill.js +29 -0
- package/lib/workflow/performance-polyfill.js.map +1 -0
- package/lib/workflow/runtime.d.ts +1 -0
- package/lib/workflow/runtime.js +14 -0
- package/lib/workflow/runtime.js.map +1 -0
- package/lib/workflow/span-exporter.d.ts +9 -0
- package/lib/workflow/span-exporter.js +56 -0
- package/lib/workflow/span-exporter.js.map +1 -0
- package/lib/workflow/workflow-imports-impl.d.ts +7 -0
- package/lib/workflow/workflow-imports-impl.js +17 -0
- package/lib/workflow/workflow-imports-impl.js.map +1 -0
- package/lib/workflow/workflow-imports.d.ts +16 -0
- package/lib/workflow/workflow-imports.js +25 -0
- package/lib/workflow/workflow-imports.js.map +1 -0
- package/lib/workflow-interceptors.d.ts +3 -0
- package/lib/workflow-interceptors.js +12 -0
- package/lib/workflow-interceptors.js.map +1 -0
- package/package.json +78 -0
- package/src/client/index.ts +220 -0
- package/src/index.ts +14 -0
- package/src/instrumentation.ts +159 -0
- package/src/plugin.ts +86 -0
- package/src/worker/index.ts +264 -0
- package/src/workflow/context-manager.ts +53 -0
- package/src/workflow/definitions.ts +145 -0
- package/src/workflow/id-generator.ts +30 -0
- package/src/workflow/index.ts +312 -0
- package/src/workflow/performance-polyfill.ts +31 -0
- package/src/workflow/runtime.ts +12 -0
- package/src/workflow/span-exporter.ts +60 -0
- package/src/workflow/workflow-imports-impl.ts +14 -0
- package/src/workflow/workflow-imports.ts +39 -0
- package/src/workflow-interceptors.ts +14 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import './performance-polyfill';
|
|
2
|
+
import './runtime';
|
|
3
|
+
import * as otel from '@opentelemetry/api';
|
|
4
|
+
import type { ActivityInput, ContinueAsNewInput, DisposeInput, GetLogAttributesInput, GetMetricTagsInput, LocalActivityInput, Next, QueryInput, SignalInput, SignalWorkflowInput, StartChildWorkflowExecutionInput, UpdateInput, WorkflowExecuteInput, WorkflowInboundCallsInterceptor, WorkflowInternalsInterceptor, WorkflowOutboundCallsInterceptor, StartNexusOperationInput, StartNexusOperationOutput } from '@temporalio/workflow';
|
|
5
|
+
export * from './definitions';
|
|
6
|
+
/**
|
|
7
|
+
* Intercepts calls to run a Workflow
|
|
8
|
+
*
|
|
9
|
+
* Wraps the operation in an opentelemetry Span and links it to a parent Span context if one is
|
|
10
|
+
* provided in the Workflow input headers.
|
|
11
|
+
*
|
|
12
|
+
* `@temporalio/workflow` must be provided by host package in order to function.
|
|
13
|
+
*
|
|
14
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpenTelemetryInboundInterceptor implements WorkflowInboundCallsInterceptor {
|
|
17
|
+
protected readonly tracer: otel.Tracer;
|
|
18
|
+
execute(input: WorkflowExecuteInput, next: Next<WorkflowInboundCallsInterceptor, 'execute'>): Promise<unknown>;
|
|
19
|
+
handleSignal(input: SignalInput, next: Next<WorkflowInboundCallsInterceptor, 'handleSignal'>): Promise<void>;
|
|
20
|
+
handleUpdate(input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'handleUpdate'>): Promise<unknown>;
|
|
21
|
+
validateUpdate(input: UpdateInput, next: Next<WorkflowInboundCallsInterceptor, 'validateUpdate'>): void;
|
|
22
|
+
handleQuery(input: QueryInput, next: Next<WorkflowInboundCallsInterceptor, 'handleQuery'>): Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Intercepts outbound calls to schedule an Activity
|
|
26
|
+
*
|
|
27
|
+
* Wraps the operation in an opentelemetry Span and passes it to the Activity via headers.
|
|
28
|
+
*
|
|
29
|
+
* `@temporalio/workflow` must be provided by host package in order to function.
|
|
30
|
+
*
|
|
31
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
32
|
+
*/
|
|
33
|
+
export declare class OpenTelemetryOutboundInterceptor implements WorkflowOutboundCallsInterceptor {
|
|
34
|
+
protected readonly tracer: otel.Tracer;
|
|
35
|
+
scheduleActivity(input: ActivityInput, next: Next<WorkflowOutboundCallsInterceptor, 'scheduleActivity'>): Promise<unknown>;
|
|
36
|
+
scheduleLocalActivity(input: LocalActivityInput, next: Next<WorkflowOutboundCallsInterceptor, 'scheduleLocalActivity'>): Promise<unknown>;
|
|
37
|
+
startNexusOperation(input: StartNexusOperationInput, next: Next<WorkflowOutboundCallsInterceptor, 'startNexusOperation'>): Promise<StartNexusOperationOutput>;
|
|
38
|
+
startChildWorkflowExecution(input: StartChildWorkflowExecutionInput, next: Next<WorkflowOutboundCallsInterceptor, 'startChildWorkflowExecution'>): Promise<[Promise<string>, Promise<unknown>]>;
|
|
39
|
+
continueAsNew(input: ContinueAsNewInput, next: Next<WorkflowOutboundCallsInterceptor, 'continueAsNew'>): Promise<never>;
|
|
40
|
+
signalWorkflow(input: SignalWorkflowInput, next: Next<WorkflowOutboundCallsInterceptor, 'signalWorkflow'>): Promise<void>;
|
|
41
|
+
getLogAttributes(input: GetLogAttributesInput, next: Next<WorkflowOutboundCallsInterceptor, 'getLogAttributes'>): Record<string, unknown>;
|
|
42
|
+
getMetricTags(input: GetMetricTagsInput, next: Next<WorkflowOutboundCallsInterceptor, 'getMetricTags'>): GetMetricTagsInput;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Intercepts Workflow lifecycle internals.
|
|
46
|
+
*
|
|
47
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
48
|
+
*/
|
|
49
|
+
export declare class OpenTelemetryInternalsInterceptor implements WorkflowInternalsInterceptor {
|
|
50
|
+
dispose(input: DisposeInput, next: Next<WorkflowInternalsInterceptor, 'dispose'>): Promise<void>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.OpenTelemetryInternalsInterceptor = exports.OpenTelemetryOutboundInterceptor = exports.OpenTelemetryInboundInterceptor = void 0;
|
|
30
|
+
// eslint-disable-next-line import/no-unassigned-import
|
|
31
|
+
require("./performance-polyfill"); // Zero-import polyfill; must run before OTel modules access `performance`
|
|
32
|
+
// eslint-disable-next-line import/no-unassigned-import
|
|
33
|
+
require("./runtime"); // Patch the Workflow isolate runtime for opentelemetry
|
|
34
|
+
const otel = __importStar(require("@opentelemetry/api"));
|
|
35
|
+
const tracing = __importStar(require("@opentelemetry/sdk-trace-base"));
|
|
36
|
+
const core_1 = require("@opentelemetry/core");
|
|
37
|
+
const instrumentation_1 = require("../instrumentation");
|
|
38
|
+
const context_manager_1 = require("./context-manager");
|
|
39
|
+
const definitions_1 = require("./definitions");
|
|
40
|
+
const span_exporter_1 = require("./span-exporter");
|
|
41
|
+
const id_generator_1 = require("./id-generator");
|
|
42
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
43
|
+
__exportStar(require("./definitions"), exports);
|
|
44
|
+
let tracer = undefined;
|
|
45
|
+
let contextManager = undefined;
|
|
46
|
+
function getTracer() {
|
|
47
|
+
if (contextManager === undefined) {
|
|
48
|
+
contextManager = new context_manager_1.ContextManager();
|
|
49
|
+
}
|
|
50
|
+
if (tracer === undefined) {
|
|
51
|
+
const provider = new tracing.BasicTracerProvider({
|
|
52
|
+
idGenerator: new id_generator_1.DeterministicIdGenerator(),
|
|
53
|
+
spanProcessors: [new tracing.SimpleSpanProcessor(new span_exporter_1.SpanExporter())],
|
|
54
|
+
});
|
|
55
|
+
otel.propagation.setGlobalPropagator(new core_1.W3CTraceContextPropagator());
|
|
56
|
+
otel.trace.setGlobalTracerProvider(provider);
|
|
57
|
+
otel.context.setGlobalContextManager(contextManager);
|
|
58
|
+
tracer = provider.getTracer('@temporalio/interceptor-workflow');
|
|
59
|
+
}
|
|
60
|
+
return tracer;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Intercepts calls to run a Workflow
|
|
64
|
+
*
|
|
65
|
+
* Wraps the operation in an opentelemetry Span and links it to a parent Span context if one is
|
|
66
|
+
* provided in the Workflow input headers.
|
|
67
|
+
*
|
|
68
|
+
* `@temporalio/workflow` must be provided by host package in order to function.
|
|
69
|
+
*
|
|
70
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
71
|
+
*/
|
|
72
|
+
class OpenTelemetryInboundInterceptor {
|
|
73
|
+
tracer = getTracer();
|
|
74
|
+
async execute(input, next) {
|
|
75
|
+
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
76
|
+
return await (0, instrumentation_1.instrument)({
|
|
77
|
+
tracer: this.tracer,
|
|
78
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_EXECUTE}${definitions_1.SPAN_DELIMITER}${(0, workflow_imports_1.workflowInfo)().workflowType}`,
|
|
79
|
+
fn: () => next(input),
|
|
80
|
+
context,
|
|
81
|
+
acceptableErrors: (err) => err instanceof workflow_imports_1.ContinueAsNew,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async handleSignal(input, next) {
|
|
85
|
+
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
86
|
+
return await (0, instrumentation_1.instrument)({
|
|
87
|
+
tracer: this.tracer,
|
|
88
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_HANDLE_SIGNAL}${definitions_1.SPAN_DELIMITER}${input.signalName}`,
|
|
89
|
+
fn: () => next(input),
|
|
90
|
+
context,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async handleUpdate(input, next) {
|
|
94
|
+
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
95
|
+
return await (0, instrumentation_1.instrument)({
|
|
96
|
+
tracer: this.tracer,
|
|
97
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_HANDLE_UPDATE}${definitions_1.SPAN_DELIMITER}${input.name}`,
|
|
98
|
+
fn: (span) => {
|
|
99
|
+
span.setAttribute(instrumentation_1.UPDATE_ID_ATTR_KEY, input.updateId);
|
|
100
|
+
return next(input);
|
|
101
|
+
},
|
|
102
|
+
context,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
validateUpdate(input, next) {
|
|
106
|
+
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
107
|
+
(0, instrumentation_1.instrumentSync)({
|
|
108
|
+
tracer: this.tracer,
|
|
109
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_VALIDATE_UPDATE}${definitions_1.SPAN_DELIMITER}${input.name}`,
|
|
110
|
+
fn: (span) => {
|
|
111
|
+
span.setAttribute(instrumentation_1.UPDATE_ID_ATTR_KEY, input.updateId);
|
|
112
|
+
return next(input);
|
|
113
|
+
},
|
|
114
|
+
context,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
async handleQuery(input, next) {
|
|
118
|
+
const context = (0, instrumentation_1.extractContextFromHeaders)(input.headers);
|
|
119
|
+
return await (0, instrumentation_1.instrument)({
|
|
120
|
+
tracer: this.tracer,
|
|
121
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_HANDLE_QUERY}${definitions_1.SPAN_DELIMITER}${input.queryName}`,
|
|
122
|
+
fn: () => next(input),
|
|
123
|
+
context,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.OpenTelemetryInboundInterceptor = OpenTelemetryInboundInterceptor;
|
|
128
|
+
/**
|
|
129
|
+
* Intercepts outbound calls to schedule an Activity
|
|
130
|
+
*
|
|
131
|
+
* Wraps the operation in an opentelemetry Span and passes it to the Activity via headers.
|
|
132
|
+
*
|
|
133
|
+
* `@temporalio/workflow` must be provided by host package in order to function.
|
|
134
|
+
*
|
|
135
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
136
|
+
*/
|
|
137
|
+
class OpenTelemetryOutboundInterceptor {
|
|
138
|
+
tracer = getTracer();
|
|
139
|
+
async scheduleActivity(input, next) {
|
|
140
|
+
return await (0, instrumentation_1.instrument)({
|
|
141
|
+
tracer: this.tracer,
|
|
142
|
+
spanName: `${definitions_1.SpanName.ACTIVITY_START}${definitions_1.SPAN_DELIMITER}${input.activityType}`,
|
|
143
|
+
fn: async () => {
|
|
144
|
+
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
145
|
+
return next({
|
|
146
|
+
...input,
|
|
147
|
+
headers,
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
async scheduleLocalActivity(input, next) {
|
|
153
|
+
return await (0, instrumentation_1.instrument)({
|
|
154
|
+
tracer: this.tracer,
|
|
155
|
+
spanName: `${definitions_1.SpanName.ACTIVITY_START}${definitions_1.SPAN_DELIMITER}${input.activityType}`,
|
|
156
|
+
fn: async () => {
|
|
157
|
+
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
158
|
+
return next({
|
|
159
|
+
...input,
|
|
160
|
+
headers,
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async startNexusOperation(input, next) {
|
|
166
|
+
return await (0, instrumentation_1.instrument)({
|
|
167
|
+
tracer: this.tracer,
|
|
168
|
+
spanName: `${definitions_1.SpanName.NEXUS_OPERATION_START}${definitions_1.SPAN_DELIMITER}${input.service}/${input.operation}`,
|
|
169
|
+
fn: async (span) => {
|
|
170
|
+
span.setAttribute(instrumentation_1.NEXUS_SERVICE_ATTR_KEY, input.service);
|
|
171
|
+
span.setAttribute(instrumentation_1.NEXUS_OPERATION_ATTR_KEY, input.operation);
|
|
172
|
+
span.setAttribute(instrumentation_1.NEXUS_ENDPOINT_ATTR_KEY, input.endpoint);
|
|
173
|
+
const headers = (0, instrumentation_1.nexusHeadersWithContext)(input.headers);
|
|
174
|
+
return await next({ ...input, headers });
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async startChildWorkflowExecution(input, next) {
|
|
179
|
+
return await (0, instrumentation_1.instrument)({
|
|
180
|
+
tracer: this.tracer,
|
|
181
|
+
spanName: `${definitions_1.SpanName.CHILD_WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
182
|
+
fn: async () => {
|
|
183
|
+
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
184
|
+
return next({
|
|
185
|
+
...input,
|
|
186
|
+
headers,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
async continueAsNew(input, next) {
|
|
192
|
+
return await (0, instrumentation_1.instrument)({
|
|
193
|
+
tracer: this.tracer,
|
|
194
|
+
spanName: `${definitions_1.SpanName.CONTINUE_AS_NEW}${definitions_1.SPAN_DELIMITER}${input.options.workflowType}`,
|
|
195
|
+
fn: async () => {
|
|
196
|
+
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
197
|
+
return next({
|
|
198
|
+
...input,
|
|
199
|
+
headers,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
acceptableErrors: (err) => err instanceof workflow_imports_1.ContinueAsNew,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
async signalWorkflow(input, next) {
|
|
206
|
+
return await (0, instrumentation_1.instrument)({
|
|
207
|
+
tracer: this.tracer,
|
|
208
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL}${definitions_1.SPAN_DELIMITER}${input.signalName}`,
|
|
209
|
+
fn: async () => {
|
|
210
|
+
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
211
|
+
return next({
|
|
212
|
+
...input,
|
|
213
|
+
headers,
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
getLogAttributes(input, next) {
|
|
219
|
+
const span = otel.trace.getSpan(otel.context.active());
|
|
220
|
+
const spanContext = span?.spanContext();
|
|
221
|
+
if (spanContext && otel.isSpanContextValid(spanContext)) {
|
|
222
|
+
return next({
|
|
223
|
+
trace_id: spanContext.traceId,
|
|
224
|
+
span_id: spanContext.spanId,
|
|
225
|
+
trace_flags: `0${spanContext.traceFlags.toString(16)}`,
|
|
226
|
+
...input,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
return next(input);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
getMetricTags(input, next) {
|
|
234
|
+
return next(input);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.OpenTelemetryOutboundInterceptor = OpenTelemetryOutboundInterceptor;
|
|
238
|
+
/**
|
|
239
|
+
* Intercepts Workflow lifecycle internals.
|
|
240
|
+
*
|
|
241
|
+
* @experimental This interceptor is experimental and APIs may change without notice.
|
|
242
|
+
*/
|
|
243
|
+
class OpenTelemetryInternalsInterceptor {
|
|
244
|
+
async dispose(input, next) {
|
|
245
|
+
if (contextManager !== undefined) {
|
|
246
|
+
contextManager.disable();
|
|
247
|
+
}
|
|
248
|
+
next(input);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.OpenTelemetryInternalsInterceptor = OpenTelemetryInternalsInterceptor;
|
|
252
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings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@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polyfill performance for the workflow isolate.
|
|
3
|
+
*
|
|
4
|
+
* OTel v2's browser platform accesses `performance` at module scope.
|
|
5
|
+
* This file MUST have zero imports so webpack initializes it before any
|
|
6
|
+
* OTel module that references `performance`.
|
|
7
|
+
*
|
|
8
|
+
* The guard uses two checks:
|
|
9
|
+
* - `__webpack_module_cache__` on globalThis is a positive indicator of the
|
|
10
|
+
* workflow sandbox (set by the SDK's VM creators before the bundle evaluates).
|
|
11
|
+
* - `performance` being undefined confirms polyfilling is needed. The polyfill
|
|
12
|
+
* reads workflow time from the activator so it is safe during preload.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Polyfill performance for the workflow isolate.
|
|
4
|
+
*
|
|
5
|
+
* OTel v2's browser platform accesses `performance` at module scope.
|
|
6
|
+
* This file MUST have zero imports so webpack initializes it before any
|
|
7
|
+
* OTel module that references `performance`.
|
|
8
|
+
*
|
|
9
|
+
* The guard uses two checks:
|
|
10
|
+
* - `__webpack_module_cache__` on globalThis is a positive indicator of the
|
|
11
|
+
* workflow sandbox (set by the SDK's VM creators before the bundle evaluates).
|
|
12
|
+
* - `performance` being undefined confirms polyfilling is needed. The polyfill
|
|
13
|
+
* reads workflow time from the activator so it is safe during preload.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
if ('__webpack_module_cache__' in globalThis && typeof performance === 'undefined') {
|
|
19
|
+
const now = () => globalThis.__TEMPORAL_ACTIVATOR__?.now ?? 0;
|
|
20
|
+
Object.assign(globalThis, {
|
|
21
|
+
performance: {
|
|
22
|
+
timeOrigin: now(),
|
|
23
|
+
now() {
|
|
24
|
+
return now() - this.timeOrigin;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=performance-polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-polyfill.js","sourceRoot":"","sources":["../../src/workflow/performance-polyfill.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,IAAI,0BAA0B,IAAI,UAAU,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;IACnF,MAAM,GAAG,GAAG,GAAG,EAAE,CAAG,UAAkB,CAAC,sBAAsB,EAAE,GAA0B,IAAI,CAAC,CAAC;IAC/F,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,WAAW,EAAE;YACX,UAAU,EAAE,GAAG,EAAE;YACjB,GAAG;gBACD,OAAO,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC;YACjC,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Sets global variables required for importing opentelemetry in isolate
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
8
|
+
if ((0, workflow_imports_1.inWorkflowContext)()) {
|
|
9
|
+
// OTel uses `window` to detect a browser environment
|
|
10
|
+
Object.assign(globalThis, {
|
|
11
|
+
window: globalThis,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,qDAAqD;IACrD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QACxB,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as tracing from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
import type { ExportResult } from '@opentelemetry/core';
|
|
3
|
+
import type { SerializableSpan } from './definitions';
|
|
4
|
+
export declare class SpanExporter implements tracing.SpanExporter {
|
|
5
|
+
private exporter?;
|
|
6
|
+
export(spans: tracing.ReadableSpan[], resultCallback: (result: ExportResult) => void): void;
|
|
7
|
+
shutdown(): Promise<void>;
|
|
8
|
+
makeSerializable(span: tracing.ReadableSpan): SerializableSpan;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpanExporter = void 0;
|
|
4
|
+
const core_1 = require("@opentelemetry/core");
|
|
5
|
+
const workflow_imports_1 = require("./workflow-imports");
|
|
6
|
+
class SpanExporter {
|
|
7
|
+
exporter;
|
|
8
|
+
export(spans, resultCallback) {
|
|
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
|
+
resultCallback({ code: core_1.ExportResultCode.SUCCESS });
|
|
14
|
+
}
|
|
15
|
+
async shutdown() {
|
|
16
|
+
// Nothing to shut down
|
|
17
|
+
}
|
|
18
|
+
makeSerializable(span) {
|
|
19
|
+
const { traceState, ...restSpanContext } = span.spanContext();
|
|
20
|
+
// Serialize traceState to a string because TraceState objects lose their
|
|
21
|
+
// prototype methods when crossing the V8 isolate boundary.
|
|
22
|
+
// See: https://github.com/temporalio/sdk-typescript/issues/1738
|
|
23
|
+
const serializableSpanContext = {
|
|
24
|
+
traceState: traceState?.serialize(),
|
|
25
|
+
...restSpanContext,
|
|
26
|
+
};
|
|
27
|
+
let serializableParentSpanContext;
|
|
28
|
+
if (span.parentSpanContext) {
|
|
29
|
+
const { traceState: parentTraceState, ...restParentSpanContext } = span.parentSpanContext;
|
|
30
|
+
serializableParentSpanContext = {
|
|
31
|
+
traceState: parentTraceState?.serialize(),
|
|
32
|
+
...restParentSpanContext,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
name: span.name,
|
|
37
|
+
kind: span.kind,
|
|
38
|
+
spanContext: serializableSpanContext,
|
|
39
|
+
parentSpanContext: serializableParentSpanContext,
|
|
40
|
+
startTime: span.startTime,
|
|
41
|
+
endTime: span.endTime,
|
|
42
|
+
status: span.status,
|
|
43
|
+
attributes: span.attributes,
|
|
44
|
+
links: span.links,
|
|
45
|
+
events: span.events,
|
|
46
|
+
duration: span.duration,
|
|
47
|
+
ended: span.ended,
|
|
48
|
+
droppedAttributesCount: span.droppedAttributesCount,
|
|
49
|
+
droppedEventsCount: span.droppedEventsCount,
|
|
50
|
+
droppedLinksCount: span.droppedLinksCount,
|
|
51
|
+
instrumentationScope: span.instrumentationScope,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.SpanExporter = SpanExporter;
|
|
56
|
+
//# sourceMappingURL=span-exporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"span-exporter.js","sourceRoot":"","sources":["../../src/workflow/span-exporter.ts"],"names":[],"mappings":";;;AAEA,8CAAuD;AAEvD,yDAAgD;AAEhD,MAAa,YAAY;IACf,QAAQ,CAAkC;IAE3C,MAAM,CAAC,KAA6B,EAAE,cAA8C;QACzF,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,IAAI,CAAC,QAAQ,GAAG,IAAA,6BAAU,GAAsB,CAAC,QAAQ,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAA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I,CAAC,sBAAsB;YACnD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;SAChD,CAAC;IACJ,CAAC;CACF;AArDD,oCAqDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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, getRandomStream, } from '@temporalio/workflow';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomStream = 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
|
+
Object.defineProperty(exports, "getRandomStream", { enumerable: true, get: function () { return workflow_1.getRandomStream; } });
|
|
17
|
+
//# 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,iDAO8B;AAN5B,6GAAA,iBAAiB,OAAA;AACjB,sGAAA,UAAU,OAAA;AACV,wGAAA,YAAY,OAAA;AACZ,6GAAA,iBAAiB,OAAA;AACjB,yGAAA,aAAa,OAAA;AACb,2GAAA,eAAe,OAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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, getRandomStream as getRandomStreamT } from '@temporalio/workflow';
|
|
11
|
+
export declare const inWorkflowContext: typeof inWorkflowContextT;
|
|
12
|
+
export declare const workflowInfo: typeof workflowInfoT;
|
|
13
|
+
export declare const ContinueAsNew: typeof ContinueAsNewT;
|
|
14
|
+
export declare const AsyncLocalStorage: typeof AsyncLocalStorageT;
|
|
15
|
+
export declare const proxySinks: typeof proxySinksT;
|
|
16
|
+
export declare const getRandomStream: typeof getRandomStreamT;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomStream = exports.proxySinks = 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 proxySinks = () => {
|
|
18
|
+
throw new common_1.IllegalStateError('Proxied sinks functions may only be used from a Workflow Execution.');
|
|
19
|
+
};
|
|
20
|
+
exports.proxySinks = proxySinks;
|
|
21
|
+
const getRandomStream = () => {
|
|
22
|
+
throw new common_1.IllegalStateError('Workflow.getRandomStream(...) may only be used from a Workflow Execution.');
|
|
23
|
+
};
|
|
24
|
+
exports.getRandomStream = getRandomStream;
|
|
25
|
+
//# sourceMappingURL=workflow-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-imports.js","sourceRoot":"","sources":["../../src/workflow/workflow-imports.ts"],"names":[],"mappings":";;;AAkBA,+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,UAAU,GAAuB,GAAG,EAAE;IACjD,MAAM,IAAI,0BAAiB,CAAC,qEAAqE,CAAC,CAAC;AACrG,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB;AAEK,MAAM,eAAe,GAA4B,GAAG,EAAE;IAC3D,MAAM,IAAI,0BAAiB,CAAC,2EAA2E,CAAC,CAAC;AAC3G,CAAC,CAAC;AAFW,QAAA,eAAe,mBAE1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Not a workflow, just interceptors */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.interceptors = void 0;
|
|
5
|
+
const workflow_1 = require("./workflow");
|
|
6
|
+
const interceptors = () => ({
|
|
7
|
+
inbound: [new workflow_1.OpenTelemetryInboundInterceptor()],
|
|
8
|
+
outbound: [new workflow_1.OpenTelemetryOutboundInterceptor()],
|
|
9
|
+
internals: [new workflow_1.OpenTelemetryInternalsInterceptor()],
|
|
10
|
+
});
|
|
11
|
+
exports.interceptors = interceptors;
|
|
12
|
+
//# sourceMappingURL=workflow-interceptors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-interceptors.js","sourceRoot":"","sources":["../src/workflow-interceptors.ts"],"names":[],"mappings":";AAAA,wCAAwC;;;AAGxC,yCAIoB;AAEb,MAAM,YAAY,GAAG,GAAyB,EAAE,CAAC,CAAC;IACvD,OAAO,EAAE,CAAC,IAAI,0CAA+B,EAAE,CAAC;IAChD,QAAQ,EAAE,CAAC,IAAI,2CAAgC,EAAE,CAAC;IAClD,SAAS,EAAE,CAAC,IAAI,4CAAiC,EAAE,CAAC;CACrD,CAAC,CAAC;AAJU,QAAA,YAAY,gBAItB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@temporalio/interceptors-opentelemetry-v2",
|
|
3
|
+
"version": "1.19.0",
|
|
4
|
+
"description": "Temporal.io SDK interceptors bundle for tracing with opentelemetry v2",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"temporal",
|
|
9
|
+
"workflow",
|
|
10
|
+
"interceptors",
|
|
11
|
+
"opentelemetry"
|
|
12
|
+
],
|
|
13
|
+
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@opentelemetry/api": "^1.9.0",
|
|
17
|
+
"@opentelemetry/core": "^2.2.0",
|
|
18
|
+
"@opentelemetry/resources": "^2.2.0",
|
|
19
|
+
"@opentelemetry/sdk-trace-base": "^2.2.0",
|
|
20
|
+
"@temporalio/plugin": "1.19.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.217.0",
|
|
24
|
+
"@opentelemetry/sdk-node": "^0.217.0",
|
|
25
|
+
"@opentelemetry/semantic-conventions": "^1.38.0",
|
|
26
|
+
"ava": "^5.3.1",
|
|
27
|
+
"nexus-rpc": "^0.0.2",
|
|
28
|
+
"rxjs": "7.8.1",
|
|
29
|
+
"uuid": "^11.1.0",
|
|
30
|
+
"@temporalio/client": "1.19.0",
|
|
31
|
+
"@temporalio/proto": "1.19.0",
|
|
32
|
+
"@temporalio/common": "1.19.0",
|
|
33
|
+
"@temporalio/test-helpers": "1.19.0",
|
|
34
|
+
"@temporalio/activity": "1.19.0",
|
|
35
|
+
"@temporalio/testing": "1.19.0",
|
|
36
|
+
"@temporalio/workflow": "1.19.0",
|
|
37
|
+
"@temporalio/worker": "1.19.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@temporalio/common": "1.19.0",
|
|
41
|
+
"@temporalio/workflow": "1.19.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@temporalio/workflow": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
50
|
+
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/temporalio/sdk-typescript.git",
|
|
54
|
+
"directory": "contrib/interceptors-opentelemetry-v2"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/contrib/interceptors-opentelemetry-v2",
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">= 20.0.0"
|
|
62
|
+
},
|
|
63
|
+
"files": [
|
|
64
|
+
"src",
|
|
65
|
+
"lib",
|
|
66
|
+
"!src/__tests__",
|
|
67
|
+
"!lib/__tests__"
|
|
68
|
+
],
|
|
69
|
+
"ava": {
|
|
70
|
+
"timeout": "120s",
|
|
71
|
+
"concurrency": 1,
|
|
72
|
+
"workerThreads": false
|
|
73
|
+
},
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "tsc --build",
|
|
76
|
+
"test": "ava ./lib/__tests__/test-*.js"
|
|
77
|
+
}
|
|
78
|
+
}
|