# @amplication/opentelemetry-nestjs 中文文档

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

版本：7\.0\.0
npm 元数据更新时间：2026-10-03T14:44:09.640Z
中文译文更新时间：2026-11-06T01:17:10.279Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40amplication/opentelemetry-nestjs
原文对照：https://npmcn.com/package/%40amplication/opentelemetry-nestjs/?lang=original
项目主页：https://github.com/amplication/opentelemetry-nestjs#readme
源码仓库：https://github.com/amplication/opentelemetry-nestjs

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

- 包体积（解压后）：620 kB，117 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=20\.19\.0
- 运行依赖：0 个
- peer 依赖：@nestjs/core ^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0，@nestjs/common ^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0，@nestjs/graphql ^12\.0\.0 \|\| ^13\.0\.0 \|\| ^14\.0\.0，@nestjs/schedule ^3\.0\.0 \|\| ^4\.0\.0 \|\| ^5\.0\.0 \|\| ^6\.0\.0 \|\| ^12\.0\.0，@nestjs/event-emitter ^2\.0\.0 \|\| ^3\.0\.0 \|\| ^12\.0\.0，@nestjs/microservices ^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0，@opentelemetry/sdk-node \>=0\.203\.0 \<1\.0\.0，@nestjs/platform-express ^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0，@opentelemetry/propagator-b3 ^2\.0\.0，@opentelemetry/sdk-trace-base ^2\.0\.0，@opentelemetry/propagator-jaeger ^2\.0\.0，@opentelemetry/context-async-hooks ^2\.0\.0，@opentelemetry/exporter-trace-otlp-grpc \>=0\.203\.0 \<1\.0\.0，@opentelemetry/exporter-trace-otlp-http \>=0\.203\.0 \<1\.0\.0，@opentelemetry/exporter-trace-otlp-proto \>=0\.203\.0 \<1\.0\.0，@opentelemetry/auto-instrumentations-node \>=0\.62\.1 \<1\.0\.0，@opentelemetry/exporter-metrics-otlp-grpc \>=0\.203\.0 \<1\.0\.0，@opentelemetry/exporter-metrics-otlp-proto \>=0\.203\.0 \<1\.0\.0，@opentelemetry/resource-detector-container \>=0\.7\.0 \<1\.0\.0
- 首次发布：2023-06-28T08:49:02.345Z
- 最新版本发布：2026-10-03T14:44:09.471Z
- 近 30 天下载量：14366（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：37（近 12 个月 7 个）

## 中文简介

