# @elastic/opentelemetry-node 中文文档

规范地址：https://npmcn.com/package/%40elastic/opentelemetry-node/

版本：1\.20\.1
npm 元数据更新时间：2026-11-09T20:45:16.919Z
中文译文更新时间：2026-11-13T10:38:46.317Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40elastic/opentelemetry-node
原文对照：https://npmcn.com/package/%40elastic/opentelemetry-node/?lang=original
项目主页：https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs
源码仓库：https://github.com/elastic/elastic-otel-node

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：169 kB，30 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：^18\.19\.0 \|\| \>=20\.6\.0
- 运行依赖：61 个
- 首次发布：2024-04-30T21:36:52.941Z
- 最新版本发布：2026-11-09T20:45:16.498Z
- 近 30 天下载量：500379（2026-10-14 至 2026-11-12，npm 官方下载统计）
- 已发布版本数：31（近 12 个月 15 个）

## 中文简介

OpenTeleometry 节点js(EDOT节点js)的弹性分布

## 安装

```sh
npm install @elastic/opentelemetry-node
```

也可以使用：`pnpm add @elastic/opentelemetry-node`、`yarn add @elastic/opentelemetry-node`、`bun add @elastic/opentelemetry-node`

## README

# EDOT节点js

OpenTeleometry Node.js(EDOT Node.js)的弹性分布是环绕该设备的轻量级包装器 [节点的 OpenTelemeting SDK](https://opentelemetry.io/docs/languages/js) 这使得在您的节点.js应用程序中开始使用OpenTeleometry变得容易,特别是如果您正在使用 [弹性可观察性](https://www.elastic.co/observability) 作为你的可观察解决方案.

```bash
# Install it
npm install --save @elastic/opentelemetry-node

# Configure it
export OTEL_EXPORTER_OTLP_ENDPOINT="...your-OTLP/collector-endpoint..."
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=..."
export OTEL_SERVICE_NAME="my-app"

# Start it with your application
node --import @elastic/opentelemetry-node my-app.js
```

**见 [eDOT 节点](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs) 详细情况.** 一些直接链接:

-   [开始吧](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs/setup)
-   [配置](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs/configuration)
-   [更改日志/ 发布注释](https://www.elastic.co/docs/release-notes/edot/sdks/node)
-   [弹性讨论论坛](https://discuss.elastic.co/tags/c/observability/apm/58/nodejs) | [GitHub 问题跟踪器](https://github.com/elastic/elastic-otel-node/issues)

## EDOT Node.js与"开放的遥测 JS SDK"有何不同??

EDOT节点js 与 `@opentelemetry/auto-instrumentations-node` 软件包来自OpenTeleometry 在其使用目标:一个单一的依赖性,为Node.js应用程序的零码仪表提供了简单路径. 一般来说,"弹性"的目标是为上游所有SDK改进做出贡献. 尽管如此,有时还是有与"弹性"(Elastic)特有的差异(例如,与一个用于中央配置的"弹性"服务,"弹性"作者附加仪器"). 以下是一份简明的区别清单:

-   EDOT 节点支持动态 [中央配置](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs/configuration#central-configuration) 的设置.
-   EDOT节点Js,作为一个 [分配](https://opentelemetry.io/docs/concepts/distributions/) 总是添加 [`telemetry.distro.*`](https://opentelemetry.io/docs/specs/semconv/attributes-registry/telemetry/) 资源属性来识别自己.
-   EDOT节点js [默认启用一些度量衡](https://github.com/elastic/elastic-otel-node/blob/main/packages/opentelemetry-node/docs/metrics.md) 未包括的 `@opentelemetry/auto-instrumentations-node`: 来自 `@opentelemetry/instrumentation-host-metrics`。 。 。 .
-   EDOT节点js [默认为 `OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=delta`](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs/configuration#otel_exporter_otlp_metrics_temporality_preference-details),这与上游OpenTelemotry JS默认 `cumulative`。 。 。 .
-   EDOT节点js _禁用_ 默认情况下,Node.js日志框架仪器的"log send"特性(对于皮诺, Bunyan和Winston). 重用这个 `ELASTIC_OTEL_NODE_ENABLE_LOG_SENDING=true` 环境变量。 见 [页:1 `ELASTIC_OTEL_NODE_ENABLE_LOG_SENDING` 文档](https://www.elastic.co/docs/reference/opentelemetry/edot-sdks/nodejs/configuration#elastic_otel_node_enable_log_sending-details) 详细情况.
-   EDOT节点js使用最近 [导入中 `createAddHookMessageChannel` 特性](https://github.com/nodejs/import-in-the-middle/blob/main/README.md#only-intercepting-hooked-modules) 改进无害环境管理支持。 我们希望对此提供上游支持.
-   内部 [诊断记录](https://github.com/open-telemetry/opentelemetry-js/blob/main/experimental/packages/opentelemetry-sdk-node/README.md#configure-log-level-from-the-environment) 从 EDOT Node.js 中,使用自定义的JSON-log格式,而不是OpenTeleometry JS. diag Dloging 格式(luggite) JSON格式的只有消息串格式.
-   EDOT 节点设置 `OTEL_LOG_LEVEL` 改为 `info` 默认。 这不同于上游OTel JS(例如,在使用自动仪器-节点软件包时),在那里 `OTEL_LOG_LEVEL` 未设置, 相当于 `OTEL_LOG_LEVEL=none`。 。 。 .

## 常见问题

### @elastic/opentelemetry-node 是什么？

OpenTeleometry 节点js\(EDOT节点js\)的弹性分布

### 如何安装 @elastic/opentelemetry-node？

在项目目录运行 npm install @elastic/opentelemetry-node，或使用 pnpm add / yarn add / bun add。

### @elastic/opentelemetry-node 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @elastic/opentelemetry-node 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @elastic/opentelemetry-node 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^18\.19\.0 \|\| \>=20\.6\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @elastic/opentelemetry-node 可以商用吗？

@elastic/opentelemetry-node 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @elastic/opentelemetry-node 的下载量有多少？

根据 npm 官方下载统计，@elastic/opentelemetry-node 在 2026/10/14 – 2026/11/12 这 30 天内被下载 500,379 次，日均约 16,679 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @elastic/opentelemetry-node 还在维护吗？

最新版本 1\.20\.1 发布于 2026/11/10（3 天前）；至今共发布 31 个版本，其中过去 12 个月发布了 15 个；首次发布于 2024/05/01。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

