modal 0.11.1-dev.14 → 0.11.1-dev.15
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/dist/index.cjs +196 -8
- package/dist/index.d.cts +106 -6
- package/dist/index.d.ts +106 -6
- package/dist/index.js +195 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -51,6 +51,7 @@ __export(index_exports, {
|
|
|
51
51
|
FunctionCallLogsManager: () => FunctionCallLogsManager,
|
|
52
52
|
FunctionCallService: () => FunctionCallService,
|
|
53
53
|
FunctionLogsManager: () => FunctionLogsManager,
|
|
54
|
+
FunctionMetricsManager: () => FunctionMetricsManager,
|
|
54
55
|
FunctionService: () => FunctionService,
|
|
55
56
|
FunctionTimeoutError: () => FunctionTimeoutError,
|
|
56
57
|
Function_: () => Function_,
|
|
@@ -67635,11 +67636,40 @@ var TimeoutError = class extends Error {
|
|
|
67635
67636
|
this.name = "TimeoutError";
|
|
67636
67637
|
}
|
|
67637
67638
|
};
|
|
67638
|
-
var FunctionTimeoutError = class extends Error {
|
|
67639
|
+
var FunctionTimeoutError = class _FunctionTimeoutError extends Error {
|
|
67639
67640
|
constructor(message) {
|
|
67640
67641
|
super(message);
|
|
67641
67642
|
this.name = "FunctionTimeoutError";
|
|
67642
67643
|
}
|
|
67644
|
+
// Backward compatibility: FunctionCall.get() wait timeouts still match
|
|
67645
|
+
// FunctionTimeoutError, with a deprecation warning.
|
|
67646
|
+
static [Symbol.hasInstance](instance) {
|
|
67647
|
+
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
67648
|
+
return true;
|
|
67649
|
+
}
|
|
67650
|
+
if (this === _FunctionTimeoutError && instance instanceof FunctionCallGetTimeoutError) {
|
|
67651
|
+
instance.warnFunctionTimeoutErrorMatch();
|
|
67652
|
+
return true;
|
|
67653
|
+
}
|
|
67654
|
+
return false;
|
|
67655
|
+
}
|
|
67656
|
+
};
|
|
67657
|
+
var warnedFunctionTimeoutErrorMatch = false;
|
|
67658
|
+
var FunctionCallGetTimeoutError = class extends TimeoutError {
|
|
67659
|
+
#logger;
|
|
67660
|
+
constructor(message, logger2) {
|
|
67661
|
+
super(message);
|
|
67662
|
+
this.#logger = logger2;
|
|
67663
|
+
}
|
|
67664
|
+
warnFunctionTimeoutErrorMatch() {
|
|
67665
|
+
if (warnedFunctionTimeoutErrorMatch) {
|
|
67666
|
+
return;
|
|
67667
|
+
}
|
|
67668
|
+
warnedFunctionTimeoutErrorMatch = true;
|
|
67669
|
+
this.#logger.warn(
|
|
67670
|
+
"Matching a FunctionCall.get() timeout with `instanceof FunctionTimeoutError` is deprecated and will stop working in a future release; check `instanceof TimeoutError` first instead."
|
|
67671
|
+
);
|
|
67672
|
+
}
|
|
67643
67673
|
};
|
|
67644
67674
|
var RemoteError = class extends Error {
|
|
67645
67675
|
constructor(message) {
|
|
@@ -68219,12 +68249,14 @@ async function blobDownload(cpClient, blobId) {
|
|
|
68219
68249
|
var outputsTimeoutMs = 55 * 1e3;
|
|
68220
68250
|
var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
68221
68251
|
cpClient;
|
|
68252
|
+
logger;
|
|
68222
68253
|
functionCallId;
|
|
68223
68254
|
input;
|
|
68224
68255
|
functionCallJwt;
|
|
68225
68256
|
inputJwt;
|
|
68226
|
-
constructor(cpClient, functionCallId, input, functionCallJwt, inputJwt) {
|
|
68257
|
+
constructor(cpClient, logger2, functionCallId, input, functionCallJwt, inputJwt) {
|
|
68227
68258
|
this.cpClient = cpClient;
|
|
68259
|
+
this.logger = logger2;
|
|
68228
68260
|
this.functionCallId = functionCallId;
|
|
68229
68261
|
this.input = input;
|
|
68230
68262
|
this.functionCallJwt = functionCallJwt;
|
|
@@ -68243,6 +68275,7 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68243
68275
|
});
|
|
68244
68276
|
return new _ControlPlaneInvocation(
|
|
68245
68277
|
client.cpClient,
|
|
68278
|
+
client.logger,
|
|
68246
68279
|
functionMapResponse.functionCallId,
|
|
68247
68280
|
input,
|
|
68248
68281
|
functionMapResponse.functionCallJwt,
|
|
@@ -68250,11 +68283,16 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68250
68283
|
);
|
|
68251
68284
|
}
|
|
68252
68285
|
static fromFunctionCallId(client, functionCallId) {
|
|
68253
|
-
return new _ControlPlaneInvocation(
|
|
68286
|
+
return new _ControlPlaneInvocation(
|
|
68287
|
+
client.cpClient,
|
|
68288
|
+
client.logger,
|
|
68289
|
+
functionCallId
|
|
68290
|
+
);
|
|
68254
68291
|
}
|
|
68255
68292
|
async awaitOutput(timeoutMs, clearOnSuccess = false) {
|
|
68256
68293
|
return await pollFunctionOutput(
|
|
68257
68294
|
this.cpClient,
|
|
68295
|
+
this.logger,
|
|
68258
68296
|
(timeoutMs2) => this.#getOutput(
|
|
68259
68297
|
timeoutMs2,
|
|
68260
68298
|
clearOnSuccess,
|
|
@@ -68294,12 +68332,14 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68294
68332
|
var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
68295
68333
|
cpClient;
|
|
68296
68334
|
ipClient;
|
|
68335
|
+
logger;
|
|
68297
68336
|
functionId;
|
|
68298
68337
|
input;
|
|
68299
68338
|
attemptToken;
|
|
68300
|
-
constructor(cpClient, ipClient, functionId, input, attemptToken) {
|
|
68339
|
+
constructor(cpClient, ipClient, logger2, functionId, input, attemptToken) {
|
|
68301
68340
|
this.cpClient = cpClient;
|
|
68302
68341
|
this.ipClient = ipClient;
|
|
68342
|
+
this.logger = logger2;
|
|
68303
68343
|
this.functionId = functionId;
|
|
68304
68344
|
this.input = input;
|
|
68305
68345
|
this.attemptToken = attemptToken;
|
|
@@ -68317,6 +68357,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68317
68357
|
return new _InputPlaneInvocation(
|
|
68318
68358
|
client.cpClient,
|
|
68319
68359
|
ipClient,
|
|
68360
|
+
client.logger,
|
|
68320
68361
|
functionId,
|
|
68321
68362
|
functionPutInputsItem,
|
|
68322
68363
|
attemptStartResponse.attemptToken
|
|
@@ -68325,6 +68366,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68325
68366
|
async awaitOutput(timeoutMs) {
|
|
68326
68367
|
return await pollFunctionOutput(
|
|
68327
68368
|
this.cpClient,
|
|
68369
|
+
this.logger,
|
|
68328
68370
|
(timeoutMs2) => this.#getOutput(timeoutMs2),
|
|
68329
68371
|
timeoutMs
|
|
68330
68372
|
);
|
|
@@ -68349,7 +68391,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68349
68391
|
function timeNowSeconds() {
|
|
68350
68392
|
return Date.now() / 1e3;
|
|
68351
68393
|
}
|
|
68352
|
-
async function pollFunctionOutput(cpClient, getOutput, timeoutMs) {
|
|
68394
|
+
async function pollFunctionOutput(cpClient, logger2, getOutput, timeoutMs) {
|
|
68353
68395
|
const startTime = Date.now();
|
|
68354
68396
|
let pollTimeoutMs = outputsTimeoutMs;
|
|
68355
68397
|
if (timeoutMs !== void 0) {
|
|
@@ -68364,7 +68406,7 @@ async function pollFunctionOutput(cpClient, getOutput, timeoutMs) {
|
|
|
68364
68406
|
const remainingMs = timeoutMs - (Date.now() - startTime);
|
|
68365
68407
|
if (remainingMs <= 0) {
|
|
68366
68408
|
const message = `Timeout exceeded: ${timeoutMs}ms`;
|
|
68367
|
-
throw new
|
|
68409
|
+
throw new FunctionCallGetTimeoutError(message, logger2);
|
|
68368
68410
|
}
|
|
68369
68411
|
pollTimeoutMs = Math.min(outputsTimeoutMs, remainingMs);
|
|
68370
68412
|
}
|
|
@@ -79002,7 +79044,7 @@ var AuthTokenManager = class {
|
|
|
79002
79044
|
};
|
|
79003
79045
|
|
|
79004
79046
|
// src/version.ts
|
|
79005
|
-
var SDK_VERSION = "0.11.1-dev.
|
|
79047
|
+
var SDK_VERSION = "0.11.1-dev.15";
|
|
79006
79048
|
function getSDKVersion() {
|
|
79007
79049
|
return SDK_VERSION;
|
|
79008
79050
|
}
|
|
@@ -80633,7 +80675,12 @@ var FunctionCall = class {
|
|
|
80633
80675
|
this.#client = client;
|
|
80634
80676
|
this.functionCallId = functionCallId;
|
|
80635
80677
|
}
|
|
80636
|
-
/**
|
|
80678
|
+
/**
|
|
80679
|
+
* Get the result of a FunctionCall, optionally waiting with a timeout.
|
|
80680
|
+
*
|
|
80681
|
+
* @throws {@link TimeoutError} if `timeoutMs` elapses before the Function finishes.
|
|
80682
|
+
* @throws {@link FunctionTimeoutError} if the Function exceeds its execution timeout.
|
|
80683
|
+
*/
|
|
80637
80684
|
async get(params = {}) {
|
|
80638
80685
|
checkForRenamedParams(params, { timeout: "timeoutMs" });
|
|
80639
80686
|
const invocation = ControlPlaneInvocation.fromFunctionCallId(
|
|
@@ -80674,6 +80721,142 @@ var FunctionCall = class {
|
|
|
80674
80721
|
// src/function.ts
|
|
80675
80722
|
var import_nice_grpc17 = require("nice-grpc");
|
|
80676
80723
|
|
|
80724
|
+
// src/metrics.ts
|
|
80725
|
+
function metricsRequest(params) {
|
|
80726
|
+
const until = params.until ?? /* @__PURE__ */ new Date();
|
|
80727
|
+
const since = params.since ?? new Date(until.getTime() - 60 * 60 * 1e3);
|
|
80728
|
+
if (!Number.isFinite(since.getTime()) || !Number.isFinite(until.getTime())) {
|
|
80729
|
+
throw new InvalidError("`since` and `until` must be valid dates.");
|
|
80730
|
+
}
|
|
80731
|
+
if (since >= until) {
|
|
80732
|
+
throw new InvalidError("`since` must be before `until`.");
|
|
80733
|
+
}
|
|
80734
|
+
if (since.getTime() < 0) {
|
|
80735
|
+
throw new InvalidError("`since` must be at or after the Unix epoch.");
|
|
80736
|
+
}
|
|
80737
|
+
if (until.getTime() - since.getTime() > 31 * 24 * 60 * 60 * 1e3) {
|
|
80738
|
+
throw new InvalidError("Metrics time range cannot exceed 31 days.");
|
|
80739
|
+
}
|
|
80740
|
+
if (params.groups !== void 0 && (!Array.isArray(params.groups) || params.groups.some((g) => typeof g !== "string" || !g))) {
|
|
80741
|
+
throw new InvalidError(
|
|
80742
|
+
"`groups` must be an array of nonempty group names."
|
|
80743
|
+
);
|
|
80744
|
+
}
|
|
80745
|
+
const request = FunctionGetMetricsRequest.create({
|
|
80746
|
+
since,
|
|
80747
|
+
until,
|
|
80748
|
+
groups: params.groups ?? [],
|
|
80749
|
+
rollup: params.allVariants ?? false
|
|
80750
|
+
});
|
|
80751
|
+
if (params.bucketSizeSecs !== void 0) {
|
|
80752
|
+
const seconds = params.bucketSizeSecs;
|
|
80753
|
+
if (!Number.isInteger(seconds) || seconds < 60 || seconds > 2 ** 32 - 1) {
|
|
80754
|
+
throw new InvalidError(
|
|
80755
|
+
"`bucketSizeSecs` must be a whole number of seconds, at least one minute."
|
|
80756
|
+
);
|
|
80757
|
+
}
|
|
80758
|
+
if (Math.floor(until.getTime() / (params.bucketSizeSecs * 1e3)) - Math.floor(since.getTime() / (params.bucketSizeSecs * 1e3)) > 500) {
|
|
80759
|
+
throw new InvalidError(
|
|
80760
|
+
"Metrics are limited to 500 points per series; increase `bucketSizeSecs`."
|
|
80761
|
+
);
|
|
80762
|
+
}
|
|
80763
|
+
request.bucketSecs = seconds;
|
|
80764
|
+
}
|
|
80765
|
+
return request;
|
|
80766
|
+
}
|
|
80767
|
+
var FunctionMetricsManager = class {
|
|
80768
|
+
#client;
|
|
80769
|
+
#functionId;
|
|
80770
|
+
/** @hidden */
|
|
80771
|
+
constructor(client, functionId) {
|
|
80772
|
+
this.#client = client;
|
|
80773
|
+
this.#functionId = functionId;
|
|
80774
|
+
}
|
|
80775
|
+
/**
|
|
80776
|
+
* Fetch metric samples, defaulting to all groups over the last hour.
|
|
80777
|
+
*
|
|
80778
|
+
* The maximum range is 31 days, with at most 500 points per series. Omit
|
|
80779
|
+
* bucketSizeSecs to let Modal select a supported width targeting approximately
|
|
80780
|
+
* 100 buckets. Bounds round down to UTC bucket boundaries: data before since
|
|
80781
|
+
* may be included, and the partial bucket at until is excluded.
|
|
80782
|
+
* Missing observations have value null. Use schema() to discover definitions.
|
|
80783
|
+
*
|
|
80784
|
+
* @example
|
|
80785
|
+
* ```typescript
|
|
80786
|
+
* const metrics = await fn.metrics.export({
|
|
80787
|
+
* bucketSizeSecs: 5 * 60,
|
|
80788
|
+
* groups: ["calls"],
|
|
80789
|
+
* });
|
|
80790
|
+
* for (const point of metrics.series["successful_calls_count"].points) {
|
|
80791
|
+
* console.log(point.time, point.value);
|
|
80792
|
+
* }
|
|
80793
|
+
* ```
|
|
80794
|
+
*/
|
|
80795
|
+
async export(params = {}) {
|
|
80796
|
+
const request = metricsRequest(params);
|
|
80797
|
+
request.functionId = this.#functionId;
|
|
80798
|
+
const response = await this.#client.cpClient.functionGetMetrics(request);
|
|
80799
|
+
const series = Object.fromEntries(
|
|
80800
|
+
response.series.map((item) => [
|
|
80801
|
+
item.name,
|
|
80802
|
+
{
|
|
80803
|
+
name: item.name,
|
|
80804
|
+
unit: item.unit,
|
|
80805
|
+
aggregation: item.name.slice(item.name.lastIndexOf("_") + 1),
|
|
80806
|
+
description: item.description,
|
|
80807
|
+
points: item.points.map((point) => ({
|
|
80808
|
+
time: point.timestamp ?? /* @__PURE__ */ new Date(0),
|
|
80809
|
+
value: point.value ?? null
|
|
80810
|
+
}))
|
|
80811
|
+
}
|
|
80812
|
+
])
|
|
80813
|
+
);
|
|
80814
|
+
return {
|
|
80815
|
+
objectId: this.#functionId,
|
|
80816
|
+
since: response.since ?? /* @__PURE__ */ new Date(0),
|
|
80817
|
+
until: response.until ?? /* @__PURE__ */ new Date(0),
|
|
80818
|
+
bucketSizeSecs: response.bucketSecs,
|
|
80819
|
+
pointCount: Object.values(series).reduce(
|
|
80820
|
+
(count, item) => count + item.points.length,
|
|
80821
|
+
0
|
|
80822
|
+
),
|
|
80823
|
+
series
|
|
80824
|
+
};
|
|
80825
|
+
}
|
|
80826
|
+
/**
|
|
80827
|
+
* Return metric definitions keyed by group name, without fetching samples.
|
|
80828
|
+
* Omit groups to return all groups. Each group's definitions include all its
|
|
80829
|
+
* individual series.
|
|
80830
|
+
*/
|
|
80831
|
+
async schema(params = {}) {
|
|
80832
|
+
const window = metricsRequest(params);
|
|
80833
|
+
const response = await this.#client.cpClient.metricsGetInfo(
|
|
80834
|
+
MetricsGetInfoRequest.create({
|
|
80835
|
+
targetType: 1 /* METRICS_TARGET_TYPE_FUNCTION */,
|
|
80836
|
+
since: window.since,
|
|
80837
|
+
until: window.until,
|
|
80838
|
+
groups: window.groups
|
|
80839
|
+
})
|
|
80840
|
+
);
|
|
80841
|
+
const groups = /* @__PURE__ */ new Map();
|
|
80842
|
+
for (const row of response.groups) {
|
|
80843
|
+
let group = groups.get(row.name);
|
|
80844
|
+
if (!group) {
|
|
80845
|
+
group = { name: row.name, definitions: [] };
|
|
80846
|
+
groups.set(row.name, group);
|
|
80847
|
+
}
|
|
80848
|
+
group.definitions.push(
|
|
80849
|
+
...row.metrics.map((metric) => ({
|
|
80850
|
+
name: metric.name,
|
|
80851
|
+
unit: metric.unit,
|
|
80852
|
+
description: metric.description
|
|
80853
|
+
}))
|
|
80854
|
+
);
|
|
80855
|
+
}
|
|
80856
|
+
return Object.fromEntries(groups);
|
|
80857
|
+
}
|
|
80858
|
+
};
|
|
80859
|
+
|
|
80677
80860
|
// src/retries.ts
|
|
80678
80861
|
var Retries = class {
|
|
80679
80862
|
maxRetries;
|
|
@@ -81056,6 +81239,10 @@ var Function_ = class _Function_ {
|
|
|
81056
81239
|
this.#handleMetadata?.appId ?? ""
|
|
81057
81240
|
);
|
|
81058
81241
|
}
|
|
81242
|
+
/** Access metric samples with export() and series definitions with schema(). */
|
|
81243
|
+
get metrics() {
|
|
81244
|
+
return new FunctionMetricsManager(this.#client, this.functionId);
|
|
81245
|
+
}
|
|
81059
81246
|
/** Override the static Function configuration at runtime. */
|
|
81060
81247
|
withOptions(options) {
|
|
81061
81248
|
return new _Function_(
|
|
@@ -81621,6 +81808,7 @@ var ExperimentalOutboundPolicy2 = class _ExperimentalOutboundPolicy {
|
|
|
81621
81808
|
FunctionCallLogsManager,
|
|
81622
81809
|
FunctionCallService,
|
|
81623
81810
|
FunctionLogsManager,
|
|
81811
|
+
FunctionMetricsManager,
|
|
81624
81812
|
FunctionService,
|
|
81625
81813
|
FunctionTimeoutError,
|
|
81626
81814
|
Function_,
|
package/dist/index.d.cts
CHANGED
|
@@ -3320,7 +3320,7 @@ interface MethodDefinition {
|
|
|
3320
3320
|
supportedOutputFormats: DataFormat[];
|
|
3321
3321
|
}
|
|
3322
3322
|
declare const MethodDefinition: MessageFns$1<MethodDefinition>;
|
|
3323
|
-
interface MetricDefinition {
|
|
3323
|
+
interface MetricDefinition$1 {
|
|
3324
3324
|
/** Exact series name returned by the metrics RPC. */
|
|
3325
3325
|
name: string;
|
|
3326
3326
|
/** Matches FunctionMetricSeries.unit. */
|
|
@@ -3328,14 +3328,14 @@ interface MetricDefinition {
|
|
|
3328
3328
|
/** Meaning and aggregation semantics of the series. */
|
|
3329
3329
|
description: string;
|
|
3330
3330
|
}
|
|
3331
|
-
declare const MetricDefinition: MessageFns$1<MetricDefinition>;
|
|
3331
|
+
declare const MetricDefinition$1: MessageFns$1<MetricDefinition$1>;
|
|
3332
3332
|
interface MetricGroupDefinition {
|
|
3333
3333
|
/** Group selector, such as "calls". Multiple catalogue rows can share this name. */
|
|
3334
3334
|
name: string;
|
|
3335
3335
|
/** Shared description of this catalogue row's series. */
|
|
3336
3336
|
description: string;
|
|
3337
3337
|
/** Individual series represented by this row, ordered by name; all have the same unit. */
|
|
3338
|
-
metrics: MetricDefinition[];
|
|
3338
|
+
metrics: MetricDefinition$1[];
|
|
3339
3339
|
/** Display label, such as "execution_time_{p50,p90,p99}". */
|
|
3340
3340
|
displayName: string;
|
|
3341
3341
|
}
|
|
@@ -8186,7 +8186,12 @@ declare class FunctionCall {
|
|
|
8186
8186
|
readonly functionCallId: string;
|
|
8187
8187
|
/** @ignore */
|
|
8188
8188
|
constructor(client: ModalClient, functionCallId: string, appId: string, functionId: string);
|
|
8189
|
-
/**
|
|
8189
|
+
/**
|
|
8190
|
+
* Get the result of a FunctionCall, optionally waiting with a timeout.
|
|
8191
|
+
*
|
|
8192
|
+
* @throws {@link TimeoutError} if `timeoutMs` elapses before the Function finishes.
|
|
8193
|
+
* @throws {@link FunctionTimeoutError} if the Function exceeds its execution timeout.
|
|
8194
|
+
*/
|
|
8190
8195
|
get(params?: FunctionCallGetParams): Promise<any>;
|
|
8191
8196
|
/** Cancel a running FunctionCall. */
|
|
8192
8197
|
cancel(params?: FunctionCallCancelParams): Promise<void>;
|
|
@@ -8204,6 +8209,91 @@ declare class FunctionCall {
|
|
|
8204
8209
|
get logs(): FunctionCallLogsManager;
|
|
8205
8210
|
}
|
|
8206
8211
|
|
|
8212
|
+
/** An observation at a UTC-aligned bucket start. */
|
|
8213
|
+
interface TimeSeriesPoint {
|
|
8214
|
+
time: Date;
|
|
8215
|
+
/** Missing observations are null; observed zeroes remain zero. */
|
|
8216
|
+
value: number | null;
|
|
8217
|
+
}
|
|
8218
|
+
/** An individual metric series with points ordered by time. */
|
|
8219
|
+
interface MetricSeries {
|
|
8220
|
+
name: string;
|
|
8221
|
+
unit: string;
|
|
8222
|
+
aggregation: string;
|
|
8223
|
+
description: string;
|
|
8224
|
+
points: TimeSeriesPoint[];
|
|
8225
|
+
}
|
|
8226
|
+
/** The name, unit, and meaning of an exportable series. */
|
|
8227
|
+
interface MetricDefinition {
|
|
8228
|
+
name: string;
|
|
8229
|
+
unit: string;
|
|
8230
|
+
description: string;
|
|
8231
|
+
}
|
|
8232
|
+
/** A metrics group and its individual series definitions. */
|
|
8233
|
+
interface MetricsSchema {
|
|
8234
|
+
name: string;
|
|
8235
|
+
definitions: MetricDefinition[];
|
|
8236
|
+
}
|
|
8237
|
+
/** Exported metrics over the effective, UTC-aligned [since, until) range. */
|
|
8238
|
+
interface ObjectMetrics {
|
|
8239
|
+
objectId: string;
|
|
8240
|
+
since: Date;
|
|
8241
|
+
until: Date;
|
|
8242
|
+
bucketSizeSecs: number;
|
|
8243
|
+
/** Total points across series, including missing observations. */
|
|
8244
|
+
pointCount: number;
|
|
8245
|
+
series: Record<string, MetricSeries>;
|
|
8246
|
+
}
|
|
8247
|
+
/** Options for discovering metric definitions. */
|
|
8248
|
+
interface MetricsSchemaParams {
|
|
8249
|
+
/** Omit or pass an empty array to select all groups. */
|
|
8250
|
+
groups?: string[];
|
|
8251
|
+
}
|
|
8252
|
+
/** Options for exporting Function metric samples. */
|
|
8253
|
+
interface FunctionMetricsExportParams extends MetricsSchemaParams {
|
|
8254
|
+
/** Defaults to one hour before until. */
|
|
8255
|
+
since?: Date;
|
|
8256
|
+
/** Defaults to the current time. */
|
|
8257
|
+
until?: Date;
|
|
8258
|
+
/** Bucket width in whole seconds. */
|
|
8259
|
+
bucketSizeSecs?: number;
|
|
8260
|
+
/** Include the root Function and all its variants. Defaults to false. */
|
|
8261
|
+
allVariants?: boolean;
|
|
8262
|
+
}
|
|
8263
|
+
/** Namespace for Function metric samples and definitions. */
|
|
8264
|
+
declare class FunctionMetricsManager {
|
|
8265
|
+
#private;
|
|
8266
|
+
/** @hidden */
|
|
8267
|
+
constructor(client: ModalClient, functionId: string);
|
|
8268
|
+
/**
|
|
8269
|
+
* Fetch metric samples, defaulting to all groups over the last hour.
|
|
8270
|
+
*
|
|
8271
|
+
* The maximum range is 31 days, with at most 500 points per series. Omit
|
|
8272
|
+
* bucketSizeSecs to let Modal select a supported width targeting approximately
|
|
8273
|
+
* 100 buckets. Bounds round down to UTC bucket boundaries: data before since
|
|
8274
|
+
* may be included, and the partial bucket at until is excluded.
|
|
8275
|
+
* Missing observations have value null. Use schema() to discover definitions.
|
|
8276
|
+
*
|
|
8277
|
+
* @example
|
|
8278
|
+
* ```typescript
|
|
8279
|
+
* const metrics = await fn.metrics.export({
|
|
8280
|
+
* bucketSizeSecs: 5 * 60,
|
|
8281
|
+
* groups: ["calls"],
|
|
8282
|
+
* });
|
|
8283
|
+
* for (const point of metrics.series["successful_calls_count"].points) {
|
|
8284
|
+
* console.log(point.time, point.value);
|
|
8285
|
+
* }
|
|
8286
|
+
* ```
|
|
8287
|
+
*/
|
|
8288
|
+
export(params?: FunctionMetricsExportParams): Promise<ObjectMetrics>;
|
|
8289
|
+
/**
|
|
8290
|
+
* Return metric definitions keyed by group name, without fetching samples.
|
|
8291
|
+
* Omit groups to return all groups. Each group's definitions include all its
|
|
8292
|
+
* individual series.
|
|
8293
|
+
*/
|
|
8294
|
+
schema(params?: MetricsSchemaParams): Promise<Record<string, MetricsSchema>>;
|
|
8295
|
+
}
|
|
8296
|
+
|
|
8207
8297
|
type HeartbeatFunction = () => Promise<any>;
|
|
8208
8298
|
declare class EphemeralHeartbeatManager {
|
|
8209
8299
|
private readonly heartbeatFn;
|
|
@@ -8440,6 +8530,8 @@ declare class Function_ {
|
|
|
8440
8530
|
* for CLI access to logs for an App.
|
|
8441
8531
|
*/
|
|
8442
8532
|
get logs(): FunctionLogsManager;
|
|
8533
|
+
/** Access metric samples with export() and series definitions with schema(). */
|
|
8534
|
+
get metrics(): FunctionMetricsManager;
|
|
8443
8535
|
/** Override the static Function configuration at runtime. */
|
|
8444
8536
|
withOptions(options: FunctionWithOptionsParams): Function_;
|
|
8445
8537
|
/** Override the static Function concurrency configuration at runtime. */
|
|
@@ -10813,9 +10905,17 @@ declare class App {
|
|
|
10813
10905
|
declare class TimeoutError extends Error {
|
|
10814
10906
|
constructor(message?: string);
|
|
10815
10907
|
}
|
|
10816
|
-
/**
|
|
10908
|
+
/**
|
|
10909
|
+
* Function execution exceeds the allowed time limit.
|
|
10910
|
+
*
|
|
10911
|
+
* {@link FunctionCall#get FunctionCall.get()} throws {@link TimeoutError}
|
|
10912
|
+
* instead when `timeoutMs` elapses before the Function finishes. Matching that
|
|
10913
|
+
* case with `instanceof FunctionTimeoutError` is deprecated and will stop
|
|
10914
|
+
* working in a future release.
|
|
10915
|
+
*/
|
|
10817
10916
|
declare class FunctionTimeoutError extends Error {
|
|
10818
10917
|
constructor(message: string);
|
|
10918
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
10819
10919
|
}
|
|
10820
10920
|
/** An error on the Modal server, or a Python exception. */
|
|
10821
10921
|
declare class RemoteError extends Error {
|
|
@@ -10904,4 +11004,4 @@ declare class ClientClosedError extends Error {
|
|
|
10904
11004
|
|
|
10905
11005
|
declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
|
|
10906
11006
|
|
|
10907
|
-
export { AlreadyExistsError, App, type AppFromNameParams, type AppInfo, type AppInfoParams, type AppLifecycle, AppService, type AppState, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, Environment, EnvironmentAppsService, type EnvironmentCreateParams, type EnvironmentFromNameParams, EnvironmentObjectsService, EnvironmentService, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
|
|
11007
|
+
export { AlreadyExistsError, App, type AppFromNameParams, type AppInfo, type AppInfoParams, type AppLifecycle, AppService, type AppState, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, Environment, EnvironmentAppsService, type EnvironmentCreateParams, type EnvironmentFromNameParams, EnvironmentObjectsService, EnvironmentService, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, type FunctionMetricsExportParams, FunctionMetricsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, type MetricDefinition, type MetricSeries, type MetricsSchema, type MetricsSchemaParams, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type ObjectMetrics, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, type TimeSeriesPoint, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -3320,7 +3320,7 @@ interface MethodDefinition {
|
|
|
3320
3320
|
supportedOutputFormats: DataFormat[];
|
|
3321
3321
|
}
|
|
3322
3322
|
declare const MethodDefinition: MessageFns$1<MethodDefinition>;
|
|
3323
|
-
interface MetricDefinition {
|
|
3323
|
+
interface MetricDefinition$1 {
|
|
3324
3324
|
/** Exact series name returned by the metrics RPC. */
|
|
3325
3325
|
name: string;
|
|
3326
3326
|
/** Matches FunctionMetricSeries.unit. */
|
|
@@ -3328,14 +3328,14 @@ interface MetricDefinition {
|
|
|
3328
3328
|
/** Meaning and aggregation semantics of the series. */
|
|
3329
3329
|
description: string;
|
|
3330
3330
|
}
|
|
3331
|
-
declare const MetricDefinition: MessageFns$1<MetricDefinition>;
|
|
3331
|
+
declare const MetricDefinition$1: MessageFns$1<MetricDefinition$1>;
|
|
3332
3332
|
interface MetricGroupDefinition {
|
|
3333
3333
|
/** Group selector, such as "calls". Multiple catalogue rows can share this name. */
|
|
3334
3334
|
name: string;
|
|
3335
3335
|
/** Shared description of this catalogue row's series. */
|
|
3336
3336
|
description: string;
|
|
3337
3337
|
/** Individual series represented by this row, ordered by name; all have the same unit. */
|
|
3338
|
-
metrics: MetricDefinition[];
|
|
3338
|
+
metrics: MetricDefinition$1[];
|
|
3339
3339
|
/** Display label, such as "execution_time_{p50,p90,p99}". */
|
|
3340
3340
|
displayName: string;
|
|
3341
3341
|
}
|
|
@@ -8186,7 +8186,12 @@ declare class FunctionCall {
|
|
|
8186
8186
|
readonly functionCallId: string;
|
|
8187
8187
|
/** @ignore */
|
|
8188
8188
|
constructor(client: ModalClient, functionCallId: string, appId: string, functionId: string);
|
|
8189
|
-
/**
|
|
8189
|
+
/**
|
|
8190
|
+
* Get the result of a FunctionCall, optionally waiting with a timeout.
|
|
8191
|
+
*
|
|
8192
|
+
* @throws {@link TimeoutError} if `timeoutMs` elapses before the Function finishes.
|
|
8193
|
+
* @throws {@link FunctionTimeoutError} if the Function exceeds its execution timeout.
|
|
8194
|
+
*/
|
|
8190
8195
|
get(params?: FunctionCallGetParams): Promise<any>;
|
|
8191
8196
|
/** Cancel a running FunctionCall. */
|
|
8192
8197
|
cancel(params?: FunctionCallCancelParams): Promise<void>;
|
|
@@ -8204,6 +8209,91 @@ declare class FunctionCall {
|
|
|
8204
8209
|
get logs(): FunctionCallLogsManager;
|
|
8205
8210
|
}
|
|
8206
8211
|
|
|
8212
|
+
/** An observation at a UTC-aligned bucket start. */
|
|
8213
|
+
interface TimeSeriesPoint {
|
|
8214
|
+
time: Date;
|
|
8215
|
+
/** Missing observations are null; observed zeroes remain zero. */
|
|
8216
|
+
value: number | null;
|
|
8217
|
+
}
|
|
8218
|
+
/** An individual metric series with points ordered by time. */
|
|
8219
|
+
interface MetricSeries {
|
|
8220
|
+
name: string;
|
|
8221
|
+
unit: string;
|
|
8222
|
+
aggregation: string;
|
|
8223
|
+
description: string;
|
|
8224
|
+
points: TimeSeriesPoint[];
|
|
8225
|
+
}
|
|
8226
|
+
/** The name, unit, and meaning of an exportable series. */
|
|
8227
|
+
interface MetricDefinition {
|
|
8228
|
+
name: string;
|
|
8229
|
+
unit: string;
|
|
8230
|
+
description: string;
|
|
8231
|
+
}
|
|
8232
|
+
/** A metrics group and its individual series definitions. */
|
|
8233
|
+
interface MetricsSchema {
|
|
8234
|
+
name: string;
|
|
8235
|
+
definitions: MetricDefinition[];
|
|
8236
|
+
}
|
|
8237
|
+
/** Exported metrics over the effective, UTC-aligned [since, until) range. */
|
|
8238
|
+
interface ObjectMetrics {
|
|
8239
|
+
objectId: string;
|
|
8240
|
+
since: Date;
|
|
8241
|
+
until: Date;
|
|
8242
|
+
bucketSizeSecs: number;
|
|
8243
|
+
/** Total points across series, including missing observations. */
|
|
8244
|
+
pointCount: number;
|
|
8245
|
+
series: Record<string, MetricSeries>;
|
|
8246
|
+
}
|
|
8247
|
+
/** Options for discovering metric definitions. */
|
|
8248
|
+
interface MetricsSchemaParams {
|
|
8249
|
+
/** Omit or pass an empty array to select all groups. */
|
|
8250
|
+
groups?: string[];
|
|
8251
|
+
}
|
|
8252
|
+
/** Options for exporting Function metric samples. */
|
|
8253
|
+
interface FunctionMetricsExportParams extends MetricsSchemaParams {
|
|
8254
|
+
/** Defaults to one hour before until. */
|
|
8255
|
+
since?: Date;
|
|
8256
|
+
/** Defaults to the current time. */
|
|
8257
|
+
until?: Date;
|
|
8258
|
+
/** Bucket width in whole seconds. */
|
|
8259
|
+
bucketSizeSecs?: number;
|
|
8260
|
+
/** Include the root Function and all its variants. Defaults to false. */
|
|
8261
|
+
allVariants?: boolean;
|
|
8262
|
+
}
|
|
8263
|
+
/** Namespace for Function metric samples and definitions. */
|
|
8264
|
+
declare class FunctionMetricsManager {
|
|
8265
|
+
#private;
|
|
8266
|
+
/** @hidden */
|
|
8267
|
+
constructor(client: ModalClient, functionId: string);
|
|
8268
|
+
/**
|
|
8269
|
+
* Fetch metric samples, defaulting to all groups over the last hour.
|
|
8270
|
+
*
|
|
8271
|
+
* The maximum range is 31 days, with at most 500 points per series. Omit
|
|
8272
|
+
* bucketSizeSecs to let Modal select a supported width targeting approximately
|
|
8273
|
+
* 100 buckets. Bounds round down to UTC bucket boundaries: data before since
|
|
8274
|
+
* may be included, and the partial bucket at until is excluded.
|
|
8275
|
+
* Missing observations have value null. Use schema() to discover definitions.
|
|
8276
|
+
*
|
|
8277
|
+
* @example
|
|
8278
|
+
* ```typescript
|
|
8279
|
+
* const metrics = await fn.metrics.export({
|
|
8280
|
+
* bucketSizeSecs: 5 * 60,
|
|
8281
|
+
* groups: ["calls"],
|
|
8282
|
+
* });
|
|
8283
|
+
* for (const point of metrics.series["successful_calls_count"].points) {
|
|
8284
|
+
* console.log(point.time, point.value);
|
|
8285
|
+
* }
|
|
8286
|
+
* ```
|
|
8287
|
+
*/
|
|
8288
|
+
export(params?: FunctionMetricsExportParams): Promise<ObjectMetrics>;
|
|
8289
|
+
/**
|
|
8290
|
+
* Return metric definitions keyed by group name, without fetching samples.
|
|
8291
|
+
* Omit groups to return all groups. Each group's definitions include all its
|
|
8292
|
+
* individual series.
|
|
8293
|
+
*/
|
|
8294
|
+
schema(params?: MetricsSchemaParams): Promise<Record<string, MetricsSchema>>;
|
|
8295
|
+
}
|
|
8296
|
+
|
|
8207
8297
|
type HeartbeatFunction = () => Promise<any>;
|
|
8208
8298
|
declare class EphemeralHeartbeatManager {
|
|
8209
8299
|
private readonly heartbeatFn;
|
|
@@ -8440,6 +8530,8 @@ declare class Function_ {
|
|
|
8440
8530
|
* for CLI access to logs for an App.
|
|
8441
8531
|
*/
|
|
8442
8532
|
get logs(): FunctionLogsManager;
|
|
8533
|
+
/** Access metric samples with export() and series definitions with schema(). */
|
|
8534
|
+
get metrics(): FunctionMetricsManager;
|
|
8443
8535
|
/** Override the static Function configuration at runtime. */
|
|
8444
8536
|
withOptions(options: FunctionWithOptionsParams): Function_;
|
|
8445
8537
|
/** Override the static Function concurrency configuration at runtime. */
|
|
@@ -10813,9 +10905,17 @@ declare class App {
|
|
|
10813
10905
|
declare class TimeoutError extends Error {
|
|
10814
10906
|
constructor(message?: string);
|
|
10815
10907
|
}
|
|
10816
|
-
/**
|
|
10908
|
+
/**
|
|
10909
|
+
* Function execution exceeds the allowed time limit.
|
|
10910
|
+
*
|
|
10911
|
+
* {@link FunctionCall#get FunctionCall.get()} throws {@link TimeoutError}
|
|
10912
|
+
* instead when `timeoutMs` elapses before the Function finishes. Matching that
|
|
10913
|
+
* case with `instanceof FunctionTimeoutError` is deprecated and will stop
|
|
10914
|
+
* working in a future release.
|
|
10915
|
+
*/
|
|
10817
10916
|
declare class FunctionTimeoutError extends Error {
|
|
10818
10917
|
constructor(message: string);
|
|
10918
|
+
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
10819
10919
|
}
|
|
10820
10920
|
/** An error on the Modal server, or a Python exception. */
|
|
10821
10921
|
declare class RemoteError extends Error {
|
|
@@ -10904,4 +11004,4 @@ declare class ClientClosedError extends Error {
|
|
|
10904
11004
|
|
|
10905
11005
|
declare function checkForRenamedParams(params: any, renames: Record<string, string>): void;
|
|
10906
11006
|
|
|
10907
|
-
export { AlreadyExistsError, App, type AppFromNameParams, type AppInfo, type AppInfoParams, type AppLifecycle, AppService, type AppState, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, Environment, EnvironmentAppsService, type EnvironmentCreateParams, type EnvironmentFromNameParams, EnvironmentObjectsService, EnvironmentService, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
|
|
11007
|
+
export { AlreadyExistsError, App, type AppFromNameParams, type AppInfo, type AppInfoParams, type AppLifecycle, AppService, type AppState, ClientClosedError, CloudBucketMount, CloudBucketMountService, Cls, type ClsFromNameParams, ClsInstance, ClsService, type ClsWithBatchingParams, type ClsWithConcurrencyParams, type ClsWithOptionsParams, ConflictError, ContainerProcess, Environment, EnvironmentAppsService, type EnvironmentCreateParams, type EnvironmentFromNameParams, EnvironmentObjectsService, EnvironmentService, ExecutionError, ExperimentalOutboundPolicy, type FileInfo, type FileType, type FileWatchEvent, type FileWatchEventType, type FunctionAutoscalerSettings, FunctionCall, type FunctionCallCancelParams, type FunctionCallGetParams, type FunctionCallLogFetchParams, type FunctionCallLogStreamParams, type FunctionCallLogTailParams, FunctionCallLogsManager, FunctionCallService, type FunctionCurrentStats, type FunctionFromNameParams, type FunctionLogFetchParams, type FunctionLogStreamParams, type FunctionLogTailParams, FunctionLogsManager, type FunctionMetricsExportParams, FunctionMetricsManager, FunctionService, type FunctionStats, type FunctionStatsParams, FunctionTimeoutError, type FunctionUpdateAutoscalerParams, type FunctionWithBatchingParams, type FunctionWithConcurrencyParams, type FunctionWithOptionsParams, Function_, Image, type ImageDeleteParams, type ImageDockerfileCommandsParams, type ImageFromNameParams, type ImagePublishParams, ImageService, InternalFailure, InvalidError, type LogEntry, type FunctionLogFetchParams as LogFetchParams, type LogLevel, type LogSource, type Logger, type MetricDefinition, type MetricSeries, type MetricsSchema, type MetricsSchemaParams, ModalClient, type ModalClientParams, type ModalReadStream, type ModalWriteStream, NotFoundError, type ObjectMetrics, Probe, type ProbeParams, type Profile, Proxy, type ProxyFromNameParams, ProxyService, Queue, type QueueClearParams, type QueueDeleteParams, QueueEmptyError, type QueueEphemeralParams, type QueueFromNameParams, QueueFullError, type QueueGetParams, type QueueIterateParams, type QueueLenParams, type QueuePutParams, QueueService, RemoteError, ResourceExhaustedError, Retries, Sandbox, type SandboxCreateConnectCredentials, type SandboxCreateConnectTokenParams, type SandboxCreateParams, type SandboxExecParams, type SandboxExperimentalFromNameParams, type SandboxExperimentalFromSnapshotParams, type SandboxExperimentalGetExitSnapshotParams, type SandboxExperimentalListParams, SandboxFilesystem, SandboxFilesystemDirectoryNotEmptyError, SandboxFilesystemError, SandboxFilesystemFileTooLargeError, SandboxFilesystemIsADirectoryError, SandboxFilesystemNotADirectoryError, SandboxFilesystemNotFoundError, SandboxFilesystemPathAlreadyExistsError, SandboxFilesystemPermissionError, type SandboxFromNameParams, type SandboxListParams, type SandboxLogFetchParams, type SandboxLogTailParams, SandboxLogsManager, type SandboxMountImageParams, type SandboxReloadVolumesParams, type SandboxRuntime, SandboxService, SandboxSnapshot, type SandboxSnapshotDirectoryParams, type SandboxSnapshotFilesystemParams, SandboxSnapshotService, type SandboxTerminateParams, SandboxTimeoutError, type SandboxUpdateNetworkPolicyParams, Secret, type SecretDeleteParams, type SecretFromNameParams, type SecretFromObjectParams, SecretService, SidecarContainer, type SidecarCreateParams, type SidecarExecParams, type SidecarGetParams, type SidecarListParams, type SidecarMountImageParams, SidecarService, type SidecarSnapshotDirectoryParams, type SidecarSnapshotFilesystemParams, type SidecarTerminateParams, type SidecarUnmountImageParams, SnapshotCreationError, type StatsPercentile, type StatsPercentileDistribution, type StdioBehavior, type StreamMode, type TimeSeriesPoint, TimeoutError, Tunnel, Volume, type VolumeDeleteParams, type VolumeEphemeralParams, type VolumeFromNameParams, type VolumeMountOptionsParams, VolumeService, checkForRenamedParams };
|
package/dist/index.js
CHANGED
|
@@ -67536,11 +67536,40 @@ var TimeoutError = class extends Error {
|
|
|
67536
67536
|
this.name = "TimeoutError";
|
|
67537
67537
|
}
|
|
67538
67538
|
};
|
|
67539
|
-
var FunctionTimeoutError = class extends Error {
|
|
67539
|
+
var FunctionTimeoutError = class _FunctionTimeoutError extends Error {
|
|
67540
67540
|
constructor(message) {
|
|
67541
67541
|
super(message);
|
|
67542
67542
|
this.name = "FunctionTimeoutError";
|
|
67543
67543
|
}
|
|
67544
|
+
// Backward compatibility: FunctionCall.get() wait timeouts still match
|
|
67545
|
+
// FunctionTimeoutError, with a deprecation warning.
|
|
67546
|
+
static [Symbol.hasInstance](instance) {
|
|
67547
|
+
if (Function.prototype[Symbol.hasInstance].call(this, instance)) {
|
|
67548
|
+
return true;
|
|
67549
|
+
}
|
|
67550
|
+
if (this === _FunctionTimeoutError && instance instanceof FunctionCallGetTimeoutError) {
|
|
67551
|
+
instance.warnFunctionTimeoutErrorMatch();
|
|
67552
|
+
return true;
|
|
67553
|
+
}
|
|
67554
|
+
return false;
|
|
67555
|
+
}
|
|
67556
|
+
};
|
|
67557
|
+
var warnedFunctionTimeoutErrorMatch = false;
|
|
67558
|
+
var FunctionCallGetTimeoutError = class extends TimeoutError {
|
|
67559
|
+
#logger;
|
|
67560
|
+
constructor(message, logger2) {
|
|
67561
|
+
super(message);
|
|
67562
|
+
this.#logger = logger2;
|
|
67563
|
+
}
|
|
67564
|
+
warnFunctionTimeoutErrorMatch() {
|
|
67565
|
+
if (warnedFunctionTimeoutErrorMatch) {
|
|
67566
|
+
return;
|
|
67567
|
+
}
|
|
67568
|
+
warnedFunctionTimeoutErrorMatch = true;
|
|
67569
|
+
this.#logger.warn(
|
|
67570
|
+
"Matching a FunctionCall.get() timeout with `instanceof FunctionTimeoutError` is deprecated and will stop working in a future release; check `instanceof TimeoutError` first instead."
|
|
67571
|
+
);
|
|
67572
|
+
}
|
|
67544
67573
|
};
|
|
67545
67574
|
var RemoteError = class extends Error {
|
|
67546
67575
|
constructor(message) {
|
|
@@ -68120,12 +68149,14 @@ async function blobDownload(cpClient, blobId) {
|
|
|
68120
68149
|
var outputsTimeoutMs = 55 * 1e3;
|
|
68121
68150
|
var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
68122
68151
|
cpClient;
|
|
68152
|
+
logger;
|
|
68123
68153
|
functionCallId;
|
|
68124
68154
|
input;
|
|
68125
68155
|
functionCallJwt;
|
|
68126
68156
|
inputJwt;
|
|
68127
|
-
constructor(cpClient, functionCallId, input, functionCallJwt, inputJwt) {
|
|
68157
|
+
constructor(cpClient, logger2, functionCallId, input, functionCallJwt, inputJwt) {
|
|
68128
68158
|
this.cpClient = cpClient;
|
|
68159
|
+
this.logger = logger2;
|
|
68129
68160
|
this.functionCallId = functionCallId;
|
|
68130
68161
|
this.input = input;
|
|
68131
68162
|
this.functionCallJwt = functionCallJwt;
|
|
@@ -68144,6 +68175,7 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68144
68175
|
});
|
|
68145
68176
|
return new _ControlPlaneInvocation(
|
|
68146
68177
|
client.cpClient,
|
|
68178
|
+
client.logger,
|
|
68147
68179
|
functionMapResponse.functionCallId,
|
|
68148
68180
|
input,
|
|
68149
68181
|
functionMapResponse.functionCallJwt,
|
|
@@ -68151,11 +68183,16 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68151
68183
|
);
|
|
68152
68184
|
}
|
|
68153
68185
|
static fromFunctionCallId(client, functionCallId) {
|
|
68154
|
-
return new _ControlPlaneInvocation(
|
|
68186
|
+
return new _ControlPlaneInvocation(
|
|
68187
|
+
client.cpClient,
|
|
68188
|
+
client.logger,
|
|
68189
|
+
functionCallId
|
|
68190
|
+
);
|
|
68155
68191
|
}
|
|
68156
68192
|
async awaitOutput(timeoutMs, clearOnSuccess = false) {
|
|
68157
68193
|
return await pollFunctionOutput(
|
|
68158
68194
|
this.cpClient,
|
|
68195
|
+
this.logger,
|
|
68159
68196
|
(timeoutMs2) => this.#getOutput(
|
|
68160
68197
|
timeoutMs2,
|
|
68161
68198
|
clearOnSuccess,
|
|
@@ -68195,12 +68232,14 @@ var ControlPlaneInvocation = class _ControlPlaneInvocation {
|
|
|
68195
68232
|
var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
68196
68233
|
cpClient;
|
|
68197
68234
|
ipClient;
|
|
68235
|
+
logger;
|
|
68198
68236
|
functionId;
|
|
68199
68237
|
input;
|
|
68200
68238
|
attemptToken;
|
|
68201
|
-
constructor(cpClient, ipClient, functionId, input, attemptToken) {
|
|
68239
|
+
constructor(cpClient, ipClient, logger2, functionId, input, attemptToken) {
|
|
68202
68240
|
this.cpClient = cpClient;
|
|
68203
68241
|
this.ipClient = ipClient;
|
|
68242
|
+
this.logger = logger2;
|
|
68204
68243
|
this.functionId = functionId;
|
|
68205
68244
|
this.input = input;
|
|
68206
68245
|
this.attemptToken = attemptToken;
|
|
@@ -68218,6 +68257,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68218
68257
|
return new _InputPlaneInvocation(
|
|
68219
68258
|
client.cpClient,
|
|
68220
68259
|
ipClient,
|
|
68260
|
+
client.logger,
|
|
68221
68261
|
functionId,
|
|
68222
68262
|
functionPutInputsItem,
|
|
68223
68263
|
attemptStartResponse.attemptToken
|
|
@@ -68226,6 +68266,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68226
68266
|
async awaitOutput(timeoutMs) {
|
|
68227
68267
|
return await pollFunctionOutput(
|
|
68228
68268
|
this.cpClient,
|
|
68269
|
+
this.logger,
|
|
68229
68270
|
(timeoutMs2) => this.#getOutput(timeoutMs2),
|
|
68230
68271
|
timeoutMs
|
|
68231
68272
|
);
|
|
@@ -68250,7 +68291,7 @@ var InputPlaneInvocation = class _InputPlaneInvocation {
|
|
|
68250
68291
|
function timeNowSeconds() {
|
|
68251
68292
|
return Date.now() / 1e3;
|
|
68252
68293
|
}
|
|
68253
|
-
async function pollFunctionOutput(cpClient, getOutput, timeoutMs) {
|
|
68294
|
+
async function pollFunctionOutput(cpClient, logger2, getOutput, timeoutMs) {
|
|
68254
68295
|
const startTime = Date.now();
|
|
68255
68296
|
let pollTimeoutMs = outputsTimeoutMs;
|
|
68256
68297
|
if (timeoutMs !== void 0) {
|
|
@@ -68265,7 +68306,7 @@ async function pollFunctionOutput(cpClient, getOutput, timeoutMs) {
|
|
|
68265
68306
|
const remainingMs = timeoutMs - (Date.now() - startTime);
|
|
68266
68307
|
if (remainingMs <= 0) {
|
|
68267
68308
|
const message = `Timeout exceeded: ${timeoutMs}ms`;
|
|
68268
|
-
throw new
|
|
68309
|
+
throw new FunctionCallGetTimeoutError(message, logger2);
|
|
68269
68310
|
}
|
|
68270
68311
|
pollTimeoutMs = Math.min(outputsTimeoutMs, remainingMs);
|
|
68271
68312
|
}
|
|
@@ -78916,7 +78957,7 @@ var AuthTokenManager = class {
|
|
|
78916
78957
|
};
|
|
78917
78958
|
|
|
78918
78959
|
// src/version.ts
|
|
78919
|
-
var SDK_VERSION = "0.11.1-dev.
|
|
78960
|
+
var SDK_VERSION = "0.11.1-dev.15";
|
|
78920
78961
|
function getSDKVersion() {
|
|
78921
78962
|
return SDK_VERSION;
|
|
78922
78963
|
}
|
|
@@ -80552,7 +80593,12 @@ var FunctionCall = class {
|
|
|
80552
80593
|
this.#client = client;
|
|
80553
80594
|
this.functionCallId = functionCallId;
|
|
80554
80595
|
}
|
|
80555
|
-
/**
|
|
80596
|
+
/**
|
|
80597
|
+
* Get the result of a FunctionCall, optionally waiting with a timeout.
|
|
80598
|
+
*
|
|
80599
|
+
* @throws {@link TimeoutError} if `timeoutMs` elapses before the Function finishes.
|
|
80600
|
+
* @throws {@link FunctionTimeoutError} if the Function exceeds its execution timeout.
|
|
80601
|
+
*/
|
|
80556
80602
|
async get(params = {}) {
|
|
80557
80603
|
checkForRenamedParams(params, { timeout: "timeoutMs" });
|
|
80558
80604
|
const invocation = ControlPlaneInvocation.fromFunctionCallId(
|
|
@@ -80593,6 +80639,142 @@ var FunctionCall = class {
|
|
|
80593
80639
|
// src/function.ts
|
|
80594
80640
|
import { ClientError as ClientError16, Status as Status16 } from "nice-grpc";
|
|
80595
80641
|
|
|
80642
|
+
// src/metrics.ts
|
|
80643
|
+
function metricsRequest(params) {
|
|
80644
|
+
const until = params.until ?? /* @__PURE__ */ new Date();
|
|
80645
|
+
const since = params.since ?? new Date(until.getTime() - 60 * 60 * 1e3);
|
|
80646
|
+
if (!Number.isFinite(since.getTime()) || !Number.isFinite(until.getTime())) {
|
|
80647
|
+
throw new InvalidError("`since` and `until` must be valid dates.");
|
|
80648
|
+
}
|
|
80649
|
+
if (since >= until) {
|
|
80650
|
+
throw new InvalidError("`since` must be before `until`.");
|
|
80651
|
+
}
|
|
80652
|
+
if (since.getTime() < 0) {
|
|
80653
|
+
throw new InvalidError("`since` must be at or after the Unix epoch.");
|
|
80654
|
+
}
|
|
80655
|
+
if (until.getTime() - since.getTime() > 31 * 24 * 60 * 60 * 1e3) {
|
|
80656
|
+
throw new InvalidError("Metrics time range cannot exceed 31 days.");
|
|
80657
|
+
}
|
|
80658
|
+
if (params.groups !== void 0 && (!Array.isArray(params.groups) || params.groups.some((g) => typeof g !== "string" || !g))) {
|
|
80659
|
+
throw new InvalidError(
|
|
80660
|
+
"`groups` must be an array of nonempty group names."
|
|
80661
|
+
);
|
|
80662
|
+
}
|
|
80663
|
+
const request = FunctionGetMetricsRequest.create({
|
|
80664
|
+
since,
|
|
80665
|
+
until,
|
|
80666
|
+
groups: params.groups ?? [],
|
|
80667
|
+
rollup: params.allVariants ?? false
|
|
80668
|
+
});
|
|
80669
|
+
if (params.bucketSizeSecs !== void 0) {
|
|
80670
|
+
const seconds = params.bucketSizeSecs;
|
|
80671
|
+
if (!Number.isInteger(seconds) || seconds < 60 || seconds > 2 ** 32 - 1) {
|
|
80672
|
+
throw new InvalidError(
|
|
80673
|
+
"`bucketSizeSecs` must be a whole number of seconds, at least one minute."
|
|
80674
|
+
);
|
|
80675
|
+
}
|
|
80676
|
+
if (Math.floor(until.getTime() / (params.bucketSizeSecs * 1e3)) - Math.floor(since.getTime() / (params.bucketSizeSecs * 1e3)) > 500) {
|
|
80677
|
+
throw new InvalidError(
|
|
80678
|
+
"Metrics are limited to 500 points per series; increase `bucketSizeSecs`."
|
|
80679
|
+
);
|
|
80680
|
+
}
|
|
80681
|
+
request.bucketSecs = seconds;
|
|
80682
|
+
}
|
|
80683
|
+
return request;
|
|
80684
|
+
}
|
|
80685
|
+
var FunctionMetricsManager = class {
|
|
80686
|
+
#client;
|
|
80687
|
+
#functionId;
|
|
80688
|
+
/** @hidden */
|
|
80689
|
+
constructor(client, functionId) {
|
|
80690
|
+
this.#client = client;
|
|
80691
|
+
this.#functionId = functionId;
|
|
80692
|
+
}
|
|
80693
|
+
/**
|
|
80694
|
+
* Fetch metric samples, defaulting to all groups over the last hour.
|
|
80695
|
+
*
|
|
80696
|
+
* The maximum range is 31 days, with at most 500 points per series. Omit
|
|
80697
|
+
* bucketSizeSecs to let Modal select a supported width targeting approximately
|
|
80698
|
+
* 100 buckets. Bounds round down to UTC bucket boundaries: data before since
|
|
80699
|
+
* may be included, and the partial bucket at until is excluded.
|
|
80700
|
+
* Missing observations have value null. Use schema() to discover definitions.
|
|
80701
|
+
*
|
|
80702
|
+
* @example
|
|
80703
|
+
* ```typescript
|
|
80704
|
+
* const metrics = await fn.metrics.export({
|
|
80705
|
+
* bucketSizeSecs: 5 * 60,
|
|
80706
|
+
* groups: ["calls"],
|
|
80707
|
+
* });
|
|
80708
|
+
* for (const point of metrics.series["successful_calls_count"].points) {
|
|
80709
|
+
* console.log(point.time, point.value);
|
|
80710
|
+
* }
|
|
80711
|
+
* ```
|
|
80712
|
+
*/
|
|
80713
|
+
async export(params = {}) {
|
|
80714
|
+
const request = metricsRequest(params);
|
|
80715
|
+
request.functionId = this.#functionId;
|
|
80716
|
+
const response = await this.#client.cpClient.functionGetMetrics(request);
|
|
80717
|
+
const series = Object.fromEntries(
|
|
80718
|
+
response.series.map((item) => [
|
|
80719
|
+
item.name,
|
|
80720
|
+
{
|
|
80721
|
+
name: item.name,
|
|
80722
|
+
unit: item.unit,
|
|
80723
|
+
aggregation: item.name.slice(item.name.lastIndexOf("_") + 1),
|
|
80724
|
+
description: item.description,
|
|
80725
|
+
points: item.points.map((point) => ({
|
|
80726
|
+
time: point.timestamp ?? /* @__PURE__ */ new Date(0),
|
|
80727
|
+
value: point.value ?? null
|
|
80728
|
+
}))
|
|
80729
|
+
}
|
|
80730
|
+
])
|
|
80731
|
+
);
|
|
80732
|
+
return {
|
|
80733
|
+
objectId: this.#functionId,
|
|
80734
|
+
since: response.since ?? /* @__PURE__ */ new Date(0),
|
|
80735
|
+
until: response.until ?? /* @__PURE__ */ new Date(0),
|
|
80736
|
+
bucketSizeSecs: response.bucketSecs,
|
|
80737
|
+
pointCount: Object.values(series).reduce(
|
|
80738
|
+
(count, item) => count + item.points.length,
|
|
80739
|
+
0
|
|
80740
|
+
),
|
|
80741
|
+
series
|
|
80742
|
+
};
|
|
80743
|
+
}
|
|
80744
|
+
/**
|
|
80745
|
+
* Return metric definitions keyed by group name, without fetching samples.
|
|
80746
|
+
* Omit groups to return all groups. Each group's definitions include all its
|
|
80747
|
+
* individual series.
|
|
80748
|
+
*/
|
|
80749
|
+
async schema(params = {}) {
|
|
80750
|
+
const window = metricsRequest(params);
|
|
80751
|
+
const response = await this.#client.cpClient.metricsGetInfo(
|
|
80752
|
+
MetricsGetInfoRequest.create({
|
|
80753
|
+
targetType: 1 /* METRICS_TARGET_TYPE_FUNCTION */,
|
|
80754
|
+
since: window.since,
|
|
80755
|
+
until: window.until,
|
|
80756
|
+
groups: window.groups
|
|
80757
|
+
})
|
|
80758
|
+
);
|
|
80759
|
+
const groups = /* @__PURE__ */ new Map();
|
|
80760
|
+
for (const row of response.groups) {
|
|
80761
|
+
let group = groups.get(row.name);
|
|
80762
|
+
if (!group) {
|
|
80763
|
+
group = { name: row.name, definitions: [] };
|
|
80764
|
+
groups.set(row.name, group);
|
|
80765
|
+
}
|
|
80766
|
+
group.definitions.push(
|
|
80767
|
+
...row.metrics.map((metric) => ({
|
|
80768
|
+
name: metric.name,
|
|
80769
|
+
unit: metric.unit,
|
|
80770
|
+
description: metric.description
|
|
80771
|
+
}))
|
|
80772
|
+
);
|
|
80773
|
+
}
|
|
80774
|
+
return Object.fromEntries(groups);
|
|
80775
|
+
}
|
|
80776
|
+
};
|
|
80777
|
+
|
|
80596
80778
|
// src/retries.ts
|
|
80597
80779
|
var Retries = class {
|
|
80598
80780
|
maxRetries;
|
|
@@ -80975,6 +81157,10 @@ var Function_ = class _Function_ {
|
|
|
80975
81157
|
this.#handleMetadata?.appId ?? ""
|
|
80976
81158
|
);
|
|
80977
81159
|
}
|
|
81160
|
+
/** Access metric samples with export() and series definitions with schema(). */
|
|
81161
|
+
get metrics() {
|
|
81162
|
+
return new FunctionMetricsManager(this.#client, this.functionId);
|
|
81163
|
+
}
|
|
80978
81164
|
/** Override the static Function configuration at runtime. */
|
|
80979
81165
|
withOptions(options) {
|
|
80980
81166
|
return new _Function_(
|
|
@@ -81539,6 +81725,7 @@ export {
|
|
|
81539
81725
|
FunctionCallLogsManager,
|
|
81540
81726
|
FunctionCallService,
|
|
81541
81727
|
FunctionLogsManager,
|
|
81728
|
+
FunctionMetricsManager,
|
|
81542
81729
|
FunctionService,
|
|
81543
81730
|
FunctionTimeoutError,
|
|
81544
81731
|
Function_,
|