@devopsplaybook.io/otel-utils-fastify 1.0.3 → 1.0.4-beta1
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.
|
@@ -4,5 +4,6 @@ import { FastifyInstance } from "fastify";
|
|
|
4
4
|
export declare function StandardTracerFastifyRegisterHooks(fastify: FastifyInstance, standardTracer: StandardTracer, standardLogger: StandardLogger, options?: StandardTracerFastifyRegisterHooksOptions): void;
|
|
5
5
|
export interface StandardTracerFastifyRegisterHooksOptions {
|
|
6
6
|
rootApiPath?: string;
|
|
7
|
+
ignoreList?: string[];
|
|
7
8
|
}
|
|
8
9
|
export declare function OTelRequestSpan(req: any): Span;
|
|
@@ -10,11 +10,15 @@ const propagator = new core_1.W3CTraceContextPropagator();
|
|
|
10
10
|
function StandardTracerFastifyRegisterHooks(fastify, standardTracer, standardLogger, options) {
|
|
11
11
|
const logger = standardLogger.createModuleLogger("Fastify");
|
|
12
12
|
fastify.addHook("onRequest", async (req) => {
|
|
13
|
+
var _a;
|
|
13
14
|
if (req.method === "OPTIONS" ||
|
|
14
15
|
!req.url.startsWith((options === null || options === void 0 ? void 0 : options.rootApiPath) || "/api")) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
const spanName = `${req.method}-${req.url.split("?")[0]}`;
|
|
19
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.ignoreList) === null || _a === void 0 ? void 0 : _a.includes(spanName)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
const callerContext = propagator.extract(api_1.ROOT_CONTEXT, req.headers, api_1.defaultTextMapGetter);
|
|
19
23
|
sdk_node_1.api.context.with(callerContext, () => {
|
|
20
24
|
const span = standardTracer.startSpan(spanName);
|
package/package.json
CHANGED
|
@@ -32,6 +32,9 @@ export function StandardTracerFastifyRegisterHooks(
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
const spanName = `${req.method}-${req.url.split("?")[0]}`;
|
|
35
|
+
if (options?.ignoreList?.includes(spanName)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
35
38
|
const callerContext = propagator.extract(
|
|
36
39
|
ROOT_CONTEXT,
|
|
37
40
|
req.headers,
|
|
@@ -75,6 +78,7 @@ export function StandardTracerFastifyRegisterHooks(
|
|
|
75
78
|
|
|
76
79
|
export interface StandardTracerFastifyRegisterHooksOptions {
|
|
77
80
|
rootApiPath?: string;
|
|
81
|
+
ignoreList?: string[];
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|