@uoa/lambda-tracing 1.0.0-beta.2 → 1.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.d.ts +1 -0
- package/dist/tracing.js +24 -21
- package/package.json +1 -1
- package/tracing.ts +22 -18
package/dist/tracing.d.ts
CHANGED
package/dist/tracing.js
CHANGED
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRequestId = void 0;
|
|
3
|
+
exports.getRequestId = exports.initializeTracing = void 0;
|
|
4
4
|
const sdk_trace_node_1 = require("@opentelemetry/sdk-trace-node");
|
|
5
5
|
const instrumentation_aws_lambda_1 = require("@opentelemetry/instrumentation-aws-lambda");
|
|
6
6
|
const instrumentation_1 = require("@opentelemetry/instrumentation");
|
|
7
7
|
const UoaB3Propagator_1 = require("./UoaB3Propagator");
|
|
8
8
|
const provider = new sdk_trace_node_1.NodeTracerProvider();
|
|
9
|
-
provider.register({
|
|
10
|
-
propagator: new UoaB3Propagator_1.UoaB3Propagator()
|
|
11
|
-
});
|
|
12
9
|
let requestId;
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
new
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
10
|
+
function initializeTracing() {
|
|
11
|
+
provider.register({
|
|
12
|
+
propagator: new UoaB3Propagator_1.UoaB3Propagator()
|
|
13
|
+
});
|
|
14
|
+
(0, instrumentation_1.registerInstrumentations)({
|
|
15
|
+
instrumentations: [
|
|
16
|
+
new instrumentation_aws_lambda_1.AwsLambdaInstrumentation({
|
|
17
|
+
requestHook: (span, { event, context }) => {
|
|
18
|
+
span.setAttribute('faas.name', context.functionName);
|
|
19
|
+
requestId = context.awsRequestId;
|
|
20
|
+
},
|
|
21
|
+
responseHook: (span, { err, res }) => {
|
|
22
|
+
if (err instanceof Error)
|
|
23
|
+
span.setAttribute('faas.error', err.message);
|
|
24
|
+
if (res)
|
|
25
|
+
span.setAttribute('faas.res', res);
|
|
26
|
+
},
|
|
27
|
+
disableAwsContextPropagation: true
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.initializeTracing = initializeTracing;
|
|
30
33
|
function getRequestId() {
|
|
31
34
|
return requestId;
|
|
32
35
|
}
|
package/package.json
CHANGED
package/tracing.ts
CHANGED
|
@@ -4,26 +4,30 @@ import {registerInstrumentations} from '@opentelemetry/instrumentation';
|
|
|
4
4
|
import {UoaB3Propagator} from "./UoaB3Propagator";
|
|
5
5
|
|
|
6
6
|
const provider = new NodeTracerProvider();
|
|
7
|
-
provider.register({
|
|
8
|
-
propagator: new UoaB3Propagator()
|
|
9
|
-
});
|
|
10
7
|
let requestId: string;
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
new
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
9
|
+
export function initializeTracing() {
|
|
10
|
+
provider.register({
|
|
11
|
+
propagator: new UoaB3Propagator()
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
registerInstrumentations({
|
|
15
|
+
instrumentations: [
|
|
16
|
+
new AwsLambdaInstrumentation({
|
|
17
|
+
requestHook: (span, { event, context }) => {
|
|
18
|
+
span.setAttribute('faas.name', context.functionName);
|
|
19
|
+
requestId = context.awsRequestId;
|
|
20
|
+
},
|
|
21
|
+
responseHook: (span, { err, res }) => {
|
|
22
|
+
if (err instanceof Error) span.setAttribute('faas.error', err.message);
|
|
23
|
+
if (res) span.setAttribute('faas.res', res);
|
|
24
|
+
},
|
|
25
|
+
disableAwsContextPropagation: true
|
|
26
|
+
})
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
}
|
|
27
31
|
|
|
28
32
|
export function getRequestId() {
|
|
29
33
|
return requestId;
|