用于Nestjs的OpenTeleometry模块,具有自动仪表与资源检测功能. 最初从 [https://github.com/overbit/opeteletometry-nestjs.git (中文(简体) )](https://github.com/overbit/opentelemetry-nestjs.git)

## 安装

```sh
npm install @amplication/opentelemetry-nestjs
```

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

## README

# 雀巢JS 开口遥测

 [![](https://img.shields.io/npm/v/@amplication/opentelemetry-nestjs.svg) ![](https://img.shields.io/npm/dt/@amplication/opentelemetry-nestjs.svg)](https://www.npmjs.com/package/@amplication/opentelemetry-nestjs) [![](https://img.shields.io/npm/l/@overbit/opentelemetry-nestjs.svg)](https://github.com/overbit/opentelemetry-nestjs) [![](https://img.shields.io/github/stars/overbit/opentelemetry-nestjs.svg)](https://github.com/overbit/opentelemetry-nestjs)

这个图书馆,原来是叉子的 从 [@ overbit/ opetetometry- nestjs (英语)](https://github.com/overbit/opentelemetry-nestjs.git),提供无缝 雀巢JS应用的OpenTeleometry集成,包括自动追踪和度量衡.

## 说明

为NestJS(协议-不可知框架)所设计,这个库跨越了HTTP,GRPC,RabbitMQ等协议. 它使NestJS特有的地层具有高度的可观察性, 包括 [主计长](https://docs.nestjs.com/controllers), (中文(简体) ), [警卫](https://docs.nestjs.com/guards), (中文(简体) ), [截取器](https://docs.nestjs.com/interceptors), (中文(简体) ), [管道](https://docs.nestjs.com/pipes), (中文(简体) ), 财务报告和审定财务报表 [供应商](https://docs.nestjs.com/providers)。 。 。 .

此外,它还为广泛使用的NestJS图书馆提供自动跟踪和计量仪器,帮助您 以最小配置监视和分析您的应用程序.

## 安装

```bash
npm install @amplication/opentelemetry-nestjs --save
```

支持NestJS 10,11和12上节点.js QQ 20.19. `@nestjs/graphql`, (中文(简体) ), `@nestjs/microservices`, (中文(简体) ), `@nestjs/schedule` 财务报告和审定财务报表 `@nestjs/platform-express` 是可选的对等器 - 只在您的应用程序使用时安装它们 .

## 设置

开始 `@amplication/opentelemetry-nestjs` 很简单。 用于大多数 NestJS 的自动仪器 组件,只需导入 `OpenTelemetryModule` 在您的根模块中 :

```ts
import { OpenTelemetryModule } from '@amplication/opentelemetry-nestjs';

@Module({
  imports: [OpenTelemetryModule.forRoot()],
})
export class AppModule {}
```

这将自动显示仪器控制器、 提供者、 守卫、 截取器和其他核心 NestJS 层 你的观察力出盒.

> \[TIP\] 这个库只有乐器 NestJS 代码. 确保 页:1 [打开遥测节点 SDK](https://opentelemetry.io/docs/languages/js/getting-started/nodejs) 已安装 适当初始化以收集痕迹和度量衡。 此软件包也 提供 [帮助者](https://npmcn.com/package/%40amplication/opentelemetry-nestjs/#readme-starting-the-opentelemetry-sdk) 对于它.

## 使用量

当此库自动显示乐器核心 NestJS 层时, 您可以使用 `@Traceable` 财务报告和审定财务报表 `@Span` 装饰器改为 创建特定方法的自定义跨度,例如提供者函数。 这样你就可以给人有意义的名字了 并且捕捉到重要行动的精细痕迹.

### `@Span`

```ts
import { Injectable } from '@nestjs/common';
import { Span } from '@amplication/opentelemetry-nestjs';

@Injectable()
export class AppService {
  @Span()
  getHello(): string {
    return 'Hello World!';
  }

  @Span('SpecialCase')
  getSpecial(): string {
    return 'Never miss a SpecialCase with its fancy name!';
  }
}
```

### `@Traceable`

`@Traceable` 喜欢 `@Span` 但不同的是,它可以用于一个类级 自动仪器每 类别方法:

```ts
import { Injectable } from '@nestjs/common';
import { Traceable } from '@amplication/opentelemetry-nestjs';

@Traceable()
@Injectable()
export class AppService {
  getHello(): string {
    return 'Hello World!';
  }
}
```

## `Tracer`

在高级使用的情况下, 您需要访问本地的 OpenTelemetry 微量服务商才能从 NestJS 访问它们 应用程序上下文。 这样的话,你可以注射 `Tracer` 提供者 :

```ts
import { Injectable } from '@nestjs/common';
import { Tracer } from '@amplication/opentelemetry-nestjs';

@Injectable()
export class AppService {
  constructor(private readonly tracer: Tracer) {}

  getHello(): string {
    const span = this.tracer.startSpan('important_section_start');
    // do something important
    span.setAttributes({ userId: 1150 });
    span.end();
    return 'Hello World!';
  }
}
```

### `TraceService`

这个 `TraceService` 直接访问当前跨度上下文,并允许您开始自定义跨度:

```ts
import { Injectable } from '@nestjs/common';
import { TraceService } from '@amplication/opentelemetry-nestjs';

@Injectable()
export class AppService {
  constructor(private readonly traceService: TraceService) {}

  getHello(): string {
    const span = this.traceService.startSpan('hello');
    // do something
    span.end();
    return 'Hello World!';
  }
}
```

## 自动跟踪仪器

图书馆配有全面的"巢"JS仪器出库. 一旦您导入模块,控制器, 警卫、供应商、管道和其他核心部件自动追踪.

如果您想要自定义启用的仪器, 您可以使用 `instrumentation` 选项 :

```ts
import { Module } from '@nestjs/common';
import {
  OpenTelemetryModule,
  ControllerInstrumentation,
  EventEmitterInstrumentation,
  GuardInstrumentation,
  LoggerInstrumentation,
  PipeInstrumentation,
  ScheduleInstrumentation,
} from '@amplication/opentelemetry-nestjs';

@Module({
  imports: [
    OpenTelemetryModule.forRoot({
      instrumentation: [
        ControllerInstrumentation,
        GuardInstrumentation,
        EventEmitterInstrumentation,
        ScheduleInstrumentation,
        PipeInstrumentation,
        LoggerInstrumentation,
      ],
    }),
  ],
})
export class AppModule {}
```

### 仪器组件

| 实例 | 说明 |
| --- | --- |
| `ControllerInstrumentation` | 自动跟踪所有模块控制器 |
| `GuardInstrumentation` | 自动追踪包括全球警卫在内的所有模块警卫 |
| `PipeInstrumentation` | 自动跟踪所有模块管,包括全球管 |
| `InterceptorInstrumentation` | 自动追踪所有模块拦截器,包括全球管道 |
| `EventEmitterInstrumentation` | 自动跟踪 [@nestjs/事件内容](https://docs.nestjs.com/techniques/events) 库,支持所有特性 |
| `ScheduleInstrumentation` | 自动跟踪 [@ nestjs/ 时间表](https://docs.nestjs.com/techniques/task-scheduling) 库,支持所有特性 |
| `ConsoleLoggerInstrumentation` | [控制台](https://docs.nestjs.com/techniques/logger#extend-built-in-logger) 财务报告和审定财务报表 [锁定器](https://docs.nestjs.com/techniques/logger#using-the-logger-for-application-logging) 类跟踪器,带有跟踪仪的日志 |

#### 使用 Track ID 登录

通过启用 ConsoleLogger 仪器(或使用默认配置),所有日志将自动包含 当前痕量标识, 从而更容易将日志与痕量联系起来 :

![Example trace output](https://npmcn.com/package/%40amplication/opentelemetry-nestjs/docs/log.png)

### 非注射类的人工追踪

如果您需要追踪未由 NestJS DI 容器管理的类别, 您可以将实例包入 `TraceWrapper.trace()`。这自动为每种方法创建一个新的跨度:

```ts
import { TraceWrapper } from '@amplication/opentelemetry-nestjs';

class MyClass {
  hello() {
    console.log('Hi');
  }

  async bye() {
    await new Promise(() => console.log('bye bye'));
  }
}

// ....

const instance = new MyClass();
const tracedInstance = TraceWrapper.trace(instance);

// ....
```

## 计量

您可以使用 Prometheus 输出器来建立测量收集 。 首先,安装Prometheus出口商包:

```
npm install @opentelemetry/exporter-prometheus
```

然后,在您的 OpenTelemotry 节点 SDK 中配置它 :

```ts
new NodeSDK({
  serviceName: 'nestjs-opentelemetry-example',
  // ...
  metricReader: new PrometheusExporter({
    endpoint: 'metrics',
    port: 9464,
  }),
});
```

您现在可以通过 Prometheus 导出器访问自动收集的度量衡 时间 [http://localhost:9464/meters (英语)](http://localhost:9464/metrics)。 。 。 .

其他出口选择见 页:1 [OpenTeleometry JavaScript 导出文档](https://opentelemetry.io/docs/js/exporters/)。 。 。 .

## 启动 OpenTeleometry SDK

在典型的为节点(Node.js)设置的 OpenTeleometry 中,通常会创建一个 `tracing.ts` (或类似名称)文件 初始化并配置 SDK。 此文件应导入 **在最顶端 `main.ts`**,在任何其他时间之前 输入,以便所有装入后的模块和库都有适当的仪器。 这样做可以确保跨度 为您的应用程序的操作而正确创建,且上下文传播和自动仪器为 从进程开始活动.

此软件包提供了一套辅助功能,用于简化 OpenTelemeting 节点 SDK 的启动和配置 NestJS应用. 它包括上下文管理、宣传器、资源探测、自动仪器和跨度 加工——并可以大大减少痕迹中的噪音.

### `startNestJsOpenTelemetrySDK(configuration)`

以默认的 NestJS 方便助手启动节点 OpenTelemeting SDK, 包括自动仪器, 上下文 管理器、宣传器和资源探测器。 接受任意 `NodeSDKConfiguration` 覆盖 :

**示例**

```ts
import { startNestJsOpenTelemetrySDK } from '@amplication/opentelemetry-nestjs';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';

const sdk = startNestJsOpenTelemetrySDK({
  serviceName: 'nestjs-example',
  metricReader: new PrometheusExporter({ endpoint: 'metrics', port: 9464 }),
});
```

`startNestJsOpenTelemetrySDK` 相当于以下内容:

```ts
import { NodeSDK } from '@opentelemetry/sdk-node';
import {
  nodeAutoInstrumentationReduceNoise,
  nodeAutoInstrumentationHttpReduceIncoming,
  nestjsContextManager,
  nestjsTextMapPropagator,
  nestjsResourceDetectors,
} from '@amplication/opentelemetry-nestjs';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';

const sdk = new NodeSDK({
  instrumentations: getNodeAutoInstrumentations(
    mergeInstrumentationConfigMap(
      nodeAutoInstrumentationReduceNoise(),
      nodeAutoInstrumentationHttpReduceIncoming(),
    ),
  ),
  contextManager: nestjsContextManager(),
  textMapPropagator: nestjsTextMapPropagator(),
  resourceDetectors: nestjsResourceDetectors(),
});

sdk.start();
```

### `nodeAutoInstrumentationReduceNoise()`

返回预配置的一套降噪的节点自动装置:

-   `fs` 仪器忽略文件 `node_modules` 和标签之间有文件路径.
-   `http` 仪器更新收到的请求跨度至 `"HTTP_METHOD PATH"`。 。 。 .
-   `graphql` 为 NestJS 配置了仪器(`mergeItems: true`, (中文(简体) ), `ignoreResolveSpans: true`, (中文(简体) ), `ignoreTrivialResolveSpans: true`) (中文(简体) ).
-   `net`, (中文(简体) ), `dns`, (中文(简体) ), `express`,以及 `nestjs-core` 仪器被禁用以减少噪音.

**示例**

```ts
import { nodeAutoInstrumentationReduceNoise } from '@amplication/opentelemetry-nestjs';
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';

const instrumentations = getNodeAutoInstrumentations(
  nodeAutoInstrumentationReduceNoise(),
);
```

### `nodeAutoInstrumentationHttpReduceIncoming(options?)`

过滤从跟踪中收到的特定HTTP请求,例如健康检查或选择方案请求.

**选项 :**

-   `healthChecks`: 需要忽略的 URL 路径数组(`['/health', '/_health', '/healthz', 'healthcheck']` (默认)
-   `methods`: 忽略的 HTTP 方法的阵列 (`['OPTIONS']` (默认)

**示例**

```ts
import { nodeAutoInstrumentationHttpReduceIncoming } from '@amplication/opentelemetry-nestjs';

const httpInstrumentations = nodeAutoInstrumentationHttpReduceIncoming({
  healthChecks: ['/health', '/status'],
  methods: ['OPTIONS'],
});
```

* * *

### `nestjsContextManager()`

返回 a `AsyncLocalStorageContextManager` 在Async NestJS代码中进行适当的上下文传播.

**示例**

```ts
import { nestjsContextManager } from '@amplication/opentelemetry-nestjs';

const contextManager = nestjsContextManager();
```

* * *

### `nestjsTextMapPropagator()`

返回一个复合传播器,支持:

-   贾格
-   W3C 追踪上下文
-   B3 单头和多头

**示例**

```ts
import { nestjsTextMapPropagator } from '@amplication/opentelemetry-nestjs';

const propagator = nestjsTextMapPropagator();
```

* * *

### `nestjsResourceDetectors()`

返回一系列资源探测器,以丰富环境信息(目前包括 `containerDetector`) (中文(简体) ).

**示例**

```ts
import { nestjsResourceDetectors } from '@amplication/opentelemetry-nestjs';

const detectors = nestjsResourceDetectors();
```

* * *

### `mergeInstrumentationConfigMap(target, source)`

递归地将两个仪器配置对象合并. 用于将自定义自动仪器选项与 默认.

**示例**

```ts
import {
  mergeInstrumentationConfigMap,
  nodeAutoInstrumentationReduceNoise,
} from '@amplication/opentelemetry-nestjs';

const customConfig = {
  '@opentelemetry/instrumentation-http': {
    ignoreIncomingRequestHook: (req) => req.url === '/metrics',
  },
};

const merged = mergeInstrumentationConfigMap(
  nodeAutoInstrumentationReduceNoise(),
  customConfig,
);
```

### 实例

```ts
/* tracing.ts */
import { startNestJsOpenTelemetrySDK } from '@amplication/opentelemetry-nestjs';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
import { CompositePropagator } from '@opentelemetry/core';
import { JaegerPropagator } from '@opentelemetry/propagator-jaeger';
import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';

startNestJsOpenTelemetrySDK({
  serviceName: 'myservice-opentelemetry-example',
  metricReader: new PrometheusExporter({
    endpoint: 'metrics',
    port: 9464,
  }),
  spanProcessors: [
    new BatchSpanProcessor(
      new OTLPTraceExporter({
        url: 'your-jaeger-url',
      }),
    ),
  ],
  textMapPropagator: new CompositePropagator({
    propagators: [
      new JaegerPropagator(),
      new B3Propagator(),
      new B3Propagator({
        injectEncoding: B3InjectEncoding.MULTI_HEADER,
      }),
    ],
  }),
});

import { NestFactory } from '@nestjs/core';
// ....
```

```ts
/* at the very top of main.ts */
import 'tracing.ts';
// ...
```

```ts
/* app.module.ts */
import { Module } from '@nestjs/common';
import { OpenTelemetryModule } from '@amplication/opentelemetry-nestjs';

@Module({
  imports: [OpenTelemetryModule.forRoot()],
})
export class AppModule {}
```

### AWS X-Ray/ 云层监视

关于与AWS X-Ray和Cloud Watch的集成,请遵循 页:1 [官方指示](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-OTLPEndpoint.html)数字 :

```ts
/* tracing.ts */
import {
  startNestJsOpenTelemetrySDK,
  defaultInstrumentation,
} from '@amplication/opentelemetry-nestjs';
import { PrometheusExporter } from '@opentelemetry/exporter-prometheus';
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
import { SimpleSpanProcessor } from '@opentelemetry/sdk-trace-node';
import { CompositePropagator } from '@opentelemetry/core';
import { AWSXRayPropagator } from '@opentelemetry/propagator-aws-xray';
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray';
import { AwsInstrumentation } from '@opentelemetry/instrumentation-aws-sdk';

startNestJsOpenTelemetrySDK({
  serviceName: 'myservice-opentelemetry-example',
  metricReader: new PrometheusExporter({
    endpoint: 'metrics',
    port: 9464,
  }),
  instrumentations: [
    ...defaultInstrumentation,
    new AwsInstrumentation({
      suppressInternalInstrumentation: true,
      sqsExtractContextPropagationFromPayload: true,
    }),
  ],
  idGenerator: new AWSXRayIdGenerator(),
  spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter({}))],
  textMapPropagator: new AWSXRayPropagator(),
});
```

## 从v6.x迁移到v7.x

7.0版本没有API修改. 它减少了对NestJS 8和9的支持,并增加了对NestJS 12和 `@nestjs/graphql` 13.4+ / 14 (中文(简体) )

-   **支持的版本**: NestJS 10、11和12 (中文(简体) )`@nestjs/graphql` 12-14, (中文(简体) ), `@nestjs/event-emitter` 第2、3和12条, `@nestjs/schedule` 页:1 节点.js QQ 20. 19 是需要的, 它允许这个 CommunityJS 包装入 仅限无害环境管理的NestJS 12套软件.
-   **可选同伴**数字 : `@nestjs/graphql`, (中文(简体) ), `@nestjs/microservices`, (中文(简体) ), `@nestjs/schedule` 财务报告和审定财务报表 `@nestjs/platform-express` 不再自动安装。 如果使用的话, 添加到应用程序的依赖性中 .
-   **不再进口**: 包不再深入 `@nestjs/graphql/dist/...` 或者说 `@nestjs/microservices/constants`,与软件包相撞 `exports` 引入的地图 `@nestjs/graphql` 13.4. (中文(简体) ).

## 从v5.x迁移到v6.x

6.0版本引入了重大的突破性修改来提高类型安全性,与OpenTeleometry标准保持一致,并增强代码组织.

**📖 [《移徙指南》全文](https://npmcn.com/package/%40amplication/opentelemetry-nestjs/docs/migration-5-to-6.md)**

### 变化的快速摘要

1.  **SDK 启动**数字 : `Tracing.init()` → `startNestJsOpenTelemetrySDK()`
2.  **模块配置**: 矩阵格式 = 对象格式 `instrumentation` 属性
3.  **命名**页:1 `*Injector` 科目 − `*Instrumentation`
4.  **进口**: 文件路径已更新到 kebab 大小写
5.  **追踪命名**: 已更新以与 OpenTeleometry 语义公约保持一致

**在(v5.x)之前:**

```typescript
Tracing.init({ serviceName: 'my-app' });
OpenTelemetryModule.forRoot([ControllerInjector]);
```

**在(v6.x)之后:**

```typescript
startNestJsOpenTelemetrySDK({ serviceName: 'my-app' });
OpenTelemetryModule.forRoot({ instrumentation: [ControllerInstrumentation] });
```

关于详细的迁移指示、代码示例和完整的核对表,见 [移徙指南](https://npmcn.com/package/%40amplication/opentelemetry-nestjs/docs/migration-5-to-6.md)。 。 。 .

## 常见问题

### @amplication/opentelemetry-nestjs 是什么？

用于Nestjs的OpenTeleometry模块,具有自动仪表与资源检测功能\. 最初从 https://github\.com/overbit/opeteletometry-nestjs\.git \(中文\(简体\) \)

### 如何安装 @amplication/opentelemetry-nestjs？

在项目目录运行 npm install @amplication/opentelemetry-nestjs，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@nestjs/core（^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0）、@nestjs/common（^10\.0\.0 \|\| ^11\.0\.0 \|\| ^12\.0\.0）、@nestjs/event-emitter（^2\.0\.0 \|\| ^3\.0\.0 \|\| ^12\.0\.0）、@opentelemetry/sdk-node（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/propagator-b3（^2\.0\.0）、@opentelemetry/sdk-trace-base（^2\.0\.0）、@opentelemetry/propagator-jaeger（^2\.0\.0）、@opentelemetry/context-async-hooks（^2\.0\.0）、@opentelemetry/exporter-trace-otlp-grpc（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/exporter-trace-otlp-http（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/exporter-trace-otlp-proto（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/auto-instrumentations-node（\>=0\.62\.1 \<1\.0\.0）、@opentelemetry/exporter-metrics-otlp-grpc（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/exporter-metrics-otlp-proto（\>=0\.203\.0 \<1\.0\.0）、@opentelemetry/resource-detector-container（\>=0\.7\.0 \<1\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @amplication/opentelemetry-nestjs 支持 TypeScript 吗？

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

### @amplication/opentelemetry-nestjs 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

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

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

### @amplication/opentelemetry-nestjs 可以商用吗？

@amplication/opentelemetry-nestjs 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @amplication/opentelemetry-nestjs 的下载量有多少？

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

### @amplication/opentelemetry-nestjs 还在维护吗？

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

