@vercel/functions 3.8.0 → 3.9.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @vercel/functions
2
2
 
3
+ ## 3.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d72826e: Prevented unit tests and generated outputs from changing Turborepo task inputs during CI, and removed the redundant affected Unit test retry.
8
+
9
+ ## 3.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 0b0a4a8: Add a `metric()` helper for reporting custom metrics from Vercel Functions.
14
+
3
15
  ## 3.8.0
4
16
 
5
17
  ### Minor Changes
@@ -38,6 +38,7 @@
38
38
  - [invalidateBySrcImage](functions/invalidateBySrcImage.md)
39
39
  - [invalidateByTag](functions/invalidateByTag.md)
40
40
  - [ipAddress](functions/ipAddress.md)
41
+ - [metric](functions/metric.md)
41
42
  - [next](functions/next.md)
42
43
  - [rewrite](functions/rewrite.md)
43
44
  - [waitUntil](functions/waitUntil.md)
@@ -0,0 +1,45 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Function: metric()
6
+
7
+ > **metric**(`name`, `value`, `tags?`): `void`
8
+
9
+ Defined in: [packages/functions/src/metric.ts:28](https://github.com/vercel/vercel/blob/main/packages/functions/src/metric.ts#L28)
10
+
11
+ Reports a custom metric for the current Vercel Function invocation.
12
+
13
+ ## Parameters
14
+
15
+ ### name
16
+
17
+ `string`
18
+
19
+ The name of the metric.
20
+
21
+ ### value
22
+
23
+ `number`
24
+
25
+ The numeric value of the metric.
26
+
27
+ ### tags?
28
+
29
+ [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)\<`string`, `string`\>
30
+
31
+ Optional tags to attach to the metric.
32
+
33
+ ## Returns
34
+
35
+ `void`
36
+
37
+ ## Example
38
+
39
+ ```js
40
+ import { metric } from '@vercel/functions';
41
+
42
+ metric('tinybird.query_ms', 100, {
43
+ query: 'getUser',
44
+ });
45
+ ```
package/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { geolocation, ipAddress } from './headers';
3
3
  export { getEnv } from './get-env';
4
4
  export { getDeadline } from './deadline';
5
5
  export { waitUntil } from './wait-until';
6
+ export { metric } from './metric';
6
7
  export { rewrite, next } from './middleware';
7
8
  export { getCache } from './cache';
8
9
  export { attachDatabasePool, experimental_attachDatabasePool, } from './db-connections';
package/index.js CHANGED
@@ -31,6 +31,7 @@ __export(src_exports, {
31
31
  invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
32
32
  invalidateByTag: () => import_purge.invalidateByTag,
33
33
  ipAddress: () => import_headers.ipAddress,
34
+ metric: () => import_metric.metric,
34
35
  next: () => import_middleware.next,
35
36
  rewrite: () => import_middleware.rewrite,
36
37
  waitUntil: () => import_wait_until.waitUntil
@@ -40,6 +41,7 @@ var import_headers = require("./headers");
40
41
  var import_get_env = require("./get-env");
41
42
  var import_deadline = require("./deadline");
42
43
  var import_wait_until = require("./wait-until");
44
+ var import_metric = require("./metric");
43
45
  var import_middleware = require("./middleware");
44
46
  var import_cache = require("./cache");
45
47
  var import_db_connections = require("./db-connections");
@@ -61,6 +63,7 @@ var import_websocket = require("./websocket");
61
63
  invalidateBySrcImage,
62
64
  invalidateByTag,
63
65
  ipAddress,
66
+ metric,
64
67
  next,
65
68
  rewrite,
66
69
  waitUntil
package/metric.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Reports a custom metric for the current Vercel Function invocation.
3
+ *
4
+ * @param name The name of the metric.
5
+ * @param value The numeric value of the metric.
6
+ * @param tags Optional tags to attach to the metric.
7
+ *
8
+ * @example
9
+ *
10
+ * ```js
11
+ * import { metric } from '@vercel/functions';
12
+ *
13
+ * metric('tinybird.query_ms', 100, {
14
+ * query: 'getUser',
15
+ * });
16
+ * ```
17
+ */
18
+ export declare function metric(name: string, value: number, tags?: Record<string, string>): void;
package/metric.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var metric_exports = {};
20
+ __export(metric_exports, {
21
+ metric: () => metric
22
+ });
23
+ module.exports = __toCommonJS(metric_exports);
24
+ const RUSTY_RUNTIME_IPC_SYMBOL = Symbol.for("@vercel/rusty-runtime-ipc");
25
+ function metric(name, value, tags) {
26
+ const ipc = globalThis[RUSTY_RUNTIME_IPC_SYMBOL];
27
+ ipc?.sendMetric?.(name, value, tags);
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ metric
32
+ });
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "require": "./middleware.js"
31
31
  }
32
32
  },
33
- "version": "3.8.0",
33
+ "version": "3.9.1",
34
34
  "repository": {
35
35
  "directory": "packages/functions",
36
36
  "type": "git",