@uoa/lambda-tracing 2.0.0-beta.2 → 2.0.0-beta.4
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 +2 -3
- package/zipkin/zipkin.ts +11 -25
- package/dist/UoaB3Propagator.d.ts +0 -20
- package/dist/UoaB3Propagator.js +0 -142
- package/dist/logging.d.ts +0 -1
- package/dist/logging.js +0 -70
- package/dist/tracing.d.ts +0 -3
- package/dist/tracing.js +0 -53
- package/dist/uoaHttps.d.ts +0 -1
- package/dist/uoaHttps.js +0 -222
- package/dist/zipkin/platform/index.d.ts +0 -4
- package/dist/zipkin/platform/index.js +0 -35
- package/dist/zipkin/platform/node/index.d.ts +0 -4
- package/dist/zipkin/platform/node/index.js +0 -35
- package/dist/zipkin/platform/node/util.d.ts +0 -8
- package/dist/zipkin/platform/node/util.js +0 -105
- package/dist/zipkin/transform.d.ts +0 -22
- package/dist/zipkin/transform.js +0 -112
- package/dist/zipkin/types.d.ts +0 -160
- package/dist/zipkin/types.js +0 -47
- package/dist/zipkin/utils.d.ts +0 -5
- package/dist/zipkin/utils.js +0 -24
- package/dist/zipkin/zipkin.d.ts +0 -37
- package/dist/zipkin/zipkin.js +0 -124
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uoa/lambda-tracing",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.4",
|
|
4
4
|
"description": "Library for logging & distributed tracing in UoA Lambda projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,7 @@
|
|
|
25
25
|
".": "./dist/tracing.js",
|
|
26
26
|
"./tracing": "./dist/tracing.js",
|
|
27
27
|
"./uoaHttps": "./dist/uoaHttps.js",
|
|
28
|
-
"./logging": "./dist/logging.js"
|
|
29
|
-
"./zipkin/zipkin": "./dist/zipkin/zipkin.js"
|
|
28
|
+
"./logging": "./dist/logging.js"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
31
|
"@opentelemetry/api": "^1.1.0",
|
package/zipkin/zipkin.ts
CHANGED
|
@@ -61,7 +61,6 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
61
61
|
// noop
|
|
62
62
|
this._beforeSend = function () {};
|
|
63
63
|
}
|
|
64
|
-
console.log('zipkin constructor serviceName: ', this._serviceName);
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
/**
|
|
@@ -76,10 +75,6 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
76
75
|
spans[0].resource.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
|
|
77
76
|
this.DEFAULT_SERVICE_NAME
|
|
78
77
|
);
|
|
79
|
-
console.log('zipkin export serviceName: ', serviceName);
|
|
80
|
-
console.log('zipkin export this._serviceName: ', this._serviceName);
|
|
81
|
-
console.log('zipkin export [SERVICE_NAME]: ', spans[0].resource.attributes[SemanticResourceAttributes.SERVICE_NAME]);
|
|
82
|
-
console.log('zipkin export DEFAULT_SERVICE_NAME: ', this.DEFAULT_SERVICE_NAME);
|
|
83
78
|
|
|
84
79
|
diag.debug('Zipkin exporter export');
|
|
85
80
|
if (this._isShutdown) {
|
|
@@ -140,26 +135,17 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
140
135
|
serviceName: string,
|
|
141
136
|
done?: (result: ExportResult) => void
|
|
142
137
|
) {
|
|
143
|
-
const zipkinSpans = spans.map(span =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
String(
|
|
155
|
-
serviceName ||
|
|
156
|
-
span.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
|
|
157
|
-
span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME]
|
|
158
|
-
),
|
|
159
|
-
this._statusCodeTagName,
|
|
160
|
-
this._statusDescriptionTagName
|
|
161
|
-
)
|
|
162
|
-
}
|
|
138
|
+
const zipkinSpans = spans.map(span =>
|
|
139
|
+
toZipkinSpan(
|
|
140
|
+
span,
|
|
141
|
+
String(
|
|
142
|
+
serviceName ||
|
|
143
|
+
span.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
|
|
144
|
+
span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME]
|
|
145
|
+
),
|
|
146
|
+
this._statusCodeTagName,
|
|
147
|
+
this._statusDescriptionTagName
|
|
148
|
+
)
|
|
163
149
|
);
|
|
164
150
|
this._beforeSend();
|
|
165
151
|
return this._send(zipkinSpans, (result: ExportResult) => {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class extended from OpenTelemetry B3MultiPropagator so that we can propagate & log the X-B3-Info header
|
|
3
|
-
*
|
|
4
|
-
* See {@link https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-propagator-b3/src/B3MultiPropagator.ts}
|
|
5
|
-
*/
|
|
6
|
-
import { Context, TextMapGetter, TextMapPropagator, TextMapSetter } from '@opentelemetry/api';
|
|
7
|
-
export declare const X_B3_TRACE_ID = "x-b3-traceid";
|
|
8
|
-
export declare const X_B3_SPAN_ID = "x-b3-spanid";
|
|
9
|
-
export declare const X_B3_SAMPLED = "x-b3-sampled";
|
|
10
|
-
export declare const X_B3_PARENT_SPAN_ID = "x-b3-parentspanid";
|
|
11
|
-
export declare const X_B3_FLAGS = "x-b3-flags";
|
|
12
|
-
export declare const X_B3_INFO = "x-b3-info";
|
|
13
|
-
export declare const B3_DEBUG_FLAG_KEY: symbol;
|
|
14
|
-
export declare const B3_INFO_KEY: symbol;
|
|
15
|
-
export declare const B3_TRACE_ID_LENGTH_KEY: symbol;
|
|
16
|
-
export declare class UoaB3Propagator implements TextMapPropagator {
|
|
17
|
-
inject(context: Context, carrier: any, setter: TextMapSetter<any>): void;
|
|
18
|
-
extract(context: Context, carrier: any, getter: TextMapGetter<any>): Context;
|
|
19
|
-
fields(): string[];
|
|
20
|
-
}
|
package/dist/UoaB3Propagator.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UoaB3Propagator = exports.B3_TRACE_ID_LENGTH_KEY = exports.B3_INFO_KEY = exports.B3_DEBUG_FLAG_KEY = exports.X_B3_INFO = exports.X_B3_FLAGS = exports.X_B3_PARENT_SPAN_ID = exports.X_B3_SAMPLED = exports.X_B3_SPAN_ID = exports.X_B3_TRACE_ID = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Class extended from OpenTelemetry B3MultiPropagator so that we can propagate & log the X-B3-Info header
|
|
6
|
-
*
|
|
7
|
-
* See {@link https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-propagator-b3/src/B3MultiPropagator.ts}
|
|
8
|
-
*/
|
|
9
|
-
const api_1 = require("@opentelemetry/api");
|
|
10
|
-
const core_1 = require("@opentelemetry/core");
|
|
11
|
-
const tracing_1 = require("./tracing");
|
|
12
|
-
const crypto = require('crypto');
|
|
13
|
-
exports.X_B3_TRACE_ID = 'x-b3-traceid';
|
|
14
|
-
exports.X_B3_SPAN_ID = 'x-b3-spanid';
|
|
15
|
-
exports.X_B3_SAMPLED = 'x-b3-sampled';
|
|
16
|
-
exports.X_B3_PARENT_SPAN_ID = 'x-b3-parentspanid';
|
|
17
|
-
exports.X_B3_FLAGS = 'x-b3-flags';
|
|
18
|
-
exports.X_B3_INFO = 'x-b3-info';
|
|
19
|
-
exports.B3_DEBUG_FLAG_KEY = (0, api_1.createContextKey)('B3 Debug Flag');
|
|
20
|
-
exports.B3_INFO_KEY = (0, api_1.createContextKey)('B3 Info Header');
|
|
21
|
-
exports.B3_TRACE_ID_LENGTH_KEY = (0, api_1.createContextKey)('B3 TraceId Header Length');
|
|
22
|
-
const VALID_SAMPLED_VALUES = new Set([true, 'true', 'True', '1', 1]);
|
|
23
|
-
const VALID_UNSAMPLED_VALUES = new Set([false, 'false', 'False', '0', 0]);
|
|
24
|
-
function parseHeader(header) {
|
|
25
|
-
return Array.isArray(header) ? header[0] : header;
|
|
26
|
-
}
|
|
27
|
-
function getHeaderValue(carrier, getter, key) {
|
|
28
|
-
const header = getter.get(carrier, key);
|
|
29
|
-
return parseHeader(header);
|
|
30
|
-
}
|
|
31
|
-
function getTraceIdLength(carrier, getter) {
|
|
32
|
-
const traceId = getHeaderValue(carrier, getter, exports.X_B3_TRACE_ID);
|
|
33
|
-
if (typeof traceId === 'string') {
|
|
34
|
-
if (traceId.length <= 16 || traceId.length > 32) {
|
|
35
|
-
return 16;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return 32;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return 16;
|
|
42
|
-
}
|
|
43
|
-
function getTraceId(carrier, getter) {
|
|
44
|
-
const traceId = getHeaderValue(carrier, getter, exports.X_B3_TRACE_ID);
|
|
45
|
-
if (typeof traceId === 'string') {
|
|
46
|
-
return traceId.padStart(32, '0');
|
|
47
|
-
}
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
function getSpanId(carrier, getter) {
|
|
51
|
-
const spanId = getHeaderValue(carrier, getter, exports.X_B3_SPAN_ID);
|
|
52
|
-
if (typeof spanId === 'string') {
|
|
53
|
-
return spanId;
|
|
54
|
-
}
|
|
55
|
-
return '';
|
|
56
|
-
}
|
|
57
|
-
function getDebug(carrier, getter) {
|
|
58
|
-
const debug = getHeaderValue(carrier, getter, exports.X_B3_FLAGS);
|
|
59
|
-
return debug === '1' ? '1' : undefined;
|
|
60
|
-
}
|
|
61
|
-
function getTraceFlags(carrier, getter) {
|
|
62
|
-
const traceFlags = getHeaderValue(carrier, getter, exports.X_B3_SAMPLED);
|
|
63
|
-
const debug = getDebug(carrier, getter);
|
|
64
|
-
if (debug === '1' || VALID_SAMPLED_VALUES.has(traceFlags)) {
|
|
65
|
-
return api_1.TraceFlags.SAMPLED;
|
|
66
|
-
}
|
|
67
|
-
if (traceFlags === undefined || VALID_UNSAMPLED_VALUES.has(traceFlags)) {
|
|
68
|
-
return api_1.TraceFlags.NONE;
|
|
69
|
-
}
|
|
70
|
-
// This indicates to isValidSampledValue that this is not valid
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
function getInfo(carrier, getter) {
|
|
74
|
-
const info = getHeaderValue(carrier, getter, exports.X_B3_INFO);
|
|
75
|
-
if (typeof info === 'string') {
|
|
76
|
-
return info;
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
class UoaB3Propagator {
|
|
81
|
-
inject(context, carrier, setter) {
|
|
82
|
-
const spanContext = api_1.trace.getSpanContext(context);
|
|
83
|
-
if (!spanContext ||
|
|
84
|
-
!(0, api_1.isSpanContextValid)(spanContext) ||
|
|
85
|
-
(0, core_1.isTracingSuppressed)(context))
|
|
86
|
-
return;
|
|
87
|
-
const debug = context.getValue(exports.B3_DEBUG_FLAG_KEY);
|
|
88
|
-
const traceIdLength = context.getValue(exports.B3_TRACE_ID_LENGTH_KEY);
|
|
89
|
-
setter.set(carrier, exports.X_B3_TRACE_ID, spanContext.traceId.slice(spanContext.traceId.length - traceIdLength));
|
|
90
|
-
setter.set(carrier, exports.X_B3_SPAN_ID, crypto.randomBytes(8).toString('hex'));
|
|
91
|
-
setter.set(carrier, exports.X_B3_PARENT_SPAN_ID, spanContext.spanId);
|
|
92
|
-
const info = context.getValue(exports.B3_INFO_KEY);
|
|
93
|
-
if ((0, tracing_1.getTraceInfoHeader)()) {
|
|
94
|
-
setter.set(carrier, exports.X_B3_INFO, (0, tracing_1.getTraceInfoHeader)());
|
|
95
|
-
}
|
|
96
|
-
else if (info && typeof info === 'string') {
|
|
97
|
-
setter.set(carrier, exports.X_B3_INFO, info.toString());
|
|
98
|
-
}
|
|
99
|
-
// According to the B3 spec, if the debug flag is set,
|
|
100
|
-
// the sampled flag shouldn't be propagated as well.
|
|
101
|
-
if (debug === '1') {
|
|
102
|
-
setter.set(carrier, exports.X_B3_FLAGS, debug);
|
|
103
|
-
}
|
|
104
|
-
else if (spanContext.traceFlags !== undefined) {
|
|
105
|
-
// We set the header only if there is an existing sampling decision.
|
|
106
|
-
// Otherwise we will omit it => Absent.
|
|
107
|
-
setter.set(carrier, exports.X_B3_SAMPLED, (api_1.TraceFlags.SAMPLED & spanContext.traceFlags) === api_1.TraceFlags.SAMPLED
|
|
108
|
-
? '1'
|
|
109
|
-
: '0');
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
extract(context, carrier, getter) {
|
|
113
|
-
const traceIdLength = getTraceIdLength(carrier, getter);
|
|
114
|
-
context = context.setValue(exports.B3_TRACE_ID_LENGTH_KEY, traceIdLength);
|
|
115
|
-
const traceId = getTraceId(carrier, getter);
|
|
116
|
-
const spanId = getSpanId(carrier, getter);
|
|
117
|
-
const traceFlags = getTraceFlags(carrier, getter);
|
|
118
|
-
const debug = getDebug(carrier, getter);
|
|
119
|
-
const info = getInfo(carrier, getter);
|
|
120
|
-
context = context.setValue(exports.B3_DEBUG_FLAG_KEY, debug);
|
|
121
|
-
if (info) {
|
|
122
|
-
context = context.setValue(exports.B3_INFO_KEY, info);
|
|
123
|
-
}
|
|
124
|
-
return api_1.trace.setSpanContext(context, {
|
|
125
|
-
traceId,
|
|
126
|
-
spanId,
|
|
127
|
-
isRemote: true,
|
|
128
|
-
traceFlags,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
fields() {
|
|
132
|
-
return [
|
|
133
|
-
exports.X_B3_TRACE_ID,
|
|
134
|
-
exports.X_B3_SPAN_ID,
|
|
135
|
-
exports.X_B3_FLAGS,
|
|
136
|
-
exports.X_B3_SAMPLED,
|
|
137
|
-
exports.X_B3_PARENT_SPAN_ID,
|
|
138
|
-
exports.X_B3_INFO
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
exports.UoaB3Propagator = UoaB3Propagator;
|
package/dist/logging.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/logging.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const UoaB3Propagator_1 = require("./UoaB3Propagator");
|
|
4
|
-
const tracing_1 = require("./tracing");
|
|
5
|
-
const winston = require('winston');
|
|
6
|
-
const moment = require('moment');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const { trace, context } = require('@opentelemetry/api');
|
|
9
|
-
const defaultLogPattern = '%date [%thread] %level %class - [[[%traceId,%spanId,%info]]] %message';
|
|
10
|
-
const uoaLogLevels = {
|
|
11
|
-
error: 0,
|
|
12
|
-
warn: 1,
|
|
13
|
-
info: 2,
|
|
14
|
-
debug: 3
|
|
15
|
-
};
|
|
16
|
-
const uoaLoggingFormat = function (callingModule) {
|
|
17
|
-
return winston.format.printf((logInfo) => {
|
|
18
|
-
let logPattern = process.env.loggingPattern ? process.env.loggingPattern : defaultLogPattern;
|
|
19
|
-
const logReplacements = getLogReplacementValues(callingModule, logInfo);
|
|
20
|
-
logReplacements.forEach((value, key) => {
|
|
21
|
-
logPattern = logPattern.replace(key, value);
|
|
22
|
-
});
|
|
23
|
-
return logPattern;
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
function getLogReplacementValues(callingModule, logInfo) {
|
|
27
|
-
const parts = callingModule.filename.substring(0, callingModule.filename.lastIndexOf('.js')).split(path.sep);
|
|
28
|
-
const moduleParts = parts.slice(parts.indexOf('src'));
|
|
29
|
-
let traceId = '-';
|
|
30
|
-
let spanId = '-';
|
|
31
|
-
const currentContext = trace.getSpanContext(context.active());
|
|
32
|
-
if (currentContext) {
|
|
33
|
-
traceId = currentContext.traceId;
|
|
34
|
-
spanId = currentContext.spanId;
|
|
35
|
-
}
|
|
36
|
-
let info = '-';
|
|
37
|
-
const infoHeader = context.active().getValue(UoaB3Propagator_1.B3_INFO_KEY);
|
|
38
|
-
if ((0, tracing_1.getTraceInfoHeader)()) {
|
|
39
|
-
info = (0, tracing_1.getTraceInfoHeader)();
|
|
40
|
-
}
|
|
41
|
-
else if (infoHeader) {
|
|
42
|
-
info = infoHeader.toString();
|
|
43
|
-
}
|
|
44
|
-
let message = '-';
|
|
45
|
-
if (logInfo.message != null) {
|
|
46
|
-
message = logInfo.message;
|
|
47
|
-
}
|
|
48
|
-
const traceIdLength = context.active().getValue(UoaB3Propagator_1.B3_TRACE_ID_LENGTH_KEY);
|
|
49
|
-
let logReplacements = new Map();
|
|
50
|
-
logReplacements.set('%date', moment().toISOString());
|
|
51
|
-
logReplacements.set('%thread', '-');
|
|
52
|
-
logReplacements.set('%level', logInfo.level.toUpperCase());
|
|
53
|
-
logReplacements.set('%class', moduleParts.join('.'));
|
|
54
|
-
logReplacements.set('%traceId', traceId.slice(traceId.length - traceIdLength));
|
|
55
|
-
logReplacements.set('%spanId', spanId);
|
|
56
|
-
logReplacements.set('%info', info);
|
|
57
|
-
logReplacements.set('%message', message.replace(/\n/g, ''));
|
|
58
|
-
return logReplacements;
|
|
59
|
-
}
|
|
60
|
-
module.exports = function (callingModule) {
|
|
61
|
-
return winston.createLogger({
|
|
62
|
-
levels: uoaLogLevels,
|
|
63
|
-
transports: [
|
|
64
|
-
new winston.transports.Console({
|
|
65
|
-
level: process.env.loggingLevel ? process.env.loggingLevel.toLowerCase() : 'info'
|
|
66
|
-
})
|
|
67
|
-
],
|
|
68
|
-
format: uoaLoggingFormat(callingModule)
|
|
69
|
-
});
|
|
70
|
-
};
|
package/dist/tracing.d.ts
DELETED
package/dist/tracing.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setTraceInfoHeader = exports.getTraceInfoHeader = exports.initializeTracing = void 0;
|
|
4
|
-
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
5
|
-
const instrumentation_aws_lambda_1 = require("@opentelemetry/instrumentation-aws-lambda");
|
|
6
|
-
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
7
|
-
const UoaB3Propagator_1 = require("./UoaB3Propagator");
|
|
8
|
-
const api_1 = require("@opentelemetry/api");
|
|
9
|
-
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
10
|
-
const zipkin_1 = require("./zipkin/zipkin");
|
|
11
|
-
const provider = new sdk_trace_node_1.NodeTracerProvider({ sampler: new sdk_trace_base_1.AlwaysOnSampler() });
|
|
12
|
-
let infoHeader;
|
|
13
|
-
function initializeTracing(serviceName) {
|
|
14
|
-
const options = {
|
|
15
|
-
url: process.env.zipkinUrl ? process.env.zipkinUrl : 'http://zipkin-uoa-its-nonprod-external-1074907196.ap-southeast-2.elb.amazonaws.com:9411/api/v2/spans',
|
|
16
|
-
serviceName: serviceName
|
|
17
|
-
};
|
|
18
|
-
provider.addSpanProcessor(new sdk_trace_node_1.BatchSpanProcessor(new zipkin_1.ZipkinExporter(options)));
|
|
19
|
-
provider.register({
|
|
20
|
-
propagator: new UoaB3Propagator_1.UoaB3Propagator()
|
|
21
|
-
});
|
|
22
|
-
(0, instrumentation_1.registerInstrumentations)({
|
|
23
|
-
instrumentations: [
|
|
24
|
-
new instrumentation_aws_lambda_1.AwsLambdaInstrumentation({
|
|
25
|
-
requestHook: (span, { event, context }) => {
|
|
26
|
-
span.setAttribute('faas.name', context.functionName);
|
|
27
|
-
infoHeader = undefined; //reset header value in case lambda execution environment maintained since last invocation
|
|
28
|
-
},
|
|
29
|
-
responseHook: (span, { err, res }) => {
|
|
30
|
-
if (err instanceof Error)
|
|
31
|
-
span.setAttribute('faas.error', err.message);
|
|
32
|
-
if (res)
|
|
33
|
-
span.setAttribute('faas.res', res);
|
|
34
|
-
},
|
|
35
|
-
disableAwsContextPropagation: true
|
|
36
|
-
})
|
|
37
|
-
]
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
exports.initializeTracing = initializeTracing;
|
|
41
|
-
function getTraceInfoHeader() {
|
|
42
|
-
if (infoHeader) {
|
|
43
|
-
return infoHeader;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return api_1.context.active().getValue(UoaB3Propagator_1.B3_INFO_KEY);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.getTraceInfoHeader = getTraceInfoHeader;
|
|
50
|
-
function setTraceInfoHeader(info) {
|
|
51
|
-
infoHeader = info;
|
|
52
|
-
}
|
|
53
|
-
exports.setTraceInfoHeader = setTraceInfoHeader;
|
package/dist/uoaHttps.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/uoaHttps.js
DELETED
|
@@ -1,222 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
const https = __importStar(require("https"));
|
|
36
|
-
const api_1 = require("@opentelemetry/api");
|
|
37
|
-
function request(...args) {
|
|
38
|
-
if (args[2]) {
|
|
39
|
-
api_1.propagation.inject(api_1.context.active(), args[1].headers);
|
|
40
|
-
return https.request(args[0], args[1], args[2]);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
api_1.propagation.inject(api_1.context.active(), args[0].headers);
|
|
44
|
-
return https.request(args[0], args[1]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function doGetRequest(hostname, path, headers, port = 443) {
|
|
48
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return new Promise(function (resolve, reject) {
|
|
50
|
-
const options = {
|
|
51
|
-
"method": "GET",
|
|
52
|
-
"hostname": hostname,
|
|
53
|
-
"path": path,
|
|
54
|
-
"headers": headers,
|
|
55
|
-
"port": port
|
|
56
|
-
};
|
|
57
|
-
api_1.propagation.inject(api_1.context.active(), options.headers);
|
|
58
|
-
const req = https.request(options, function (response) {
|
|
59
|
-
const chunks = [];
|
|
60
|
-
response.on("data", function (chunk) {
|
|
61
|
-
chunks.push(chunk);
|
|
62
|
-
});
|
|
63
|
-
response.on("end", function () {
|
|
64
|
-
let body = Buffer.concat(chunks);
|
|
65
|
-
body = JSON.parse(body.toString());
|
|
66
|
-
resolve(body);
|
|
67
|
-
});
|
|
68
|
-
response.on("error", function (e) {
|
|
69
|
-
reject(e);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
req.end();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function doPostRequest(hostname, path, headers, data, port = 443) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
return new Promise(function (resolve, reject) {
|
|
79
|
-
const options = {
|
|
80
|
-
"method": "POST",
|
|
81
|
-
"hostname": hostname,
|
|
82
|
-
"path": path,
|
|
83
|
-
"headers": headers,
|
|
84
|
-
"port": port
|
|
85
|
-
};
|
|
86
|
-
api_1.propagation.inject(api_1.context.active(), options.headers);
|
|
87
|
-
const req = https.request(options, function (response) {
|
|
88
|
-
const chunks = [];
|
|
89
|
-
response.on("data", function (chunk) {
|
|
90
|
-
chunks.push(chunk);
|
|
91
|
-
});
|
|
92
|
-
response.on("end", function () {
|
|
93
|
-
if (response.statusCode == 204) {
|
|
94
|
-
//204 is no content, and most JSON parses blow up on an empty string
|
|
95
|
-
resolve(null);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
let body = Buffer.concat(chunks);
|
|
99
|
-
if (!('Content-Type' in options.headers) || options.headers['Content-Type'] === 'application/json') {
|
|
100
|
-
body = JSON.parse(body.toString());
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
body = body.toString();
|
|
104
|
-
}
|
|
105
|
-
resolve(body);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
response.on("error", function (e) {
|
|
109
|
-
reject(e);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
if (data) {
|
|
113
|
-
if (!('Content-Type' in options.headers) || options.headers['Content-Type'] === 'application/json') {
|
|
114
|
-
//We serialize using JSON.stringify as a default, or if a JSON is specified
|
|
115
|
-
req.write(JSON.stringify(data));
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// If another content-type is specified however, we respect the serialization provided
|
|
119
|
-
req.write(data);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
req.end();
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function doPutRequest(hostname, path, headers, data, port = 443) {
|
|
127
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
return new Promise(function (resolve, reject) {
|
|
129
|
-
const options = {
|
|
130
|
-
"method": "PUT",
|
|
131
|
-
"hostname": hostname,
|
|
132
|
-
"path": path,
|
|
133
|
-
"headers": headers,
|
|
134
|
-
"port": port
|
|
135
|
-
};
|
|
136
|
-
api_1.propagation.inject(api_1.context.active(), options.headers);
|
|
137
|
-
const req = https.request(options, function (response) {
|
|
138
|
-
const chunks = [];
|
|
139
|
-
response.on("data", function (chunk) {
|
|
140
|
-
chunks.push(chunk);
|
|
141
|
-
});
|
|
142
|
-
response.on("end", function () {
|
|
143
|
-
if (response.statusCode == 204) {
|
|
144
|
-
//204 is no content, and most JSON parses blow up on an empty string
|
|
145
|
-
resolve(null);
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
let body = Buffer.concat(chunks);
|
|
149
|
-
if (!('Content-Type' in options.headers) || options.headers['Content-Type'] === 'application/json') {
|
|
150
|
-
body = JSON.parse(body.toString());
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
body = body.toString();
|
|
154
|
-
}
|
|
155
|
-
resolve(body);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
response.on("error", function (e) {
|
|
159
|
-
reject(e);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
if (data) {
|
|
163
|
-
if (!('Content-Type' in options.headers) || options.headers['Content-Type'] === 'application/json') {
|
|
164
|
-
//We serialize using JSON.stringify as a default, or if a JSON is specified
|
|
165
|
-
req.write(JSON.stringify(data));
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
// If another content-type is specified however, we respect the serialization provided
|
|
169
|
-
req.write(data);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
req.end();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
function doDeleteRequest(hostname, path, headers, port = 443) {
|
|
177
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
return new Promise(function (resolve, reject) {
|
|
179
|
-
const options = {
|
|
180
|
-
"method": "DELETE",
|
|
181
|
-
"hostname": hostname,
|
|
182
|
-
"path": path,
|
|
183
|
-
"headers": headers,
|
|
184
|
-
"port": port
|
|
185
|
-
};
|
|
186
|
-
api_1.propagation.inject(api_1.context.active(), options.headers);
|
|
187
|
-
const req = https.request(options, function (response) {
|
|
188
|
-
const chunks = [];
|
|
189
|
-
response.on("data", function (chunk) {
|
|
190
|
-
chunks.push(chunk);
|
|
191
|
-
});
|
|
192
|
-
response.on("end", function () {
|
|
193
|
-
if (response.statusCode == 204) {
|
|
194
|
-
//204 is no content, and most JSON parses blow up on an empty string
|
|
195
|
-
resolve(null);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
let body = Buffer.concat(chunks);
|
|
199
|
-
if (!('Content-Type' in options.headers) || options.headers['Content-Type'] === 'application/json') {
|
|
200
|
-
body = JSON.parse(body.toString());
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
body = body.toString();
|
|
204
|
-
}
|
|
205
|
-
resolve(body);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
response.on("error", function (e) {
|
|
209
|
-
reject(e);
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
req.end();
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
module.exports = {
|
|
217
|
-
request,
|
|
218
|
-
doGetRequest,
|
|
219
|
-
doPostRequest,
|
|
220
|
-
doPutRequest,
|
|
221
|
-
doDeleteRequest
|
|
222
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
*
|
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
* you may not use this file except in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* https://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
* See the License for the specific language governing permissions and
|
|
15
|
-
* limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
/**
|
|
33
|
-
* Copied from https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-exporter-zipkin/src/platform/index.ts
|
|
34
|
-
*/
|
|
35
|
-
__exportStar(require("./node"), exports);
|