@temporalio/common 1.9.1 → 1.9.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 +3 -3
- package/lib/otel.d.ts +0 -26
- package/lib/otel.js +0 -87
- package/lib/otel.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/common",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Common library for code that's used across the Client, Worker, and/or Workflow",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "Temporal Technologies Inc. <sdk@temporal.io>",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@temporalio/proto": "1.9.
|
|
15
|
+
"@temporalio/proto": "1.9.3",
|
|
16
16
|
"long": "^5.2.3",
|
|
17
17
|
"ms": "^3.0.0-canary.1",
|
|
18
18
|
"proto3-json-serializer": "^2.0.0"
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"src",
|
|
37
37
|
"lib"
|
|
38
38
|
],
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e7e46639c1ba23b86f367a051fb54d736c5f21ce"
|
|
40
40
|
}
|
package/lib/otel.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as otel from '@opentelemetry/api';
|
|
2
|
-
import { Headers } from './interceptors';
|
|
3
|
-
/** Default trace header for opentelemetry interceptors */
|
|
4
|
-
export declare const TRACE_HEADER = "_tracer-data";
|
|
5
|
-
/** As in workflow run id */
|
|
6
|
-
export declare const RUN_ID_ATTR_KEY = "run_id";
|
|
7
|
-
/** For a workflow or activity task */
|
|
8
|
-
export declare const TASK_TOKEN_ATTR_KEY = "task_token";
|
|
9
|
-
/** Number of jobs in a workflow activation */
|
|
10
|
-
export declare const NUM_JOBS_ATTR_KEY = "num_jobs";
|
|
11
|
-
/**
|
|
12
|
-
* If found, return an otel Context deserialized from the provided headers
|
|
13
|
-
*/
|
|
14
|
-
export declare function extractContextFromHeaders(headers: Headers): Promise<otel.Context | undefined>;
|
|
15
|
-
/**
|
|
16
|
-
* If found, return an otel SpanContext deserialized from the provided headers
|
|
17
|
-
*/
|
|
18
|
-
export declare function extractSpanContextFromHeaders(headers: Headers): Promise<otel.SpanContext | undefined>;
|
|
19
|
-
/**
|
|
20
|
-
* Given headers, return new headers with the current otel context inserted
|
|
21
|
-
*/
|
|
22
|
-
export declare function headersWithContext(headers: Headers): Promise<Headers>;
|
|
23
|
-
/**
|
|
24
|
-
* Link a span to an maybe-existing span context
|
|
25
|
-
*/
|
|
26
|
-
export declare function linkSpans(fromSpan: otel.Span, toContext?: otel.SpanContext): void;
|
package/lib/otel.js
DELETED
|
@@ -1,87 +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.linkSpans = exports.headersWithContext = exports.extractSpanContextFromHeaders = exports.extractContextFromHeaders = exports.NUM_JOBS_ATTR_KEY = exports.TASK_TOKEN_ATTR_KEY = exports.RUN_ID_ATTR_KEY = exports.TRACE_HEADER = void 0;
|
|
27
|
-
const otel = __importStar(require("@opentelemetry/api"));
|
|
28
|
-
const payload_converter_1 = require("./converter/payload-converter");
|
|
29
|
-
/** Default trace header for opentelemetry interceptors */
|
|
30
|
-
exports.TRACE_HEADER = '_tracer-data';
|
|
31
|
-
/** As in workflow run id */
|
|
32
|
-
exports.RUN_ID_ATTR_KEY = 'run_id';
|
|
33
|
-
/** For a workflow or activity task */
|
|
34
|
-
exports.TASK_TOKEN_ATTR_KEY = 'task_token';
|
|
35
|
-
/** Number of jobs in a workflow activation */
|
|
36
|
-
exports.NUM_JOBS_ATTR_KEY = 'num_jobs';
|
|
37
|
-
const payloadConverter = payload_converter_1.defaultPayloadConverter;
|
|
38
|
-
/**
|
|
39
|
-
* If found, return an otel Context deserialized from the provided headers
|
|
40
|
-
*/
|
|
41
|
-
async function extractContextFromHeaders(headers) {
|
|
42
|
-
const encodedSpanContext = headers[exports.TRACE_HEADER];
|
|
43
|
-
if (encodedSpanContext === undefined) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
const textMap = payloadConverter.fromPayload(encodedSpanContext);
|
|
47
|
-
return otel.propagation.extract(otel.context.active(), textMap, otel.defaultTextMapGetter);
|
|
48
|
-
}
|
|
49
|
-
exports.extractContextFromHeaders = extractContextFromHeaders;
|
|
50
|
-
/**
|
|
51
|
-
* If found, return an otel SpanContext deserialized from the provided headers
|
|
52
|
-
*/
|
|
53
|
-
async function extractSpanContextFromHeaders(headers) {
|
|
54
|
-
const context = await extractContextFromHeaders(headers);
|
|
55
|
-
if (context === undefined) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
return otel.trace.getSpanContext(context);
|
|
59
|
-
}
|
|
60
|
-
exports.extractSpanContextFromHeaders = extractSpanContextFromHeaders;
|
|
61
|
-
/**
|
|
62
|
-
* Given headers, return new headers with the current otel context inserted
|
|
63
|
-
*/
|
|
64
|
-
async function headersWithContext(headers) {
|
|
65
|
-
const carrier = {};
|
|
66
|
-
otel.propagation.inject(otel.context.active(), carrier, otel.defaultTextMapSetter);
|
|
67
|
-
return { ...headers, [exports.TRACE_HEADER]: payloadConverter.toPayload(carrier) };
|
|
68
|
-
}
|
|
69
|
-
exports.headersWithContext = headersWithContext;
|
|
70
|
-
/**
|
|
71
|
-
* Link a span to an maybe-existing span context
|
|
72
|
-
*/
|
|
73
|
-
function linkSpans(fromSpan, toContext) {
|
|
74
|
-
if (toContext !== undefined) {
|
|
75
|
-
// TODO: I have to go around typescript because otel api 😢
|
|
76
|
-
// See https://github.com/open-telemetry/opentelemetry-js-api/issues/124
|
|
77
|
-
const links = fromSpan.links;
|
|
78
|
-
if (links === undefined) {
|
|
79
|
-
fromSpan.links = [{ context: toContext }];
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
links.push({ context: toContext });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.linkSpans = linkSpans;
|
|
87
|
-
//# sourceMappingURL=otel.js.map
|
package/lib/otel.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otel.js","sourceRoot":"","sources":["../src/otel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAE3C,qEAAwE;AAExE,0DAA0D;AAC7C,QAAA,YAAY,GAAG,cAAc,CAAC;AAC3C,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