otel-js
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "otel-js":https://skillpi.com/zh/skills/deepskill-bda37567a30f4ccf75ea1c7288d192b7ebe67475722d4b73380a0a35d90b7602。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
使用 OpenTelemetry 对 Node.js 应用进行插桩,适用于添加分布式追踪、收集指标、对 HTTP 请求和数据库查询进行追踪,以及为微服务设置可观测性。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
Frontmatter
name: otel-js
description: >-
Instrument Node.js apps with OpenTelemetry. Use when a user asks to add
distributed tracing, collect metrics, instrument HTTP requests, trace
database queries, or set up observability for microservices.
license: Apache-2.0
compatibility: 'Node.js 16+, Express, Fastify, NestJS'
metadata:
author: terminal-skills
version: 1.0.0
category: devops
tags:
- opentelemetry
- tracing
- metrics
- nodejs
- observabilityOpenTelemetry for Node.js
Overview
OpenTelemetry (OTel) is the standard for distributed tracing, metrics, and logs. Instrument your Node.js services once, and send telemetry to any backend (Jaeger, Grafana Tempo, Datadog, Honeycomb). Auto-instrumentation captures HTTP, database, and gRPC calls without code changes.
Instructions
Step 1: Auto-Instrumentation
npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-http @opentelemetry/exporter-metrics-otlp-http
// instrumentation.ts — OpenTelemetry setup (import BEFORE app code)
import { NodeSDK } from '@opentelemetry/sdk-node'
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics'
import { Resource } from '@opentelemetry/resources'
import { ATTR_SERVICE_NAME, ATTR_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'
const sdk = new NodeSDK({
resource: new Resource({
[ATTR_SERVICE_NAME]: 'api-service',
[ATTR_SERVICE_VERSION]: process.env.npm_package_version || '1.0.0',
}),
traceExporter: new OTLPTraceExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/traces',
}),
metricReader: new PeriodicExportingMetricReader({
exporter: new OTLPMetricExporter({
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4318/v1/metrics',
}),
exportIntervalMillis: 30000,
}),
instrumentations: [
getNodeAutoInstrumentations({
'@opentelemetry/instrumentation-http': {
ignoreIncomingPaths: ['/health', '/ready'], // don't trace health checks
},
'@opentelemetry/instrumentation-express': { enabled: true },
'@opentelemetry/instrumentation-pg': { enabled: true },
'@opentelemetry/instrumentation-redis': { enabled: true },
}),
],
})
sdk.start()
console.log('OpenTelemetry initialized')
process.on('SIGTERM', () => sdk.shutdown())
Step 2: Custom Spans
// services/orders.ts — Manual instrumentation for business logic
import { trace, SpanStatusCode } from '@opentelemetry/api'
const tracer = trace.getTracer('order-service')
export async function processOrder(orderId: string) {
return tracer.startActiveSpan('processOrder', async (span) => {
span.setAttribute('order.id', orderId)
try {
// Child span for payment
const payment = await tracer.startActiveSpan('chargePayment', async (paymentSpan) => {
paymentSpan.setAttribute('payment.provider', 'stripe')
const result = await stripe.charges.create({ amount: 9999 })
paymentSpan.setAttribute('payment.id', result.id)
paymentSpan.end()
return result
})
span.setAttribute('order.status', 'completed')
span.setAttribute('payment.id', payment.id)
span.setStatus({ code: SpanStatusCode.OK })
} catch (err) {
span.recordException(err)
span.setStatus({ code: SpanStatusCode.ERROR, message: err.message })
throw err
} finally {
span.end()
}
})
}
Step 3: Run
# Start app with instrumentation loaded first
node --import ./instrumentation.ts src/server.ts
# Or in package.json
# "start": "node --import ./instrumentation.ts dist/server.js"
Guidelines
- Import instrumentation BEFORE your app code — auto-instrumentation patches libraries on import.
- Use
--importflag (ESM) or-rflag (CJS) to load instrumentation first. - Auto-instrumentation covers HTTP, Express, Fastify, PostgreSQL, Redis, MongoDB, gRPC.
- Add custom spans for business logic (order processing, payment flows) — auto-instrumentation only covers infrastructure.
- Send telemetry to an OTLP collector (Grafana Alloy, OTel Collector) for routing to multiple backends.
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 OpenTelemetry Node.js 插桩解决方案
- 覆盖分布式追踪、指标收集、HTTP 和数据库插桩等核心可观测性需求
- 适用于广泛的 Node.js 开发者群体
亮点
- 触发词精准完整,明确列出分布式追踪、指标收集、HTTP 插桩、数据库查询追踪、微服务可观测性等具体场景
- 边界清晰,不易与其他 Skill 重叠
亮点
- Phase 划分清晰(Auto-Instrumentation → Custom Spans → Run)
- 包含完整的端到端代码示例和运行命令
- frontmatter 完整,包含兼容性、许可证、元数据等信息
亮点
- 使用官方 OpenTelemetry 包,来源可靠
- 参数配置合理(OTLP endpoint、忽略路径等)
- 包含错误处理机制和优雅关闭逻辑
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 32 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- localhost
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。