@codefresh-io/cf-telemetry 3.4.0-alpha.2 → 3.4.0-alpha.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.
@@ -1 +1 @@
1
- export * from './db-statement-serializer.js';
1
+ export * from './stringify-db-statement.js';
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./db-statement-serializer.js"), exports);
17
+ __exportStar(require("./stringify-db-statement.js"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/otel/sdk/instrumentation-configs/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/otel/sdk/instrumentation-configs/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Aimed to serialize `db.statement` span attribute, replacing all values with "?"
3
+ * and circular references with "[Circular]"
4
+ */
5
+ export declare const stringifyDbStatement: (payload: unknown) => string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stringifyDbStatement = void 0;
4
+ /**
5
+ * Creates a replacer function for JSON.stringify,
6
+ * that replaces all non-object values with "?"
7
+ * and circular references with "[Circular]"
8
+ * @returns a replacer function
9
+ */
10
+ const getReplacer = () => {
11
+ // WeakSet is used for tracking seen objects to avoid memory leaks
12
+ const seen = new WeakSet();
13
+ return (_key, value) => {
14
+ // undefined, boolean, number, bigint, string, symbol, function || null
15
+ if (typeof value !== 'object' || !value)
16
+ return '?';
17
+ // objects (including arrays)
18
+ if (seen.has(value))
19
+ return '[Circular]';
20
+ seen.add(value);
21
+ return value;
22
+ };
23
+ };
24
+ /**
25
+ * Aimed to serialize `db.statement` span attribute, replacing all values with "?"
26
+ * and circular references with "[Circular]"
27
+ */
28
+ const stringifyDbStatement = (payload) => JSON.stringify(payload, getReplacer());
29
+ exports.stringifyDbStatement = stringifyDbStatement;
30
+ //# sourceMappingURL=stringify-db-statement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify-db-statement.js","sourceRoot":"","sources":["../../../../../src/otel/sdk/instrumentation-configs/helpers/stringify-db-statement.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAM,WAAW,GAAG,GAAa,EAAE;IACjC,kEAAkE;IAClE,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IAC3B,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrB,uEAAuE;QACvE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK;YAAE,OAAO,GAAG,CAAC;QAEpD,6BAA6B;QAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;AAA5F,QAAA,oBAAoB,wBAAwE"}
@@ -4,6 +4,6 @@ exports.mongodb = void 0;
4
4
  const helpers_1 = require("./helpers");
5
5
  exports.mongodb = {
6
6
  requireParentSpan: process.env['CF_TELEMETRY_OTEL_MONGODB_REQUIRE_PARENT_SPAN'] === 'true',
7
- dbStatementSerializer: helpers_1.dbStatementSerializer,
7
+ dbStatementSerializer: helpers_1.stringifyDbStatement,
8
8
  };
9
9
  //# sourceMappingURL=mongodb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongodb.js","sourceRoot":"","sources":["../../../../src/otel/sdk/instrumentation-configs/mongodb.ts"],"names":[],"mappings":";;;AACA,uCAAkD;AAErC,QAAA,OAAO,GAAuE;IACzF,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,KAAK,MAAM;IAC1F,qBAAqB,EAArB,+BAAqB;CACtB,CAAC"}
1
+ {"version":3,"file":"mongodb.js","sourceRoot":"","sources":["../../../../src/otel/sdk/instrumentation-configs/mongodb.ts"],"names":[],"mappings":";;;AACA,uCAAiD;AAEpC,QAAA,OAAO,GAAuE;IACzF,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,CAAC,KAAK,MAAM;IAC1F,qBAAqB,EAAE,8BAAoB;CAC5C,CAAC"}
@@ -5,6 +5,7 @@ const helpers_1 = require("./helpers");
5
5
  exports.mongoose = {
6
6
  suppressInternalInstrumentation: process.env['CF_TELEMETRY_OTEL_MONGOOSE_SUPPRESS_INTERNAL_INSTRUMENTATION'] === 'true',
7
7
  requireParentSpan: process.env['CF_TELEMETRY_OTEL_MONGOOSE_REQUIRE_PARENT_SPAN'] === 'true',
8
- dbStatementSerializer: (operation, payload) => (0, helpers_1.dbStatementSerializer)({ operation, payload }),
8
+ /** No need to serialize operation name: it is already included in `db.operation` attribute. */
9
+ dbStatementSerializer: (_operation, payload) => (0, helpers_1.stringifyDbStatement)(payload),
9
10
  };
10
11
  //# sourceMappingURL=mongoose.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mongoose.js","sourceRoot":"","sources":["../../../../src/otel/sdk/instrumentation-configs/mongoose.ts"],"names":[],"mappings":";;;AACA,uCAAkD;AAErC,QAAA,QAAQ,GAAwE;IAC3F,+BAA+B,EAAE,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,KAAK,MAAM;IACvH,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,KAAK,MAAM;IAC3F,qBAAqB,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,IAAA,+BAAqB,EAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;CAC7F,CAAC"}
1
+ {"version":3,"file":"mongoose.js","sourceRoot":"","sources":["../../../../src/otel/sdk/instrumentation-configs/mongoose.ts"],"names":[],"mappings":";;;AACA,uCAAiD;AAEpC,QAAA,QAAQ,GAAwE;IAC3F,+BAA+B,EAAE,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,KAAK,MAAM;IACvH,iBAAiB,EAAE,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,KAAK,MAAM;IAC3F,+FAA+F;IAC/F,qBAAqB,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,IAAA,8BAAoB,EAAC,OAAO,CAAC;CAC9E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codefresh-io/cf-telemetry",
3
- "version": "3.4.0-alpha.2",
3
+ "version": "3.4.0-alpha.3",
4
4
  "exports": {
5
5
  "./init": {
6
6
  "import": "./dist/init.mjs",
@@ -1,13 +0,0 @@
1
- /**
2
- * Serialize `db.statement` span attribute, replacing all values with "?".
3
- *
4
- * Custom serializer has been implemented for two reasons:
5
- * 1. Default serializer issue with circular references:
6
- * https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2281
7
- *
8
- * 2. Default serializer is less performant as it iterates over objects twice:
9
- * initially to replace values with "?" and then to serialize to JSON string.
10
- *
11
- * Feel free to get default back once the above issues are resolved.
12
- */
13
- export declare const dbStatementSerializer: (cmd: unknown) => string;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dbStatementSerializer = void 0;
4
- /**
5
- * Creates a replacer function for JSON.stringify,
6
- * that replaces all non-object values with "?"
7
- * and circular references with "[Circular]"
8
- * @returns a replacer function
9
- */
10
- const getCmdReplacer = () => {
11
- // WeakSet is used for tracking seen objects to avoid memory leaks
12
- const seen = new WeakSet();
13
- return (_key, value) => {
14
- // undefined, boolean, number, bigint, string, symbol, function || null
15
- if (typeof value !== 'object' || !value)
16
- return '?';
17
- // objects (including arrays)
18
- if (seen.has(value))
19
- return '[Circular]';
20
- seen.add(value);
21
- return value;
22
- };
23
- };
24
- /**
25
- * Serialize `db.statement` span attribute, replacing all values with "?".
26
- *
27
- * Custom serializer has been implemented for two reasons:
28
- * 1. Default serializer issue with circular references:
29
- * https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2281
30
- *
31
- * 2. Default serializer is less performant as it iterates over objects twice:
32
- * initially to replace values with "?" and then to serialize to JSON string.
33
- *
34
- * Feel free to get default back once the above issues are resolved.
35
- */
36
- const dbStatementSerializer = (cmd) => JSON.stringify(cmd, getCmdReplacer());
37
- exports.dbStatementSerializer = dbStatementSerializer;
38
- //# sourceMappingURL=db-statement-serializer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-statement-serializer.js","sourceRoot":"","sources":["../../../../../src/otel/sdk/instrumentation-configs/helpers/db-statement-serializer.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAM,cAAc,GAAG,GAAa,EAAE;IACpC,kEAAkE;IAClE,MAAM,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;IAC3B,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACrB,uEAAuE;QACvE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK;YAAE,OAAO,GAAG,CAAC;QAEpD,6BAA6B;QAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,YAAY,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACI,MAAM,qBAAqB,GAAG,CAAC,GAAY,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,cAAc,EAAE,CAAC,CAAC;AAAxF,QAAA,qBAAqB,yBAAmE"}