@temporalio/interceptors-opentelemetry 1.17.1 → 1.17.3
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/package.json +31 -13
- package/lib/client/index.d.ts +0 -24
- package/lib/client/index.js +0 -183
- package/lib/client/index.js.map +0 -1
- package/lib/index.d.ts +0 -15
- package/lib/index.js +0 -34
- package/lib/index.js.map +0 -1
- package/lib/instrumentation.d.ts +0 -58
- package/lib/instrumentation.js +0 -156
- package/lib/instrumentation.js.map +0 -1
- package/lib/plugin.d.ts +0 -31
- package/lib/plugin.js +0 -66
- package/lib/plugin.js.map +0 -1
- package/lib/worker/index.d.ts +0 -69
- package/lib/worker/index.js +0 -235
- package/lib/worker/index.js.map +0 -1
- package/lib/workflow/context-manager.d.ts +0 -10
- package/lib/workflow/context-manager.js +0 -67
- package/lib/workflow/context-manager.js.map +0 -1
- package/lib/workflow/definitions.d.ts +0 -127
- package/lib/workflow/definitions.js +0 -92
- package/lib/workflow/definitions.js.map +0 -1
- package/lib/workflow/index.d.ts +0 -41
- package/lib/workflow/index.js +0 -275
- package/lib/workflow/index.js.map +0 -1
- package/lib/workflow/runtime.d.ts +0 -1
- package/lib/workflow/runtime.js +0 -20
- package/lib/workflow/runtime.js.map +0 -1
- package/lib/workflow/span-exporter.d.ts +0 -9
- package/lib/workflow/span-exporter.js +0 -48
- package/lib/workflow/span-exporter.js.map +0 -1
- package/lib/workflow/workflow-imports-impl.d.ts +0 -9
- package/lib/workflow/workflow-imports-impl.js +0 -20
- package/lib/workflow/workflow-imports-impl.js.map +0 -1
- package/lib/workflow/workflow-imports.d.ts +0 -19
- package/lib/workflow/workflow-imports.js +0 -26
- package/lib/workflow/workflow-imports.js.map +0 -1
- package/lib/workflow-interceptors.d.ts +0 -3
- package/lib/workflow-interceptors.js +0 -12
- package/lib/workflow-interceptors.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/interceptors-opentelemetry",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.3",
|
|
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",
|
|
@@ -17,19 +17,27 @@
|
|
|
17
17
|
"@opentelemetry/core": "^1.25.1",
|
|
18
18
|
"@opentelemetry/resources": "^1.25.1",
|
|
19
19
|
"@opentelemetry/sdk-trace-base": "^1.25.1",
|
|
20
|
-
"@temporalio/plugin": "1.17.
|
|
20
|
+
"@temporalio/plugin": "1.17.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.52.1",
|
|
24
|
+
"@opentelemetry/sdk-node": "^0.52.1",
|
|
25
|
+
"@opentelemetry/semantic-conventions": "^1.25.1",
|
|
26
|
+
"ava": "^5.3.1",
|
|
23
27
|
"nexus-rpc": "^0.0.2",
|
|
24
|
-
"
|
|
25
|
-
"@temporalio/
|
|
26
|
-
"@temporalio/
|
|
27
|
-
"@temporalio/
|
|
28
|
-
"@temporalio/
|
|
28
|
+
"rxjs": "7.8.1",
|
|
29
|
+
"@temporalio/activity": "1.17.3",
|
|
30
|
+
"@temporalio/client": "1.17.3",
|
|
31
|
+
"@temporalio/proto": "1.17.3",
|
|
32
|
+
"@temporalio/test-helpers": "1.17.3",
|
|
33
|
+
"@temporalio/testing": "1.17.3",
|
|
34
|
+
"@temporalio/common": "1.17.3",
|
|
35
|
+
"@temporalio/worker": "1.17.3",
|
|
36
|
+
"@temporalio/workflow": "1.17.3"
|
|
29
37
|
},
|
|
30
38
|
"peerDependencies": {
|
|
31
|
-
"@temporalio/common": "1.17.
|
|
32
|
-
"@temporalio/workflow": "1.17.
|
|
39
|
+
"@temporalio/common": "1.17.3",
|
|
40
|
+
"@temporalio/workflow": "1.17.3"
|
|
33
41
|
},
|
|
34
42
|
"peerDependenciesMeta": {
|
|
35
43
|
"@temporalio/workflow": {
|
|
@@ -42,9 +50,9 @@
|
|
|
42
50
|
"repository": {
|
|
43
51
|
"type": "git",
|
|
44
52
|
"url": "git+https://github.com/temporalio/sdk-typescript.git",
|
|
45
|
-
"directory": "
|
|
53
|
+
"directory": "contrib/interceptors-opentelemetry"
|
|
46
54
|
},
|
|
47
|
-
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/
|
|
55
|
+
"homepage": "https://github.com/temporalio/sdk-typescript/tree/main/contrib/interceptors-opentelemetry",
|
|
48
56
|
"publishConfig": {
|
|
49
57
|
"access": "public"
|
|
50
58
|
},
|
|
@@ -53,7 +61,17 @@
|
|
|
53
61
|
},
|
|
54
62
|
"files": [
|
|
55
63
|
"src",
|
|
56
|
-
"lib"
|
|
64
|
+
"lib",
|
|
65
|
+
"!src/__tests__",
|
|
66
|
+
"!lib/__tests__"
|
|
57
67
|
],
|
|
58
|
-
"
|
|
68
|
+
"ava": {
|
|
69
|
+
"timeout": "120s",
|
|
70
|
+
"concurrency": 1,
|
|
71
|
+
"workerThreads": false
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "tsc --build",
|
|
75
|
+
"test": "ava ./lib/__tests__/test-*.js"
|
|
76
|
+
}
|
|
59
77
|
}
|
package/lib/client/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as otel from '@opentelemetry/api';
|
|
2
|
-
import type { Next, WorkflowSignalInput, WorkflowSignalWithStartInput, WorkflowStartInput, WorkflowStartOutput, WorkflowStartUpdateInput, WorkflowStartUpdateOutput, WorkflowStartUpdateWithStartInput, WorkflowStartUpdateWithStartOutput, WorkflowQueryInput, WorkflowTerminateInput, WorkflowCancelInput, WorkflowDescribeInput, WorkflowClientInterceptor, TerminateWorkflowExecutionResponse, RequestCancelWorkflowExecutionResponse, DescribeWorkflowExecutionResponse } from '@temporalio/client';
|
|
3
|
-
export interface InterceptorOptions {
|
|
4
|
-
readonly tracer?: otel.Tracer;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Intercepts calls to start a Workflow.
|
|
8
|
-
*
|
|
9
|
-
* Wraps the operation in an opentelemetry Span and passes it to the Workflow via headers.
|
|
10
|
-
*/
|
|
11
|
-
export declare class OpenTelemetryWorkflowClientInterceptor implements WorkflowClientInterceptor {
|
|
12
|
-
protected readonly tracer: otel.Tracer;
|
|
13
|
-
constructor(options?: InterceptorOptions);
|
|
14
|
-
start(input: WorkflowStartInput, next: Next<WorkflowClientInterceptor, 'start'>): Promise<string>;
|
|
15
|
-
signal(input: WorkflowSignalInput, next: Next<WorkflowClientInterceptor, 'signal'>): Promise<void>;
|
|
16
|
-
startWithDetails(input: WorkflowStartInput, next: Next<WorkflowClientInterceptor, 'startWithDetails'>): Promise<WorkflowStartOutput>;
|
|
17
|
-
startUpdate(input: WorkflowStartUpdateInput, next: Next<WorkflowClientInterceptor, 'startUpdate'>): Promise<WorkflowStartUpdateOutput>;
|
|
18
|
-
startUpdateWithStart(input: WorkflowStartUpdateWithStartInput, next: Next<WorkflowClientInterceptor, 'startUpdateWithStart'>): Promise<WorkflowStartUpdateWithStartOutput>;
|
|
19
|
-
signalWithStart(input: WorkflowSignalWithStartInput, next: Next<WorkflowClientInterceptor, 'signalWithStart'>): Promise<string>;
|
|
20
|
-
query(input: WorkflowQueryInput, next: Next<WorkflowClientInterceptor, 'query'>): Promise<unknown>;
|
|
21
|
-
terminate(input: WorkflowTerminateInput, next: Next<WorkflowClientInterceptor, 'terminate'>): Promise<TerminateWorkflowExecutionResponse>;
|
|
22
|
-
cancel(input: WorkflowCancelInput, next: Next<WorkflowClientInterceptor, 'cancel'>): Promise<RequestCancelWorkflowExecutionResponse>;
|
|
23
|
-
describe(input: WorkflowDescribeInput, next: Next<WorkflowClientInterceptor, 'describe'>): Promise<DescribeWorkflowExecutionResponse>;
|
|
24
|
-
}
|
package/lib/client/index.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.OpenTelemetryWorkflowClientInterceptor = void 0;
|
|
27
|
-
const otel = __importStar(require("@opentelemetry/api"));
|
|
28
|
-
const instrumentation_1 = require("../instrumentation");
|
|
29
|
-
const definitions_1 = require("../workflow/definitions");
|
|
30
|
-
/**
|
|
31
|
-
* Intercepts calls to start a Workflow.
|
|
32
|
-
*
|
|
33
|
-
* Wraps the operation in an opentelemetry Span and passes it to the Workflow via headers.
|
|
34
|
-
*/
|
|
35
|
-
class OpenTelemetryWorkflowClientInterceptor {
|
|
36
|
-
tracer;
|
|
37
|
-
constructor(options) {
|
|
38
|
-
this.tracer = options?.tracer ?? otel.trace.getTracer('@temporalio/interceptor-client');
|
|
39
|
-
}
|
|
40
|
-
async start(input, next) {
|
|
41
|
-
return await (0, instrumentation_1.instrument)({
|
|
42
|
-
tracer: this.tracer,
|
|
43
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
44
|
-
fn: async (span) => {
|
|
45
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
46
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
47
|
-
const runId = await next({ ...input, headers });
|
|
48
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, runId);
|
|
49
|
-
return runId;
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
async signal(input, next) {
|
|
54
|
-
return await (0, instrumentation_1.instrument)({
|
|
55
|
-
tracer: this.tracer,
|
|
56
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL}${definitions_1.SPAN_DELIMITER}${input.signalName}`,
|
|
57
|
-
fn: async (span) => {
|
|
58
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
59
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
60
|
-
await next({ ...input, headers });
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async startWithDetails(input, next) {
|
|
65
|
-
return await (0, instrumentation_1.instrument)({
|
|
66
|
-
tracer: this.tracer,
|
|
67
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
68
|
-
fn: async (span) => {
|
|
69
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
70
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
71
|
-
const output = await next({ ...input, headers });
|
|
72
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, output.runId);
|
|
73
|
-
return output;
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async startUpdate(input, next) {
|
|
78
|
-
return await (0, instrumentation_1.instrument)({
|
|
79
|
-
tracer: this.tracer,
|
|
80
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_START_UPDATE}${definitions_1.SPAN_DELIMITER}${input.updateName}`,
|
|
81
|
-
fn: async (span) => {
|
|
82
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
83
|
-
if (input.options.updateId) {
|
|
84
|
-
span.setAttribute(instrumentation_1.UPDATE_ID_ATTR_KEY, input.options.updateId);
|
|
85
|
-
}
|
|
86
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
87
|
-
const output = await next({ ...input, headers });
|
|
88
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, output.workflowRunId);
|
|
89
|
-
return output;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
async startUpdateWithStart(input, next) {
|
|
94
|
-
return await (0, instrumentation_1.instrument)({
|
|
95
|
-
tracer: this.tracer,
|
|
96
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_UPDATE_WITH_START}${definitions_1.SPAN_DELIMITER}${input.updateName}`,
|
|
97
|
-
fn: async (span) => {
|
|
98
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowStartOptions.workflowId);
|
|
99
|
-
if (input.updateOptions.updateId) {
|
|
100
|
-
span.setAttribute(instrumentation_1.UPDATE_ID_ATTR_KEY, input.updateOptions.updateId);
|
|
101
|
-
}
|
|
102
|
-
const workflowStartHeaders = (0, instrumentation_1.headersWithContext)(input.workflowStartHeaders);
|
|
103
|
-
const updateHeaders = (0, instrumentation_1.headersWithContext)(input.updateHeaders);
|
|
104
|
-
const output = await next({ ...input, workflowStartHeaders, updateHeaders });
|
|
105
|
-
if (output.workflowExecution.runId) {
|
|
106
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, output.workflowExecution.runId);
|
|
107
|
-
}
|
|
108
|
-
return output;
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
async signalWithStart(input, next) {
|
|
113
|
-
return await (0, instrumentation_1.instrument)({
|
|
114
|
-
tracer: this.tracer,
|
|
115
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_SIGNAL_WITH_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
116
|
-
fn: async (span) => {
|
|
117
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.options.workflowId);
|
|
118
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
119
|
-
const runId = await next({ ...input, headers });
|
|
120
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, runId);
|
|
121
|
-
return runId;
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
async query(input, next) {
|
|
126
|
-
return await (0, instrumentation_1.instrument)({
|
|
127
|
-
tracer: this.tracer,
|
|
128
|
-
spanName: `${definitions_1.SpanName.WORKFLOW_QUERY}${definitions_1.SPAN_DELIMITER}${input.queryType}`,
|
|
129
|
-
fn: async (span) => {
|
|
130
|
-
const headers = (0, instrumentation_1.headersWithContext)(input.headers);
|
|
131
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
132
|
-
if (input.workflowExecution.runId) {
|
|
133
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, input.workflowExecution.runId);
|
|
134
|
-
}
|
|
135
|
-
return await next({ ...input, headers });
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
async terminate(input, next) {
|
|
140
|
-
return await (0, instrumentation_1.instrument)({
|
|
141
|
-
tracer: this.tracer,
|
|
142
|
-
spanName: definitions_1.SpanName.WORKFLOW_TERMINATE,
|
|
143
|
-
fn: async (span) => {
|
|
144
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
145
|
-
if (input.workflowExecution.runId) {
|
|
146
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, input.workflowExecution.runId);
|
|
147
|
-
}
|
|
148
|
-
if (input.reason) {
|
|
149
|
-
span.setAttribute(instrumentation_1.TERMINATE_REASON_ATTR_KEY, input.reason);
|
|
150
|
-
}
|
|
151
|
-
return await next(input);
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
async cancel(input, next) {
|
|
156
|
-
return await (0, instrumentation_1.instrument)({
|
|
157
|
-
tracer: this.tracer,
|
|
158
|
-
spanName: definitions_1.SpanName.WORKFLOW_CANCEL,
|
|
159
|
-
fn: async (span) => {
|
|
160
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
161
|
-
if (input.workflowExecution.runId) {
|
|
162
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, input.workflowExecution.runId);
|
|
163
|
-
}
|
|
164
|
-
return await next(input);
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
async describe(input, next) {
|
|
169
|
-
return await (0, instrumentation_1.instrument)({
|
|
170
|
-
tracer: this.tracer,
|
|
171
|
-
spanName: definitions_1.SpanName.WORKFLOW_DESCRIBE,
|
|
172
|
-
fn: async (span) => {
|
|
173
|
-
span.setAttribute(instrumentation_1.WORKFLOW_ID_ATTR_KEY, input.workflowExecution.workflowId);
|
|
174
|
-
if (input.workflowExecution.runId) {
|
|
175
|
-
span.setAttribute(instrumentation_1.RUN_ID_ATTR_KEY, input.workflowExecution.runId);
|
|
176
|
-
}
|
|
177
|
-
return await next(input);
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
exports.OpenTelemetryWorkflowClientInterceptor = OpenTelemetryWorkflowClientInterceptor;
|
|
183
|
-
//# sourceMappingURL=index.js.map
|
package/lib/client/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;gBAChD,IAAI,CAAC,YAAY,CAAC,iCAAe,EAAE,KAAK,CAAC,CAAC;gBAC1C,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAA0B,EAAE,IA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.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `npm i @temporalio/interceptors-opentelemetry`
|
|
3
|
-
*
|
|
4
|
-
* Interceptors that add OpenTelemetry tracing.
|
|
5
|
-
*
|
|
6
|
-
* [Documentation](https://docs.temporal.io/typescript/logging#opentelemetry-tracing)
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
export * from './plugin';
|
|
11
|
-
export * from './workflow';
|
|
12
|
-
export * from './worker';
|
|
13
|
-
export { OpenTelemetryWorkflowClientInterceptor,
|
|
14
|
-
/** deprecated: Use OpenTelemetryWorkflowClientInterceptor instead */
|
|
15
|
-
OpenTelemetryWorkflowClientInterceptor as OpenTelemetryWorkflowClientCallsInterceptor, } from './client';
|
package/lib/index.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* `npm i @temporalio/interceptors-opentelemetry`
|
|
4
|
-
*
|
|
5
|
-
* Interceptors that add OpenTelemetry tracing.
|
|
6
|
-
*
|
|
7
|
-
* [Documentation](https://docs.temporal.io/typescript/logging#opentelemetry-tracing)
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
-
}
|
|
17
|
-
Object.defineProperty(o, k2, desc);
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.OpenTelemetryWorkflowClientCallsInterceptor = exports.OpenTelemetryWorkflowClientInterceptor = void 0;
|
|
27
|
-
__exportStar(require("./plugin"), exports);
|
|
28
|
-
__exportStar(require("./workflow"), exports);
|
|
29
|
-
__exportStar(require("./worker"), exports);
|
|
30
|
-
var client_1 = require("./client");
|
|
31
|
-
Object.defineProperty(exports, "OpenTelemetryWorkflowClientInterceptor", { enumerable: true, get: function () { return client_1.OpenTelemetryWorkflowClientInterceptor; } });
|
|
32
|
-
/** deprecated: Use OpenTelemetryWorkflowClientInterceptor instead */
|
|
33
|
-
Object.defineProperty(exports, "OpenTelemetryWorkflowClientCallsInterceptor", { enumerable: true, get: function () { return client_1.OpenTelemetryWorkflowClientInterceptor; } });
|
|
34
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,mCAIkB;AAHhB,gIAAA,sCAAsC,OAAA;AACtC,qEAAqE;AACrE,qIAAA,sCAAsC,OAA+C"}
|
package/lib/instrumentation.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* opentelemetry instrumentation helper functions
|
|
3
|
-
* @module
|
|
4
|
-
*/
|
|
5
|
-
import * as otel from '@opentelemetry/api';
|
|
6
|
-
import { type Headers } from '@temporalio/common';
|
|
7
|
-
/** Default trace header for opentelemetry interceptors */
|
|
8
|
-
export declare const TRACE_HEADER = "_tracer-data";
|
|
9
|
-
/** As in workflow run id */
|
|
10
|
-
export declare const RUN_ID_ATTR_KEY = "run_id";
|
|
11
|
-
/** As in workflow id */
|
|
12
|
-
export declare const WORKFLOW_ID_ATTR_KEY = "temporalWorkflowId";
|
|
13
|
-
/** As in activity id */
|
|
14
|
-
export declare const ACTIVITY_ID_ATTR_KEY = "temporalActivityId";
|
|
15
|
-
/** As in update id */
|
|
16
|
-
export declare const UPDATE_ID_ATTR_KEY = "temporalUpdateId";
|
|
17
|
-
/** As in termination reason */
|
|
18
|
-
export declare const TERMINATE_REASON_ATTR_KEY = "temporalTerminateReason";
|
|
19
|
-
/** As in Nexus service */
|
|
20
|
-
export declare const NEXUS_SERVICE_ATTR_KEY = "temporalNexusService";
|
|
21
|
-
/** As in Nexus operation */
|
|
22
|
-
export declare const NEXUS_OPERATION_ATTR_KEY = "temporalNexusOperation";
|
|
23
|
-
/** As in Nexus endpoint */
|
|
24
|
-
export declare const NEXUS_ENDPOINT_ATTR_KEY = "temporalNexusEndpoint";
|
|
25
|
-
/**
|
|
26
|
-
* If found, return an otel Context deserialized from the provided headers
|
|
27
|
-
*/
|
|
28
|
-
export declare function extractContextFromHeaders(headers: Headers): otel.Context | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* If found, return an otel Context deserialized from the provided Nexus headers.
|
|
31
|
-
*
|
|
32
|
-
* Nexus headers are plain `Record<string, string>`, so we extract the context
|
|
33
|
-
* directly from the string map.
|
|
34
|
-
*/
|
|
35
|
-
export declare function extractContextFromNexusHeaders(headers: Record<string, string>): otel.Context | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* Given headers, return new headers with the current otel context inserted
|
|
38
|
-
*/
|
|
39
|
-
export declare function headersWithContext(headers: Headers): Headers;
|
|
40
|
-
/**
|
|
41
|
-
* Given Nexus headers, return new headers with the current otel context injected directly
|
|
42
|
-
*/
|
|
43
|
-
export declare function nexusHeadersWithContext(headers: Record<string, string>): Record<string, string>;
|
|
44
|
-
export interface InstrumentOptions<T> {
|
|
45
|
-
tracer: otel.Tracer;
|
|
46
|
-
spanName: string;
|
|
47
|
-
fn: (span: otel.Span) => Promise<T>;
|
|
48
|
-
context?: otel.Context;
|
|
49
|
-
acceptableErrors?: (err: unknown) => boolean;
|
|
50
|
-
}
|
|
51
|
-
export type InstrumentOptionsSync<T> = Omit<InstrumentOptions<T>, 'fn'> & {
|
|
52
|
-
fn: (span: otel.Span) => T;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Wraps `fn` in a span which ends when function returns or throws
|
|
56
|
-
*/
|
|
57
|
-
export declare function instrument<T>({ tracer, spanName, fn, context, acceptableErrors, }: InstrumentOptions<T>): Promise<T>;
|
|
58
|
-
export declare function instrumentSync<T>({ tracer, spanName, fn, context, acceptableErrors }: InstrumentOptionsSync<T>): T;
|
package/lib/instrumentation.js
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.NEXUS_ENDPOINT_ATTR_KEY = exports.NEXUS_OPERATION_ATTR_KEY = exports.NEXUS_SERVICE_ATTR_KEY = exports.TERMINATE_REASON_ATTR_KEY = exports.UPDATE_ID_ATTR_KEY = exports.ACTIVITY_ID_ATTR_KEY = exports.WORKFLOW_ID_ATTR_KEY = exports.RUN_ID_ATTR_KEY = exports.TRACE_HEADER = void 0;
|
|
27
|
-
exports.extractContextFromHeaders = extractContextFromHeaders;
|
|
28
|
-
exports.extractContextFromNexusHeaders = extractContextFromNexusHeaders;
|
|
29
|
-
exports.headersWithContext = headersWithContext;
|
|
30
|
-
exports.nexusHeadersWithContext = nexusHeadersWithContext;
|
|
31
|
-
exports.instrument = instrument;
|
|
32
|
-
exports.instrumentSync = instrumentSync;
|
|
33
|
-
/**
|
|
34
|
-
* opentelemetry instrumentation helper functions
|
|
35
|
-
* @module
|
|
36
|
-
*/
|
|
37
|
-
const otel = __importStar(require("@opentelemetry/api"));
|
|
38
|
-
const common_1 = require("@temporalio/common");
|
|
39
|
-
/** Default trace header for opentelemetry interceptors */
|
|
40
|
-
exports.TRACE_HEADER = '_tracer-data';
|
|
41
|
-
/** As in workflow run id */
|
|
42
|
-
exports.RUN_ID_ATTR_KEY = 'run_id';
|
|
43
|
-
/** As in workflow id */
|
|
44
|
-
exports.WORKFLOW_ID_ATTR_KEY = 'temporalWorkflowId';
|
|
45
|
-
/** As in activity id */
|
|
46
|
-
exports.ACTIVITY_ID_ATTR_KEY = 'temporalActivityId';
|
|
47
|
-
/** As in update id */
|
|
48
|
-
exports.UPDATE_ID_ATTR_KEY = 'temporalUpdateId';
|
|
49
|
-
/** As in termination reason */
|
|
50
|
-
exports.TERMINATE_REASON_ATTR_KEY = 'temporalTerminateReason';
|
|
51
|
-
/** As in Nexus service */
|
|
52
|
-
exports.NEXUS_SERVICE_ATTR_KEY = 'temporalNexusService';
|
|
53
|
-
/** As in Nexus operation */
|
|
54
|
-
exports.NEXUS_OPERATION_ATTR_KEY = 'temporalNexusOperation';
|
|
55
|
-
/** As in Nexus endpoint */
|
|
56
|
-
exports.NEXUS_ENDPOINT_ATTR_KEY = 'temporalNexusEndpoint';
|
|
57
|
-
const payloadConverter = common_1.defaultPayloadConverter;
|
|
58
|
-
/**
|
|
59
|
-
* If found, return an otel Context deserialized from the provided headers
|
|
60
|
-
*/
|
|
61
|
-
function extractContextFromHeaders(headers) {
|
|
62
|
-
const encodedSpanContext = headers[exports.TRACE_HEADER];
|
|
63
|
-
if (encodedSpanContext === undefined) {
|
|
64
|
-
return undefined;
|
|
65
|
-
}
|
|
66
|
-
const textMap = payloadConverter.fromPayload(encodedSpanContext);
|
|
67
|
-
return otel.propagation.extract(otel.context.active(), textMap, otel.defaultTextMapGetter);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* If found, return an otel Context deserialized from the provided Nexus headers.
|
|
71
|
-
*
|
|
72
|
-
* Nexus headers are plain `Record<string, string>`, so we extract the context
|
|
73
|
-
* directly from the string map.
|
|
74
|
-
*/
|
|
75
|
-
function extractContextFromNexusHeaders(headers) {
|
|
76
|
-
if (Object.keys(headers).length === 0) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
return otel.propagation.extract(otel.context.active(), headers, otel.defaultTextMapGetter);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Given headers, return new headers with the current otel context inserted
|
|
83
|
-
*/
|
|
84
|
-
function headersWithContext(headers) {
|
|
85
|
-
const carrier = {};
|
|
86
|
-
otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
|
|
87
|
-
return { ...headers, [exports.TRACE_HEADER]: payloadConverter.toPayload(carrier) };
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Given Nexus headers, return new headers with the current otel context injected directly
|
|
91
|
-
*/
|
|
92
|
-
function nexusHeadersWithContext(headers) {
|
|
93
|
-
const carrier = {};
|
|
94
|
-
otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
|
|
95
|
-
return { ...headers, ...carrier };
|
|
96
|
-
}
|
|
97
|
-
async function wrapWithSpan(span, fn, acceptableErrors) {
|
|
98
|
-
try {
|
|
99
|
-
const ret = await fn(span);
|
|
100
|
-
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
101
|
-
return ret;
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
maybeAddErrorToSpan(err, span, acceptableErrors);
|
|
105
|
-
throw err;
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
span.end();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function wrapWithSpanSync(span, fn, acceptableErrors) {
|
|
112
|
-
try {
|
|
113
|
-
const ret = fn(span);
|
|
114
|
-
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
115
|
-
return ret;
|
|
116
|
-
}
|
|
117
|
-
catch (err) {
|
|
118
|
-
maybeAddErrorToSpan(err, span, acceptableErrors);
|
|
119
|
-
throw err;
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
span.end();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function maybeAddErrorToSpan(err, span, acceptableErrors) {
|
|
126
|
-
const isBenignErr = err instanceof common_1.ApplicationFailure && err.category === common_1.ApplicationFailureCategory.BENIGN;
|
|
127
|
-
if (acceptableErrors === undefined || !acceptableErrors(err)) {
|
|
128
|
-
const statusCode = isBenignErr ? otel.SpanStatusCode.UNSET : otel.SpanStatusCode.ERROR;
|
|
129
|
-
const message = err != null && typeof err.message === 'string' ? err.message : String(err);
|
|
130
|
-
span.setStatus({ code: statusCode, message });
|
|
131
|
-
span.recordException(err);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Wraps `fn` in a span which ends when function returns or throws
|
|
139
|
-
*/
|
|
140
|
-
async function instrument({ tracer, spanName, fn, context, acceptableErrors, }) {
|
|
141
|
-
if (context) {
|
|
142
|
-
return await otel.context.with(context, async () => {
|
|
143
|
-
return await tracer.startActiveSpan(spanName, async (span) => await wrapWithSpan(span, fn, acceptableErrors));
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return await tracer.startActiveSpan(spanName, async (span) => await wrapWithSpan(span, fn, acceptableErrors));
|
|
147
|
-
}
|
|
148
|
-
function instrumentSync({ tracer, spanName, fn, context, acceptableErrors }) {
|
|
149
|
-
if (context) {
|
|
150
|
-
return otel.context.with(context, () => {
|
|
151
|
-
return tracer.startActiveSpan(spanName, (span) => wrapWithSpanSync(span, fn, acceptableErrors));
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return tracer.startActiveSpan(spanName, (span) => wrapWithSpanSync(span, fn, acceptableErrors));
|
|
155
|
-
}
|
|
156
|
-
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,8DAOC;AAQD,wEAKC;AAKD,gDAIC;AAKD,0DAIC;AA6DD,gCAaC;AAED,wCAOC;AA7JD;;;GAGG;AACH,yDAA2C;AAC3C,+CAK4B;AAE5B,0DAA0D;AAC7C,QAAA,YAAY,GAAG,cAAc,CAAC;AAC3C,4BAA4B;AACf,QAAA,eAAe,GAAG,QAAQ,CAAC;AACxC,wBAAwB;AACX,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,wBAAwB;AACX,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,sBAAsB;AACT,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;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,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAChH,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAChH,CAAC;AAED,SAAgB,cAAc,CAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAA4B;IAC7G,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;YACrC,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;QAClG,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAClG,CAAC"}
|
package/lib/plugin.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
2
|
-
import type { Resource } from '@opentelemetry/resources';
|
|
3
|
-
import { SimplePlugin } from '@temporalio/plugin';
|
|
4
|
-
import type { ReplayWorkerOptions, WorkerOptions } from '@temporalio/worker';
|
|
5
|
-
import type { InterceptorOptions } from './client';
|
|
6
|
-
/**
|
|
7
|
-
* Configuration options for {@link OpenTelemetryPlugin}.
|
|
8
|
-
*
|
|
9
|
-
* @experimental Plugins is an experimental feature; APIs may change without notice.
|
|
10
|
-
*/
|
|
11
|
-
export interface OpenTelemetryPluginOptions extends InterceptorOptions {
|
|
12
|
-
/** OpenTelemetry resource attributes to attach to exported spans */
|
|
13
|
-
readonly resource: Resource;
|
|
14
|
-
/** Exporter used to send spans to a tracing backend */
|
|
15
|
-
readonly spanProcessor: SpanProcessor;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* A plugin that adds OpenTelemetry tracing.
|
|
19
|
-
*
|
|
20
|
-
* Configures Client, Activity, and Workflow interceptors for trace propagation and injects
|
|
21
|
-
* a span exporter sink for Workflow spans.
|
|
22
|
-
*
|
|
23
|
-
* @experimental Plugins is an experimental feature; APIs may change without notice.
|
|
24
|
-
*/
|
|
25
|
-
export declare class OpenTelemetryPlugin extends SimplePlugin {
|
|
26
|
-
readonly otelOptions: OpenTelemetryPluginOptions;
|
|
27
|
-
constructor(otelOptions: OpenTelemetryPluginOptions);
|
|
28
|
-
configureWorker(options: WorkerOptions): WorkerOptions;
|
|
29
|
-
configureReplayWorker(options: ReplayWorkerOptions): ReplayWorkerOptions;
|
|
30
|
-
private injectSinks;
|
|
31
|
-
}
|