modal 0.5.1 → 0.5.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.
- package/README.md +9 -0
- package/dist/index.cjs +8 -2
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,6 +50,11 @@ We also provide a number of examples:
|
|
|
50
50
|
- [Mount a cloud bucket to a Sandbox](https://github.com/modal-labs/libmodal/blob/main/modal-js/examples/sandbox-cloud-bucket.ts)
|
|
51
51
|
- [Eagerly build an Image for a Sandbox](https://github.com/modal-labs/libmodal/blob/main/modal-js/examples/sandbox-prewarm.ts)
|
|
52
52
|
- [Building custom Images](https://github.com/modal-labs/libmodal/blob/main/modal-js/examples/image-building.ts)
|
|
53
|
+
- [Add telemetry and tracing with custom middleware](https://github.com/modal-labs/libmodal/blob/main/modal-js/examples/telemetry.ts)
|
|
54
|
+
|
|
55
|
+
### Configuration
|
|
56
|
+
|
|
57
|
+
The config file path can be customized via `MODAL_CONFIG_PATH` (defaults to `~/.modal.toml`).
|
|
53
58
|
|
|
54
59
|
### Authenticating with Modal
|
|
55
60
|
|
|
@@ -61,6 +66,10 @@ export MODAL_TOKEN_ID=ak-NOTAREALTOKENSTRINGXYZ
|
|
|
61
66
|
export MODAL_TOKEN_SECRET=as-FAKESECRETSTRINGABCDEF
|
|
62
67
|
```
|
|
63
68
|
|
|
69
|
+
### Telemetry and Observability
|
|
70
|
+
|
|
71
|
+
The Modal JavaScript SDK supports custom gRPC middleware for telemetry, tracing, and observability. You can add custom middleware to measure API call latency, trace requests, and integrate with observability tools like OpenTelemetry, DataDog, and others. See the [telemetry example](https://github.com/modal-labs/libmodal/blob/main/modal-js/examples/telemetry.ts) for more details.
|
|
72
|
+
|
|
64
73
|
## Support
|
|
65
74
|
|
|
66
75
|
For usage questions and other support, please reach out on the [Modal Community Slack](https://modal.com/slack).
|
package/dist/index.cjs
CHANGED
|
@@ -46695,7 +46695,7 @@ var AuthTokenManager = class {
|
|
|
46695
46695
|
|
|
46696
46696
|
// src/version.ts
|
|
46697
46697
|
function getSDKVersion() {
|
|
46698
|
-
return true ? "0.5.
|
|
46698
|
+
return true ? "0.5.3" : "0.0.0";
|
|
46699
46699
|
}
|
|
46700
46700
|
|
|
46701
46701
|
// src/logger.ts
|
|
@@ -46822,6 +46822,7 @@ var ModalClient = class {
|
|
|
46822
46822
|
logger;
|
|
46823
46823
|
ipClients;
|
|
46824
46824
|
authTokenManager = null;
|
|
46825
|
+
customMiddleware;
|
|
46825
46826
|
constructor(params) {
|
|
46826
46827
|
checkForRenamedParams(params, { timeout: "timeoutMs" });
|
|
46827
46828
|
const baseProfile = getProfile(process.env["MODAL_PROFILE"]);
|
|
@@ -46840,6 +46841,7 @@ var ModalClient = class {
|
|
|
46840
46841
|
"server_url",
|
|
46841
46842
|
this.profile.serverUrl
|
|
46842
46843
|
);
|
|
46844
|
+
this.customMiddleware = params?.grpcMiddleware ?? [];
|
|
46843
46845
|
this.ipClients = /* @__PURE__ */ new Map();
|
|
46844
46846
|
this.cpClient = params?.cpClient ?? this.createClient(this.profile);
|
|
46845
46847
|
this.logger.debug("Modal client initialized successfully");
|
|
@@ -46889,7 +46891,11 @@ var ModalClient = class {
|
|
|
46889
46891
|
"grpc.max_send_message_length": 100 * 1024 * 1024,
|
|
46890
46892
|
"grpc-node.flow_control_window": 64 * 1024 * 1024
|
|
46891
46893
|
});
|
|
46892
|
-
|
|
46894
|
+
let factory = (0, import_nice_grpc10.createClientFactory)().use(this.authMiddleware(profile)).use(this.retryMiddleware()).use(timeoutMiddleware);
|
|
46895
|
+
for (const middleware of this.customMiddleware) {
|
|
46896
|
+
factory = factory.use(middleware);
|
|
46897
|
+
}
|
|
46898
|
+
return factory.create(ModalClientDefinition, channel);
|
|
46893
46899
|
}
|
|
46894
46900
|
/** Middleware to retry transient errors and timeouts for unary requests. */
|
|
46895
46901
|
retryMiddleware() {
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, Status } from 'nice-grpc';
|
|
1
|
+
import { Client, Status, ClientMiddleware } from 'nice-grpc';
|
|
2
2
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -5895,6 +5895,16 @@ interface ModalClientParams {
|
|
|
5895
5895
|
maxRetries?: number;
|
|
5896
5896
|
logger?: Logger;
|
|
5897
5897
|
logLevel?: LogLevel;
|
|
5898
|
+
/**
|
|
5899
|
+
* Custom gRPC middleware to be applied to all API calls.
|
|
5900
|
+
* These middleware are appended after Modal's built-in middleware
|
|
5901
|
+
* (authentication, retry logic, and timeouts), allowing you to add
|
|
5902
|
+
* telemetry, tracing, or other observability features.
|
|
5903
|
+
*
|
|
5904
|
+
* Note that the Modal gRPC API is not considered a public API, and
|
|
5905
|
+
* can change without warning.
|
|
5906
|
+
*/
|
|
5907
|
+
grpcMiddleware?: ClientMiddleware[];
|
|
5898
5908
|
/** @ignore */
|
|
5899
5909
|
cpClient?: ModalGrpcClient;
|
|
5900
5910
|
}
|
|
@@ -5934,6 +5944,7 @@ declare class ModalClient {
|
|
|
5934
5944
|
readonly logger: Logger;
|
|
5935
5945
|
private ipClients;
|
|
5936
5946
|
private authTokenManager;
|
|
5947
|
+
private customMiddleware;
|
|
5937
5948
|
constructor(params?: ModalClientParams);
|
|
5938
5949
|
environmentName(environment?: string): string;
|
|
5939
5950
|
imageBuilderVersion(version?: string): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Client, Status } from 'nice-grpc';
|
|
1
|
+
import { Client, Status, ClientMiddleware } from 'nice-grpc';
|
|
2
2
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -5895,6 +5895,16 @@ interface ModalClientParams {
|
|
|
5895
5895
|
maxRetries?: number;
|
|
5896
5896
|
logger?: Logger;
|
|
5897
5897
|
logLevel?: LogLevel;
|
|
5898
|
+
/**
|
|
5899
|
+
* Custom gRPC middleware to be applied to all API calls.
|
|
5900
|
+
* These middleware are appended after Modal's built-in middleware
|
|
5901
|
+
* (authentication, retry logic, and timeouts), allowing you to add
|
|
5902
|
+
* telemetry, tracing, or other observability features.
|
|
5903
|
+
*
|
|
5904
|
+
* Note that the Modal gRPC API is not considered a public API, and
|
|
5905
|
+
* can change without warning.
|
|
5906
|
+
*/
|
|
5907
|
+
grpcMiddleware?: ClientMiddleware[];
|
|
5898
5908
|
/** @ignore */
|
|
5899
5909
|
cpClient?: ModalGrpcClient;
|
|
5900
5910
|
}
|
|
@@ -5934,6 +5944,7 @@ declare class ModalClient {
|
|
|
5934
5944
|
readonly logger: Logger;
|
|
5935
5945
|
private ipClients;
|
|
5936
5946
|
private authTokenManager;
|
|
5947
|
+
private customMiddleware;
|
|
5937
5948
|
constructor(params?: ModalClientParams);
|
|
5938
5949
|
environmentName(environment?: string): string;
|
|
5939
5950
|
imageBuilderVersion(version?: string): string;
|
package/dist/index.js
CHANGED
|
@@ -46628,7 +46628,7 @@ var AuthTokenManager = class {
|
|
|
46628
46628
|
|
|
46629
46629
|
// src/version.ts
|
|
46630
46630
|
function getSDKVersion() {
|
|
46631
|
-
return true ? "0.5.
|
|
46631
|
+
return true ? "0.5.3" : "0.0.0";
|
|
46632
46632
|
}
|
|
46633
46633
|
|
|
46634
46634
|
// src/logger.ts
|
|
@@ -46755,6 +46755,7 @@ var ModalClient = class {
|
|
|
46755
46755
|
logger;
|
|
46756
46756
|
ipClients;
|
|
46757
46757
|
authTokenManager = null;
|
|
46758
|
+
customMiddleware;
|
|
46758
46759
|
constructor(params) {
|
|
46759
46760
|
checkForRenamedParams(params, { timeout: "timeoutMs" });
|
|
46760
46761
|
const baseProfile = getProfile(process.env["MODAL_PROFILE"]);
|
|
@@ -46773,6 +46774,7 @@ var ModalClient = class {
|
|
|
46773
46774
|
"server_url",
|
|
46774
46775
|
this.profile.serverUrl
|
|
46775
46776
|
);
|
|
46777
|
+
this.customMiddleware = params?.grpcMiddleware ?? [];
|
|
46776
46778
|
this.ipClients = /* @__PURE__ */ new Map();
|
|
46777
46779
|
this.cpClient = params?.cpClient ?? this.createClient(this.profile);
|
|
46778
46780
|
this.logger.debug("Modal client initialized successfully");
|
|
@@ -46822,7 +46824,11 @@ var ModalClient = class {
|
|
|
46822
46824
|
"grpc.max_send_message_length": 100 * 1024 * 1024,
|
|
46823
46825
|
"grpc-node.flow_control_window": 64 * 1024 * 1024
|
|
46824
46826
|
});
|
|
46825
|
-
|
|
46827
|
+
let factory = createClientFactory().use(this.authMiddleware(profile)).use(this.retryMiddleware()).use(timeoutMiddleware);
|
|
46828
|
+
for (const middleware of this.customMiddleware) {
|
|
46829
|
+
factory = factory.use(middleware);
|
|
46830
|
+
}
|
|
46831
|
+
return factory.create(ModalClientDefinition, channel);
|
|
46826
46832
|
}
|
|
46827
46833
|
/** Middleware to retry transient errors and timeouts for unary requests. */
|
|
46828
46834
|
retryMiddleware() {
|