apitally 1.0.0-beta.6 → 1.0.0
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/README.md
CHANGED
|
@@ -54,7 +54,7 @@ The SDK supports **Node.js** `^20.16` or `>= 22.3` and **Bun** `>= 1.2.0`.
|
|
|
54
54
|
| [**Elysia**](https://github.com/elysiajs/elysia) | `>= 1.1`, `< 2` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/elysia) |
|
|
55
55
|
| [**Express**](https://github.com/expressjs/express) | `>= 4.18.2`, `< 6` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/express) |
|
|
56
56
|
| [**Fastify**](https://github.com/fastify/fastify) | `>= 4.10.2`, `< 6` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/fastify) |
|
|
57
|
-
| [**H3**](https://github.com/h3js/h3) | `>= 2.0.1
|
|
57
|
+
| [**H3**](https://github.com/h3js/h3) | `>= 2.0.1`, `< 3` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/h3) |
|
|
58
58
|
| [**Hapi**](https://github.com/hapijs/hapi) | `21.x` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hapi) |
|
|
59
59
|
| [**Hono**](https://github.com/honojs/hono) \* | `>= 4.8.4`, `< 5` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/hono) |
|
|
60
60
|
| [**Koa**](https://github.com/koajs/koa) | `2.x`, `3.x` | [Link](https://docs.apitally.io/sdk-reference/javascript/v1/setup-guides/koa) |
|
|
@@ -2,9 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_logger = require("./logger.cjs");
|
|
3
3
|
const require_context = require("./context.cjs");
|
|
4
4
|
//#region src/requestAttributes.ts
|
|
5
|
+
const CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE = "apitally.request.custom_attribute_keys";
|
|
5
6
|
function setRequestAttribute(key, value) {
|
|
6
7
|
try {
|
|
7
|
-
|
|
8
|
+
const record = require_context.getRequestRecord();
|
|
9
|
+
writeRequestAttribute(require_context.getServerSpan(), record, key, value);
|
|
10
|
+
if (record) {
|
|
11
|
+
const keys = record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] ?? [];
|
|
12
|
+
if (!keys.includes(key)) record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] = [...keys, key];
|
|
13
|
+
}
|
|
8
14
|
} catch (error) {
|
|
9
15
|
require_logger.logDebug(`Error setting request attribute: ${String(error)}`);
|
|
10
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAttributes.cjs","names":["
|
|
1
|
+
{"version":3,"file":"requestAttributes.cjs","names":["getRequestRecord","getServerSpan"],"sources":["../src/requestAttributes.ts"],"sourcesContent":["import type { AttributeValue, Span } from \"@opentelemetry/api\";\nimport { getRequestRecord, getServerSpan, type RequestRecord } from \"./context.js\";\nimport { logDebug } from \"./logger.js\";\n\nconst CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE = \"apitally.request.custom_attribute_keys\";\n\nexport function setRequestAttribute(key: string, value: AttributeValue): void {\n try {\n const record = getRequestRecord();\n writeRequestAttribute(getServerSpan(), record, key, value);\n if (record) {\n const keys =\n (record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] as string[] | undefined) ?? [];\n if (!keys.includes(key)) {\n // A new array leaves already-built export copies unchanged\n record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] = [...keys, key];\n }\n }\n } catch (error) {\n logDebug(`Error setting request attribute: ${String(error)}`);\n }\n}\n\n// Mirroring attributes into the request record preserves values learned after\n// the live span stops recording.\nexport function writeRequestAttribute(\n span: Span | undefined,\n record: RequestRecord | undefined,\n key: string,\n value: AttributeValue,\n): void {\n if (span?.isRecording()) {\n span.setAttribute(key, value);\n }\n if (record) {\n record.attributes[key] = value;\n }\n}\n"],"mappings":";;;;AAIA,MAAM,kCAAkC;AAExC,SAAgB,oBAAoB,KAAa,OAA6B;CAC5E,IAAI;EACF,MAAM,SAASA,gBAAAA,iBAAiB;EAChC,sBAAsBC,gBAAAA,cAAc,GAAG,QAAQ,KAAK,KAAK;EACzD,IAAI,QAAQ;GACV,MAAM,OACH,OAAO,WAAW,oCAA6D,CAAC;GACnF,IAAI,CAAC,KAAK,SAAS,GAAG,GAEpB,OAAO,WAAW,mCAAmC,CAAC,GAAG,MAAM,GAAG;EAEtE;CACF,SAAS,OAAO;EACd,eAAA,SAAS,oCAAoC,OAAO,KAAK,GAAG;CAC9D;AACF;AAIA,SAAgB,sBACd,MACA,QACA,KACA,OACM;CACN,IAAI,MAAM,YAAY,GACpB,KAAK,aAAa,KAAK,KAAK;CAE9B,IAAI,QACF,OAAO,WAAW,OAAO;AAE7B"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { logDebug } from "./logger.js";
|
|
2
2
|
import { getRequestRecord, getServerSpan } from "./context.js";
|
|
3
3
|
//#region src/requestAttributes.ts
|
|
4
|
+
const CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE = "apitally.request.custom_attribute_keys";
|
|
4
5
|
function setRequestAttribute(key, value) {
|
|
5
6
|
try {
|
|
6
|
-
|
|
7
|
+
const record = getRequestRecord();
|
|
8
|
+
writeRequestAttribute(getServerSpan(), record, key, value);
|
|
9
|
+
if (record) {
|
|
10
|
+
const keys = record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] ?? [];
|
|
11
|
+
if (!keys.includes(key)) record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] = [...keys, key];
|
|
12
|
+
}
|
|
7
13
|
} catch (error) {
|
|
8
14
|
logDebug(`Error setting request attribute: ${String(error)}`);
|
|
9
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestAttributes.js","names":[],"sources":["../src/requestAttributes.ts"],"sourcesContent":["import type { AttributeValue, Span } from \"@opentelemetry/api\";\nimport { getRequestRecord, getServerSpan, type RequestRecord } from \"./context.js\";\nimport { logDebug } from \"./logger.js\";\n\nexport function setRequestAttribute(key: string, value: AttributeValue): void {\n try {\n writeRequestAttribute(getServerSpan(),
|
|
1
|
+
{"version":3,"file":"requestAttributes.js","names":[],"sources":["../src/requestAttributes.ts"],"sourcesContent":["import type { AttributeValue, Span } from \"@opentelemetry/api\";\nimport { getRequestRecord, getServerSpan, type RequestRecord } from \"./context.js\";\nimport { logDebug } from \"./logger.js\";\n\nconst CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE = \"apitally.request.custom_attribute_keys\";\n\nexport function setRequestAttribute(key: string, value: AttributeValue): void {\n try {\n const record = getRequestRecord();\n writeRequestAttribute(getServerSpan(), record, key, value);\n if (record) {\n const keys =\n (record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] as string[] | undefined) ?? [];\n if (!keys.includes(key)) {\n // A new array leaves already-built export copies unchanged\n record.attributes[CUSTOM_ATTRIBUTE_KEYS_ATTRIBUTE] = [...keys, key];\n }\n }\n } catch (error) {\n logDebug(`Error setting request attribute: ${String(error)}`);\n }\n}\n\n// Mirroring attributes into the request record preserves values learned after\n// the live span stops recording.\nexport function writeRequestAttribute(\n span: Span | undefined,\n record: RequestRecord | undefined,\n key: string,\n value: AttributeValue,\n): void {\n if (span?.isRecording()) {\n span.setAttribute(key, value);\n }\n if (record) {\n record.attributes[key] = value;\n }\n}\n"],"mappings":";;;AAIA,MAAM,kCAAkC;AAExC,SAAgB,oBAAoB,KAAa,OAA6B;CAC5E,IAAI;EACF,MAAM,SAAS,iBAAiB;EAChC,sBAAsB,cAAc,GAAG,QAAQ,KAAK,KAAK;EACzD,IAAI,QAAQ;GACV,MAAM,OACH,OAAO,WAAW,oCAA6D,CAAC;GACnF,IAAI,CAAC,KAAK,SAAS,GAAG,GAEpB,OAAO,WAAW,mCAAmC,CAAC,GAAG,MAAM,GAAG;EAEtE;CACF,SAAS,OAAO;EACd,SAAS,oCAAoC,OAAO,KAAK,GAAG;CAC9D;AACF;AAIA,SAAgB,sBACd,MACA,QACA,KACA,OACM;CACN,IAAI,MAAM,YAAY,GACpB,KAAK,aAAa,KAAK,KAAK;CAE9B,IAAI,QACF,OAAO,WAAW,OAAO;AAE7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apitally",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Simple API monitoring, analytics and request logging for REST APIs built with AdonisJS, Elysia, Express, Fastify, H3, Hapi, Hono, Koa and NestJS.",
|
|
5
5
|
"author": "Apitally <hello@apitally.io>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
"elysia": ">=1.1 <2",
|
|
204
204
|
"express": ">=4.18.2 <6",
|
|
205
205
|
"fastify": ">=4.10.2 <6",
|
|
206
|
-
"h3": ">=2.0.1
|
|
206
|
+
"h3": ">=2.0.1 <3",
|
|
207
207
|
"hono": ">=4.8.4 <5",
|
|
208
208
|
"koa": ">=2 <4",
|
|
209
209
|
"pino": ">=9.6.0 <11",
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
"elysia": "^1.4.29",
|
|
290
290
|
"express": "^5.2.1",
|
|
291
291
|
"fastify": "^5.11.0",
|
|
292
|
-
"h3": "2.0.
|
|
292
|
+
"h3": "2.0.2",
|
|
293
293
|
"hono": "^4.12.31",
|
|
294
294
|
"knip": "^6.29.0",
|
|
295
295
|
"koa": "^3.2.1",
|