correlation-tracing by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill correlation-tracing实现关联 ID 和分布式追踪,以跨多个服务跟踪请求并理解系统行为。
最小工作示例:
import express from "express";
import { v4 as uuidv4 } from "uuid";
// 用于上下文的异步本地存储
import { AsyncLocalStorage } from "async_hooks";
const traceContext = new AsyncLocalStorage<Map<string, any>>();
interface TraceContext {
traceId: string;
spanId: string;
parentSpanId?: string;
serviceName: string;
}
function correlationMiddleware(serviceName: string) {
return (
req: express.Request,
res: express.Response,
next: express.NextFunction,
) => {
// 提取或生成追踪 ID
const traceId = (req.headers["x-trace-id"] as string) || uuidv4();
const parentSpanId = req.headers["x-span-id"] as string;
const spanId = uuidv4();
// ... (完整实现请参阅参考指南)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| 关联 ID 中间件 (Express) | 关联 ID 中间件 (Express) |
| OpenTelemetry 集成 | OpenTelemetry 集成 |
| Python 分布式追踪 | Python 分布式追踪 |
| 手动追踪传播 | 手动追踪传播 |
每周安装量
110
代码仓库
GitHub 星标数
121
首次出现
2026年1月21日
安全审计
安装于
opencode93
gemini-cli91
codex87
cursor85
claude-code83
github-copilot75
Implement correlation IDs and distributed tracing to track requests across multiple services and understand system behavior.
Minimal working example:
import express from "express";
import { v4 as uuidv4 } from "uuid";
// Async local storage for context
import { AsyncLocalStorage } from "async_hooks";
const traceContext = new AsyncLocalStorage<Map<string, any>>();
interface TraceContext {
traceId: string;
spanId: string;
parentSpanId?: string;
serviceName: string;
}
function correlationMiddleware(serviceName: string) {
return (
req: express.Request,
res: express.Response,
next: express.NextFunction,
) => {
// Extract or generate trace ID
const traceId = (req.headers["x-trace-id"] as string) || uuidv4();
const parentSpanId = req.headers["x-span-id"] as string;
const spanId = uuidv4();
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Correlation ID Middleware (Express) | Correlation ID Middleware (Express) |
| OpenTelemetry Integration | OpenTelemetry Integration |
| Python Distributed Tracing | Python Distributed Tracing |
| Manual Trace Propagation | Manual Trace Propagation |
Weekly Installs
110
Repository
GitHub Stars
121
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode93
gemini-cli91
codex87
cursor85
claude-code83
github-copilot75
ESLint迁移到Oxlint完整指南:JavaScript/TypeScript项目性能优化工具
1,700 周安装
zeroize-audit 安全审计工具:检测敏感数据归零漏洞与编译器优化风险
914 周安装
App Store Connect CLI 崩溃排查工具:快速分析 TestFlight 崩溃报告与性能诊断
940 周安装
Uniwind:将Tailwind CSS v4引入React Native的样式解决方案
958 周安装
Autoresearch:自主实验循环工具,自动化代码优化与性能改进
1,000 周安装
Sentry问题修复技能:利用AI自动调试与修复生产环境错误
996 周安装
Obsidian CLI 命令行工具:自动化知识库管理与笔记搜索,提升 Obsidian 生产力
1,000 周安装