dt-js-runtime

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Dynatrace 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.
FileWhen to load
references/limits-and-restrictions.mdTimeout / memory / I/O quotas; what's forbidden (
eval
, WebSocket, sockets, filesystem)
references/apis-and-modules.mdWhich Web APIs and Node.js compat modules are available (fetch, crypto, streams, buffer, …)
references/fetch.mdCalling internal
/platform/...
APIs or external URLs, credential vault, outbound allowlist
references/sdk.mdAny
@dynatrace-sdk/*
package — the index routes you to the right per-SDK file
从这里开始,然后仅加载你需要的文件。
文件加载场景
references/limits-and-restrictions.md超时/内存/I/O 配额;禁用内容(
eval
、WebSocket、套接字、文件系统)
references/apis-and-modules.md可用的 Web API 和 Node.js 兼容模块(fetch、crypto、streams、buffer 等)
references/fetch.md调用内部
/platform/...
API 或外部 URL、凭证库、出站白名单
references/sdk.md所有
@dynatrace-sdk/*
包——索引会引导你找到对应的各 SDK 文件

Running a function with dtctl

使用 dtctl 运行函数

Use
dtctl exec function
to run JS runtime code without deploying an app.
dtctl
undefined
使用
dtctl exec function
无需部署应用即可运行 JS 运行时代码。
dtctl
undefined

Run 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
dynatrace-control
skill for authentication setup, context switching, and the full
exec function
reference.
dtctl 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;
}
加载
dynatrace-control
skill 以完成身份验证设置、上下文切换,以及获取完整的
exec function
参考信息。