@uoa/lambda-tracing 2.0.0-beta.1 → 2.0.0-beta.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/dist/tracing.js +3 -3
- package/dist/zipkin/zipkin.js +11 -3
- package/package.json +1 -1
- package/zipkin/zipkin.ts +25 -11
package/dist/tracing.js
CHANGED
|
@@ -6,13 +6,13 @@ const instrumentation_aws_lambda_1 = require("@opentelemetry/instrumentation-aws
|
|
|
6
6
|
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
7
7
|
const UoaB3Propagator_1 = require("./UoaB3Propagator");
|
|
8
8
|
const api_1 = require("@opentelemetry/api");
|
|
9
|
-
const
|
|
9
|
+
const sdk_trace_base_1 = require("@opentelemetry/sdk-trace-base");
|
|
10
10
|
const zipkin_1 = require("./zipkin/zipkin");
|
|
11
|
-
const provider = new sdk_trace_node_1.NodeTracerProvider({ sampler: new
|
|
11
|
+
const provider = new sdk_trace_node_1.NodeTracerProvider({ sampler: new sdk_trace_base_1.AlwaysOnSampler() });
|
|
12
12
|
let infoHeader;
|
|
13
13
|
function initializeTracing(serviceName) {
|
|
14
14
|
const options = {
|
|
15
|
-
url: 'http://zipkin-uoa-its-nonprod-external-1074907196.ap-southeast-2.elb.amazonaws.com:9411/api/v2/spans',
|
|
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
16
|
serviceName: serviceName
|
|
17
17
|
};
|
|
18
18
|
provider.addSpanProcessor(new sdk_trace_node_1.BatchSpanProcessor(new zipkin_1.ZipkinExporter(options)));
|
package/dist/zipkin/zipkin.js
CHANGED
|
@@ -18,6 +18,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
exports.ZipkinExporter = void 0;
|
|
19
19
|
/**
|
|
20
20
|
* Copied from https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-exporter-zipkin/src/zipkin.ts
|
|
21
|
+
*
|
|
22
|
+
* Modified to prioritise input serviceName over SemanticResourceAttributes.SERVICE_NAME
|
|
21
23
|
*/
|
|
22
24
|
const api_1 = require("@opentelemetry/api");
|
|
23
25
|
const core_1 = require("@opentelemetry/core");
|
|
@@ -54,6 +56,7 @@ class ZipkinExporter {
|
|
|
54
56
|
const serviceName = String(this._serviceName ||
|
|
55
57
|
spans[0].resource.attributes[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME] ||
|
|
56
58
|
this.DEFAULT_SERVICE_NAME);
|
|
59
|
+
api_1.diag.debug('export: ', serviceName);
|
|
57
60
|
api_1.diag.debug('Zipkin exporter export');
|
|
58
61
|
if (this._isShutdown) {
|
|
59
62
|
setTimeout(() => resultCallback({
|
|
@@ -102,9 +105,14 @@ class ZipkinExporter {
|
|
|
102
105
|
* Transform spans and sends to Zipkin service.
|
|
103
106
|
*/
|
|
104
107
|
_sendSpans(spans, serviceName, done) {
|
|
105
|
-
const zipkinSpans = spans.map(span =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
const zipkinSpans = spans.map(span => {
|
|
109
|
+
api_1.diag.debug('sendSpans: ', String(serviceName ||
|
|
110
|
+
span.attributes[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME] ||
|
|
111
|
+
span.resource.attributes[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]));
|
|
112
|
+
return (0, transform_1.toZipkinSpan)(span, String(serviceName ||
|
|
113
|
+
span.attributes[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME] ||
|
|
114
|
+
span.resource.attributes[semantic_conventions_1.SemanticResourceAttributes.SERVICE_NAME]), this._statusCodeTagName, this._statusDescriptionTagName);
|
|
115
|
+
});
|
|
108
116
|
this._beforeSend();
|
|
109
117
|
return this._send(zipkinSpans, (result) => {
|
|
110
118
|
if (done) {
|
package/package.json
CHANGED
package/zipkin/zipkin.ts
CHANGED
|
@@ -61,6 +61,7 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
61
61
|
// noop
|
|
62
62
|
this._beforeSend = function () {};
|
|
63
63
|
}
|
|
64
|
+
console.log('zipkin constructor serviceName: ', this._serviceName);
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
/**
|
|
@@ -75,6 +76,10 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
75
76
|
spans[0].resource.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
|
|
76
77
|
this.DEFAULT_SERVICE_NAME
|
|
77
78
|
);
|
|
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);
|
|
78
83
|
|
|
79
84
|
diag.debug('Zipkin exporter export');
|
|
80
85
|
if (this._isShutdown) {
|
|
@@ -135,17 +140,26 @@ export class ZipkinExporter implements SpanExporter {
|
|
|
135
140
|
serviceName: string,
|
|
136
141
|
done?: (result: ExportResult) => void
|
|
137
142
|
) {
|
|
138
|
-
const zipkinSpans = spans.map(span =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
const zipkinSpans = spans.map(span => {
|
|
144
|
+
console.log('zipkin sendSpans actual serviceName: ', String(
|
|
145
|
+
serviceName ||
|
|
146
|
+
span.attributes[SemanticResourceAttributes.SERVICE_NAME] ||
|
|
147
|
+
span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME]
|
|
148
|
+
));
|
|
149
|
+
console.log('zipkin sendSpans serviceName: ', this._serviceName);
|
|
150
|
+
console.log('zipkin sendSpans span.attributes[SERVICE_NAME]: ', span.attributes[SemanticResourceAttributes.SERVICE_NAME]);
|
|
151
|
+
console.log('zipkin sendSpans span.resource.attributes[SERVICE_NAME]: ', span.resource.attributes[SemanticResourceAttributes.SERVICE_NAME]);
|
|
152
|
+
return toZipkinSpan(
|
|
153
|
+
span,
|
|
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
|
+
}
|
|
149
163
|
);
|
|
150
164
|
this._beforeSend();
|
|
151
165
|
return this._send(zipkinSpans, (result: ExportResult) => {
|