@temporalio/interceptors-opentelemetry 0.17.2 → 0.19.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/lib/client/index.d.ts +1 -3
- package/lib/client/index.js +16 -10
- package/lib/client/index.js.map +1 -1
- package/lib/instrumentation.d.ts +8 -1
- package/lib/instrumentation.js +16 -7
- package/lib/instrumentation.js.map +1 -1
- package/lib/worker/index.d.ts +1 -3
- package/lib/worker/index.js +8 -6
- package/lib/worker/index.js.map +1 -1
- package/lib/workflow/context-manager.js +5 -1
- package/lib/workflow/context-manager.js.map +1 -1
- package/lib/workflow/index.js +44 -22
- package/lib/workflow/index.js.map +1 -1
- package/lib/workflow/span-exporter.js +5 -1
- package/lib/workflow/span-exporter.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@temporalio/interceptors-opentelemetry)
|
|
4
4
|
|
|
5
|
-
[Temporal](https://temporal.io) [SDK](https://
|
|
5
|
+
[Temporal](https://temporal.io)'s [TypeScript SDK](https://docs.temporal.io/docs/typescript/introduction) interceptors bundle for tracing Workflow and Activity executions with [OpenTelemetry](https://opentelemetry.io/).
|
|
6
6
|
|
|
7
|
-
[
|
|
7
|
+
- [Interceptors docs](https://docs.temporal.io/docs/typescript/interceptors)
|
|
8
|
+
- [OpenTelemetry sample project](https://github.com/temporalio/samples-typescript/tree/main/interceptors-opentelemetry)
|
package/lib/client/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as otel from '@opentelemetry/api';
|
|
2
|
-
import {
|
|
2
|
+
import { Next, WorkflowClientCallsInterceptor, WorkflowStartInput } from '@temporalio/client';
|
|
3
3
|
export interface InterceptorOptions {
|
|
4
4
|
readonly tracer?: otel.Tracer;
|
|
5
|
-
readonly dataConverter?: DataConverter;
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
7
|
* Intercepts calls to start a Workflow.
|
|
@@ -11,7 +10,6 @@ export interface InterceptorOptions {
|
|
|
11
10
|
*/
|
|
12
11
|
export declare class OpenTelemetryWorkflowClientCallsInterceptor implements WorkflowClientCallsInterceptor {
|
|
13
12
|
protected readonly tracer: otel.Tracer;
|
|
14
|
-
protected readonly dataConverter: DataConverter;
|
|
15
13
|
constructor(options?: InterceptorOptions);
|
|
16
14
|
start(input: WorkflowStartInput, next: Next<WorkflowClientCallsInterceptor, 'start'>): Promise<string>;
|
|
17
15
|
}
|
package/lib/client/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -21,10 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
26
|
exports.OpenTelemetryWorkflowClientCallsInterceptor = void 0;
|
|
23
27
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
24
|
-
const
|
|
25
|
-
const workflow_1 = require("../workflow");
|
|
28
|
+
const otel_1 = require("@temporalio/internal-non-workflow-common/lib/otel");
|
|
26
29
|
const instrumentation_1 = require("../instrumentation");
|
|
27
|
-
const
|
|
30
|
+
const workflow_1 = require("../workflow");
|
|
28
31
|
/**
|
|
29
32
|
* Intercepts calls to start a Workflow.
|
|
30
33
|
*
|
|
@@ -32,15 +35,18 @@ const otel_1 = require("@temporalio/common/lib/otel");
|
|
|
32
35
|
*/
|
|
33
36
|
class OpenTelemetryWorkflowClientCallsInterceptor {
|
|
34
37
|
constructor(options) {
|
|
35
|
-
this.dataConverter = options?.dataConverter ?? client_1.defaultDataConverter;
|
|
36
38
|
this.tracer = options?.tracer ?? otel.trace.getTracer('@temporalio/interceptor-client');
|
|
37
39
|
}
|
|
38
40
|
async start(input, next) {
|
|
39
|
-
return await (0, instrumentation_1.instrument)(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
span
|
|
43
|
-
|
|
41
|
+
return await (0, instrumentation_1.instrument)({
|
|
42
|
+
tracer: this.tracer,
|
|
43
|
+
spanName: `${workflow_1.SpanName.WORKFLOW_START}${workflow_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
44
|
+
fn: async (span) => {
|
|
45
|
+
const headers = await (0, otel_1.headersWithContext)(input.headers);
|
|
46
|
+
const runId = await next({ ...input, headers });
|
|
47
|
+
span.setAttribute(otel_1.RUN_ID_ATTR_KEY, runId);
|
|
48
|
+
return runId;
|
|
49
|
+
},
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
}
|
package/lib/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAE3C,4EAAwG;AACxG,wDAAgD;AAChD,0CAAuD;AAMvD;;;;GAIG;AACH,MAAa,2CAA2C;IAGtD,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,IAAmD;QACxF,OAAO,MAAM,IAAA,4BAAU,EAAC;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,GAAG,mBAAQ,CAAC,cAAc,GAAG,yBAAc,GAAG,KAAK,CAAC,YAAY,EAAE;YAC5E,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACjB,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAkB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;gBAChD,IAAI,CAAC,YAAY,CAAC,sBAAe,EAAE,KAAK,CAAC,CAAC;gBAC1C,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,kGAmBC"}
|
package/lib/instrumentation.d.ts
CHANGED
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
* @module
|
|
4
4
|
*/
|
|
5
5
|
import * as otel from '@opentelemetry/api';
|
|
6
|
+
export interface InstrumentOptions<T> {
|
|
7
|
+
tracer: otel.Tracer;
|
|
8
|
+
spanName: string;
|
|
9
|
+
fn: (span: otel.Span) => Promise<T>;
|
|
10
|
+
context?: otel.Context;
|
|
11
|
+
acceptableErrors?: (err: unknown) => boolean;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* Wraps `fn` in a span which ends when function returns or throws
|
|
8
15
|
*/
|
|
9
|
-
export declare function instrument<T>(tracer
|
|
16
|
+
export declare function instrument<T>({ tracer, spanName, fn, context, acceptableErrors, }: InstrumentOptions<T>): Promise<T>;
|
package/lib/instrumentation.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,15 +29,20 @@ exports.instrument = void 0;
|
|
|
25
29
|
* @module
|
|
26
30
|
*/
|
|
27
31
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
28
|
-
async function wrapWithSpan(span, fn) {
|
|
32
|
+
async function wrapWithSpan(span, fn, acceptableErrors) {
|
|
29
33
|
try {
|
|
30
34
|
const ret = await fn(span);
|
|
31
35
|
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
32
36
|
return ret;
|
|
33
37
|
}
|
|
34
38
|
catch (err) {
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
if (acceptableErrors === undefined || !acceptableErrors(err)) {
|
|
40
|
+
span.setStatus({ code: otel.SpanStatusCode.ERROR });
|
|
41
|
+
span.recordException(err);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
span.setStatus({ code: otel.SpanStatusCode.OK });
|
|
45
|
+
}
|
|
37
46
|
throw err;
|
|
38
47
|
}
|
|
39
48
|
finally {
|
|
@@ -43,13 +52,13 @@ async function wrapWithSpan(span, fn) {
|
|
|
43
52
|
/**
|
|
44
53
|
* Wraps `fn` in a span which ends when function returns or throws
|
|
45
54
|
*/
|
|
46
|
-
async function instrument(tracer,
|
|
55
|
+
async function instrument({ tracer, spanName, fn, context, acceptableErrors, }) {
|
|
47
56
|
if (context) {
|
|
48
57
|
return await otel.context.with(context, async () => {
|
|
49
|
-
return await tracer.startActiveSpan(
|
|
58
|
+
return await tracer.startActiveSpan(spanName, async (span) => await wrapWithSpan(span, fn, acceptableErrors));
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
|
-
return await tracer.startActiveSpan(
|
|
61
|
+
return await tracer.startActiveSpan(spanName, async (span) => await wrapWithSpan(span, fn, acceptableErrors));
|
|
53
62
|
}
|
|
54
63
|
exports.instrument = instrument;
|
|
55
64
|
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../src/instrumentation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;GAGG;AACH,yDAA2C;AAE3C,KAAK,UAAU,YAAY,CACzB,IAAe,EACf,EAAmC,EACnC,gBAA4C;IAE5C,IAAI;QACF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,gBAAgB,KAAK,SAAS,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE;YAC5D,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC;YACpD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;SAC3B;aAAM;YACL,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,CAAC,CAAC;SAClD;QACD,MAAM,GAAG,CAAC;KACX;YAAS;QACR,IAAI,CAAC,GAAG,EAAE,CAAC;KACZ;AACH,CAAC;AASD;;GAEG;AACI,KAAK,UAAU,UAAU,CAAI,EAClC,MAAM,EACN,QAAQ,EACR,EAAE,EACF,OAAO,EACP,gBAAgB,GACK;IACrB,IAAI,OAAO,EAAE;QACX,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;YACjD,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;QAChH,CAAC,CAAC,CAAC;KACJ;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;AAbD,gCAaC"}
|
package/lib/worker/index.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ import * as otel from '@opentelemetry/api';
|
|
|
2
2
|
import { Resource } from '@opentelemetry/resources';
|
|
3
3
|
import { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
4
4
|
import { Context as ActivityContext } from '@temporalio/activity';
|
|
5
|
-
import { ActivityExecuteInput, ActivityInboundCallsInterceptor,
|
|
5
|
+
import { ActivityExecuteInput, ActivityInboundCallsInterceptor, InjectedSink, Next } from '@temporalio/worker';
|
|
6
6
|
import { OpenTelemetryWorkflowExporter } from '../workflow';
|
|
7
7
|
export interface InterceptorOptions {
|
|
8
8
|
readonly tracer?: otel.Tracer;
|
|
9
|
-
readonly dataConverter?: DataConverter;
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
11
|
* Intercepts calls to start an Activity.
|
|
@@ -17,7 +16,6 @@ export interface InterceptorOptions {
|
|
|
17
16
|
export declare class OpenTelemetryActivityInboundInterceptor implements ActivityInboundCallsInterceptor {
|
|
18
17
|
protected readonly ctx: ActivityContext;
|
|
19
18
|
protected readonly tracer: otel.Tracer;
|
|
20
|
-
protected readonly dataConverter: DataConverter;
|
|
21
19
|
constructor(ctx: ActivityContext, options?: InterceptorOptions);
|
|
22
20
|
execute(input: ActivityExecuteInput, next: Next<ActivityInboundCallsInterceptor, 'execute'>): Promise<unknown>;
|
|
23
21
|
}
|
package/lib/worker/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -21,10 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
21
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
26
|
exports.makeWorkflowExporter = exports.OpenTelemetryActivityInboundInterceptor = void 0;
|
|
23
27
|
const otel = __importStar(require("@opentelemetry/api"));
|
|
24
|
-
const otel_1 = require("@temporalio/common/lib/otel");
|
|
25
|
-
const worker_1 = require("@temporalio/worker");
|
|
26
|
-
const workflow_1 = require("../workflow");
|
|
28
|
+
const otel_1 = require("@temporalio/internal-non-workflow-common/lib/otel");
|
|
27
29
|
const instrumentation_1 = require("../instrumentation");
|
|
30
|
+
const workflow_1 = require("../workflow");
|
|
28
31
|
/**
|
|
29
32
|
* Intercepts calls to start an Activity.
|
|
30
33
|
*
|
|
@@ -34,13 +37,12 @@ const instrumentation_1 = require("../instrumentation");
|
|
|
34
37
|
class OpenTelemetryActivityInboundInterceptor {
|
|
35
38
|
constructor(ctx, options) {
|
|
36
39
|
this.ctx = ctx;
|
|
37
|
-
this.dataConverter = options?.dataConverter ?? worker_1.defaultDataConverter;
|
|
38
40
|
this.tracer = options?.tracer ?? otel.trace.getTracer('@temporalio/interceptor-activity');
|
|
39
41
|
}
|
|
40
42
|
async execute(input, next) {
|
|
41
43
|
const context = await (0, otel_1.extractContextFromHeaders)(input.headers);
|
|
42
44
|
const spanName = `${workflow_1.SpanName.ACTIVITY_EXECUTE}${workflow_1.SPAN_DELIMITER}${this.ctx.info.activityType}`;
|
|
43
|
-
return await (0, instrumentation_1.instrument)(this.tracer, spanName, () => next(input), context);
|
|
45
|
+
return await (0, instrumentation_1.instrument)({ tracer: this.tracer, spanName, fn: () => next(input), context });
|
|
44
46
|
}
|
|
45
47
|
}
|
|
46
48
|
exports.OpenTelemetryActivityInboundInterceptor = OpenTelemetryActivityInboundInterceptor;
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAI3C,4EAA8F;AAE9F,wDAAgD;AAChD,0CAAwG;AAMxG;;;;;GAKG;AACH,MAAa,uCAAuC;IAGlD,YAA+B,GAAoB,EAAE,OAA4B;QAAlD,QAAG,GAAH,GAAG,CAAiB;QACjD,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,MAAM,IAAA,gCAAyB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAG,GAAG,mBAAQ,CAAC,gBAAgB,GAAG,yBAAc,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QAC9F,OAAO,MAAM,IAAA,4BAAU,EAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAC7F,CAAC;CACF;AAZD,0FAYC;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;AAjBD,oDAiBC;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,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAC3C,mDAAyD;AAEzD,MAAa,cAAc;IAA3B;QACY,YAAO,GAAG,IAAI,4BAAiB,EAAgB,CAAC;IA+C5D,CAAC;IA7CC,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;YAChC,MAAM,IAAI,SAAS,CAAC,2CAA2C,OAAO,MAAM,EAAE,CAAC,CAAC;SACjF;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;AAhDD,wCAgDC"}
|
package/lib/workflow/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -25,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
25
29
|
exports.OpenTelemetryInternalsInterceptor = exports.OpenTelemetryOutboundInterceptor = exports.OpenTelemetryInboundInterceptor = void 0;
|
|
26
30
|
require("./runtime"); // Patch the Workflow isolate runtime for opentelemetry
|
|
27
31
|
const workflow_1 = require("@temporalio/workflow");
|
|
28
|
-
const otel_1 = require("@temporalio/common/lib/otel");
|
|
32
|
+
const otel_1 = require("@temporalio/internal-non-workflow-common/lib/otel");
|
|
29
33
|
const context_manager_1 = require("./context-manager");
|
|
30
34
|
const span_exporter_1 = require("./span-exporter");
|
|
31
35
|
const definitions_1 = require("./definitions");
|
|
@@ -58,8 +62,13 @@ class OpenTelemetryInboundInterceptor {
|
|
|
58
62
|
}
|
|
59
63
|
async execute(input, next) {
|
|
60
64
|
const context = await (0, otel_1.extractContextFromHeaders)(input.headers);
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
return await (0, instrumentation_1.instrument)({
|
|
66
|
+
tracer: this.tracer,
|
|
67
|
+
spanName: `${definitions_1.SpanName.WORKFLOW_EXECUTE}${definitions_1.SPAN_DELIMITER}${(0, workflow_1.workflowInfo)().workflowType}`,
|
|
68
|
+
fn: () => next(input),
|
|
69
|
+
context,
|
|
70
|
+
acceptableErrors: (err) => err instanceof workflow_1.ContinueAsNew,
|
|
71
|
+
});
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
exports.OpenTelemetryInboundInterceptor = OpenTelemetryInboundInterceptor;
|
|
@@ -73,30 +82,43 @@ class OpenTelemetryOutboundInterceptor {
|
|
|
73
82
|
this.tracer = getTracer();
|
|
74
83
|
}
|
|
75
84
|
async scheduleActivity(input, next) {
|
|
76
|
-
return await (0, instrumentation_1.instrument)(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
headers,
|
|
81
|
-
|
|
85
|
+
return await (0, instrumentation_1.instrument)({
|
|
86
|
+
tracer: this.tracer,
|
|
87
|
+
spanName: `${definitions_1.SpanName.ACTIVITY_START}${definitions_1.SPAN_DELIMITER}${input.activityType}`,
|
|
88
|
+
fn: async () => {
|
|
89
|
+
const headers = await (0, otel_1.headersWithContext)(input.headers);
|
|
90
|
+
return next({
|
|
91
|
+
...input,
|
|
92
|
+
headers,
|
|
93
|
+
});
|
|
94
|
+
},
|
|
82
95
|
});
|
|
83
96
|
}
|
|
84
97
|
async startChildWorkflowExecution(input, next) {
|
|
85
|
-
return await (0, instrumentation_1.instrument)(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
headers,
|
|
90
|
-
|
|
98
|
+
return await (0, instrumentation_1.instrument)({
|
|
99
|
+
tracer: this.tracer,
|
|
100
|
+
spanName: `${definitions_1.SpanName.CHILD_WORKFLOW_START}${definitions_1.SPAN_DELIMITER}${input.workflowType}`,
|
|
101
|
+
fn: async () => {
|
|
102
|
+
const headers = await (0, otel_1.headersWithContext)(input.headers);
|
|
103
|
+
return next({
|
|
104
|
+
...input,
|
|
105
|
+
headers,
|
|
106
|
+
});
|
|
107
|
+
},
|
|
91
108
|
});
|
|
92
109
|
}
|
|
93
110
|
async continueAsNew(input, next) {
|
|
94
|
-
return await (0, instrumentation_1.instrument)(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
headers,
|
|
99
|
-
|
|
111
|
+
return await (0, instrumentation_1.instrument)({
|
|
112
|
+
tracer: this.tracer,
|
|
113
|
+
spanName: `${definitions_1.SpanName.CONTINUE_AS_NEW}${definitions_1.SPAN_DELIMITER}${input.options.workflowType}`,
|
|
114
|
+
fn: async () => {
|
|
115
|
+
const headers = await (0, otel_1.headersWithContext)(input.headers);
|
|
116
|
+
return next({
|
|
117
|
+
...input,
|
|
118
|
+
headers,
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
acceptableErrors: (err) => err instanceof workflow_1.ContinueAsNew,
|
|
100
122
|
});
|
|
101
123
|
}
|
|
102
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qBAAmB,CAAC,uDAAuD;AAE3E,mDAY8B;AAC9B,4E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AAE,EAAE,KAAK,IAAI,EAAE;gBACb,MAAM,OAAO,GAAG,MAAM,IAAA,yBAAkB,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBACxD,OAAO,IAAI,CAAC;oBACV,GAAG,KAAK;oBACR,OAAO;iBACR,CAAC,CAAC;YACL,CAAC;YACD,gBAAgB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,YAAY,wBAAa;SACxD,CAAC,CAAC;IACL,CAAC;CACF;AAtDD,4EAsDC;AAED,MAAa,iCAAiC;IAC5C,KAAK,CAAC,OAAO,CAAC,KAAmB,EAAE,IAAmD;QACpF,IAAI,cAAc,KAAK,SAAS,EAAE;YAChC,cAAc,CAAC,OAAO,EAAE,CAAC;SAC1B;QACD,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC;IACpB,CAAC;CACF;AAPD,8EAOC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span-exporter.js","sourceRoot":"","sources":["../../src/workflow/span-exporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"span-exporter.js","sourceRoot":"","sources":["../../src/workflow/span-exporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,8CAAqE;AACrE,yDAA2C;AAG3C,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,UAAU,EAAsB,CAAC;AAEzD,MAAa,YAAY;IAChB,MAAM,CAAC,KAA6B,EAAE,cAA8C;QACzF,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClE,cAAc,CAAC,EAAE,IAAI,EAAE,uBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,uBAAuB;IACzB,CAAC;IAEM,gBAAgB,CAAC,IAA0B;QAChD,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE;YAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;SACpD,CAAC;IACJ,CAAC;CACF;AA3BD,oCA2BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/interceptors-opentelemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0-rc.1",
|
|
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",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"@opentelemetry/core": "^1.0.0",
|
|
19
19
|
"@opentelemetry/resources": "^1.0.0",
|
|
20
20
|
"@opentelemetry/sdk-trace-base": "^1.0.0",
|
|
21
|
-
"@temporalio/client": "^0.
|
|
22
|
-
"@temporalio/common": "^0.
|
|
23
|
-
"@temporalio/worker": "^0.
|
|
24
|
-
"@temporalio/workflow": "^0.
|
|
21
|
+
"@temporalio/client": "^0.19.0-rc.1",
|
|
22
|
+
"@temporalio/common": "^0.19.0-rc.1",
|
|
23
|
+
"@temporalio/worker": "^0.19.0-rc.1",
|
|
24
|
+
"@temporalio/workflow": "^0.19.0-rc.1"
|
|
25
25
|
},
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/temporalio/sdk-typescript/issues"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "186341ed7285e468c145121433f2c239e53934a6"
|
|
37
37
|
}
|