dt-js-runtime
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDynatrace JavaScript Runtime
Dynatrace JavaScript Runtime
The Dynatrace JS runtime is a server-side AppEngine sandbox that executes JavaScript/TypeScript.
Dynatrace JS 运行时是一个执行 JavaScript/TypeScript 的服务器端 AppEngine 沙箱。
Function contract
函数约定
Every entry point must export a default async function:
js
export default async function () {
// ...
return result;
}ES module syntax required. TypeScript accepted (type annotations, interfaces, generics). No other export shape is supported.
每个入口点必须导出一个默认的异步函数:
js
export default async function () {
// ...
return result;
}要求使用 ES 模块语法。支持 TypeScript(类型注解、接口、泛型)。不支持其他导出形式。
References
参考文档
Start here, then load only the file you need.
| File | When to load |
|---|---|
| references/limits-and-restrictions.md | Timeout / memory / I/O quotas; what's forbidden ( |
| references/apis-and-modules.md | Which Web APIs and Node.js compat modules are available (fetch, crypto, streams, buffer, …) |
| references/fetch.md | Calling internal |
| references/sdk.md | Any |
从这里开始,然后仅加载你需要的文件。
| 文件 | 加载场景 |
|---|---|
| references/limits-and-restrictions.md | 超时/内存/I/O 配额;禁用内容( |
| references/apis-and-modules.md | 可用的 Web API 和 Node.js 兼容模块(fetch、crypto、streams、buffer 等) |
| references/fetch.md | 调用内部 |
| references/sdk.md | 所有 |
Running a function with dtctl
使用 dtctl 运行函数
Use to run JS runtime code without deploying an app.
dtctl exec functiondtctl
undefined使用 无需部署应用即可运行 JS 运行时代码。
dtctl exec functiondtctl
undefinedRun inline code
Run inline code
dtctl exec function --code 'export default async function() { return "hello" }'
dtctl exec function --code 'export default async function() { return "hello" }'
Run from file
Run from file
dtctl exec function -f script.js
dtctl exec function -f script.js
Pass JSON input — accessed as event.payload inside the function
Pass JSON input — accessed as event.payload inside the function
dtctl exec function -f script.js --payload '{"key":"value"}'
The function may accept an optional `event` parameter:
```js
export default async function(event) {
const { payload } = event; // from --payload
// event.environmentId also available
return payload;
}Load the skill for authentication setup, context switching, and the full reference.
dynatrace-controlexec functiondtctl exec function -f script.js --payload '{"key":"value"}'
函数可以接受一个可选的 `event` 参数:
```js
export default async function(event) {
const { payload } = event; // from --payload
// event.environmentId also available
return payload;
}加载 skill 以完成身份验证设置、上下文切换,以及获取完整的 参考信息。
dynatrace-controlexec function