@devopsplaybook.io/otel-utils-fastify 1.0.3 → 1.0.4-beta2

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,16 @@ 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, _b;
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
+ console.log(spanName, options === null || options === void 0 ? void 0 : options.ignoreList, (_a = options === null || options === void 0 ? void 0 : options.ignoreList) === null || _a === void 0 ? void 0 : _a.includes(spanName));
20
+ if ((_b = options === null || options === void 0 ? void 0 : options.ignoreList) === null || _b === void 0 ? void 0 : _b.includes(spanName)) {
21
+ return;
22
+ }
18
23
  const callerContext = propagator.extract(api_1.ROOT_CONTEXT, req.headers, api_1.defaultTextMapGetter);
19
24
  sdk_node_1.api.context.with(callerContext, () => {
20
25
  const span = standardTracer.startSpan(spanName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devopsplaybook.io/otel-utils-fastify",
3
- "version": "1.0.3",
3
+ "version": "1.0.4-beta2",
4
4
  "description": "Utility to simplify integration with Open Telemetry for Fastify API Server",
5
5
  "keywords": [
6
6
  "Open",
@@ -32,6 +32,14 @@ export function StandardTracerFastifyRegisterHooks(
32
32
  return;
33
33
  }
34
34
  const spanName = `${req.method}-${req.url.split("?")[0]}`;
35
+ console.log(
36
+ spanName,
37
+ options?.ignoreList,
38
+ options?.ignoreList?.includes(spanName)
39
+ );
40
+ if (options?.ignoreList?.includes(spanName)) {
41
+ return;
42
+ }
35
43
  const callerContext = propagator.extract(
36
44
  ROOT_CONTEXT,
37
45
  req.headers,
@@ -75,6 +83,7 @@ export function StandardTracerFastifyRegisterHooks(
75
83
 
76
84
  export interface StandardTracerFastifyRegisterHooksOptions {
77
85
  rootApiPath?: string;
86
+ ignoreList?: string[];
78
87
  }
79
88
 
80
89
  // eslint-disable-next-line @typescript-eslint/no-explicit-any