Communitygithub.com

Next.js OpenTelemetry 관측 가능성 스킬

Next.js App Router 애플리케이션에서 OpenTelemetry(OTel) 관측 가능성을 구성, 테스트 및 검증합니다. "/nextjs-otel", "setup otel", "configure opentelemetry", "test otel" 또는 "verify opentelemetry"에서 트리거됩니다.

Next.js OpenTelemetry 관측 가능성 스킬란 무엇인가요?

이 스킬은 Next.js App Router 애플리케이션에서 OpenTelemetry 추적을 설정하고 검증하는 완전히 자동화된 모듈식 워크플로우를 제공합니다. 단일 킬 스위치(`OTEL_SDK_DISABLED`)를 표준화하고, `@vercel/otel`의 문자열 truthiness 버그로 인한 추적 무음 비활성화를 방지하며, 모의 OTLP 수집기를 통한 자동 추적 검증을 지원합니다. 이 스킬은 프로젝트 평가, 의존성 설치, `instrumentation.ts` 배포, 환경 변수 구성, 그리고 `OTEL_SDK_DISABLED`가 true일 때와 false일 때 모두에서 추적을 확인하는 검증 단계를 포함한 5단계 실행 런북을 제공합니다. 또한 클라이언트 컴포넌트의 런타임 경계 위반, `OTEL_ENABLED`와 같은 보조 플래그의 잘못된 사용, 그리고 셸 명령 체이닝과 같은 일반적인 AI 함정을 방지하는 방법을 강조합니다. 지원 플랫폼: Claude Code, Cursor, Codex 및 기타 AI 에이전트 개발 환경.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/BIGboss248/nextjs-wordpress/tree/HEAD/.agents/skills/nextjs-otel

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Next.js OpenTelemetry 관측 가능성 스킬 (nextjs-otel)

Next.js App Router 애플리케이션에서 OpenTelemetry 추적을 구성, 테스트 및 검증하기 위한 모듈식 프로덕션 준비 워크플로우입니다. 단일 킬 스위치를 표준화하고, @vercel/otel 초기화 버그로부터 보호하며, 추적 검증을 자동화합니다.


워크플로우 개요

flowchart TD
    A["1. 프로젝트 평가<br/>(App Router 및 package.json)"] --> B["2. 의존성 설치<br/>(@vercel/otel 및 @opentelemetry/api)"]
    B --> C["3. instrumentation.ts 배포<br/>(registerOTel + onRequestError)"]
    C --> D["4. 환경 구성<br/>(.env.example 및 .env.local)"]
    D --> E["5. 검증 및 테스트<br/>(모의 수집기 및 킬 스위치)"]

단계별 실행 런북

OpenTelemetry 관측 가능성을 구성하고 검증하려면 다음 체크리스트를 순서대로 따르세요:

1. 프로젝트 발견 및 의존성 검사

  • 프로젝트 구조 검사: package.json에서 Next.js App Router 버전과 패키지 매니저(pnpm, bun, npm)를 확인합니다.
  • 계측 루트 찾기: 프로젝트가 루트 instrumentation.ts 또는 src/instrumentation.ts를 사용하는지 확인합니다.
  • 아키텍처 표준 검토: 단일 킬 스위치 규율 및 런타임 경계에 대해 architectural-standards.md를 참조합니다.

2. 의존성 설치

  • 핵심 텔레메트리 패키지 설치:
    pnpm add @vercel/otel @opentelemetry/api
    

3. instrumentation.ts 배포

  • 계측 파일 생성: instrumentation.ts.template을 루트 또는 src/에 배포합니다.
  • Truthiness 보호 장치 적용: @vercel/otel의 boolean 평가 버그를 피하기 위해 register()가 OTEL_SDK_DISABLED가 엄격하게 "true"가 아닐 때 process.env.OTEL_SDK_DISABLED를 삭제하는지 확인합니다.
  • 오류 추적 연결: onRequestError()가 활성 스팬에 next.error.digest, 경로, HTTP 메타데이터를 캡처하는지 확인합니다.

4. 환경 변수 구성

  • 환경 템플릿 업데이트: env.otel.template을 사용하여 .env.example 및 .env.local에 OpenTelemetry 구성을 추가합니다.
  • 서비스 이름 및 프로토콜 설정: OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL=http/json을 구성합니다.

5. 검증 및 테스트

  • 모의 OTLP 수집기 시작: verification-and-testing.md에 따라 포트 4318에서 테스트 수집기를 시작합니다:
    node .agents/skills/nextjs-otel/scripts/mock_collector.js
    
  • 활성 추적 확인 (OTEL_SDK_DISABLED=false): 테스트 요청 (curl http://localhost:3000/)을 트리거하고 POST /v1/traces 배치가 HTTP 200 OK를 반환하는지 확인합니다.
  • 킬 스위치 확인 (OTEL_SDK_DISABLED=true): Next.js 서버 로그에 [OTel] Instrumentation hook skipped가 출력되고 0개의 추적이 전송되는지 확인합니다.
  • 검증 보고서 출력: Markdown 요약 보고서를 생성합니다.

엣지 케이스 및 알려진 AI 함정

[!WARNING]

  • @vercel/otel 문자열 Truthiness 버그: @vercel/otel은 !!process.env.OTEL_SDK_DISABLED를 평가합니다. JavaScript에서 Boolean("false")는 true입니다. OTEL_SDK_DISABLED가 'true'가 아닐 때 이를 삭제하지 않으면 OTEL_SDK_DISABLED=false로 설정해도 추적이 자동으로 비활성화되지 않습니다.
  • 보조 사용자 정의 플래그: OTEL_SDK_DISABLED와 함께 OTEL_ENABLED를 절대 도입하지 마십시오. OTEL_SDK_DISABLED를 엄격하게 표준화하십시오.
  • 런타임 경계 위반: instrumentation.ts나 서버 OpenTelemetry SDK를 클라이언트 컴포넌트("use client")로 가져오지 마십시오.
  • 명령 체이닝: 명령을 체이닝(&&, ||, ;)하지 마십시오. 모든 설정 및 테스트 명령은 개별적으로 실행하십시오.

출력 요약 스키마

OpenTelemetry 설정 또는 검증을 완료한 후 구조화된 보고서를 출력합니다:

# OpenTelemetry 검증 보고서

## 상태 요약

- **OTel 상태**: 활성 / 비활성화
- **서비스 이름**: <구성된_서비스_이름>
- **대상 엔드포인트**: <구성된_엔드포인트>
- **내보내기 프로토콜**: http/json | http/protobuf

## 검증 결과

| 검사                        | 예상                        | 실제                | 상태 |
| :-------------------------- | :-------------------------- | :------------------ | :--- |
| 초기화 훅                   | 등록됨                      | 등록됨              | PASS |
| 추적 전송 (활성)            | POST /v1/traces (200 OK)    | X개 배치 수신       | PASS |
| 킬 스위치 (비활성화)        | 건너뜀, 0개 추적            | 건너뜀, 0개 추적    | PASS |
| 유형 검사                   | 0개 오류                    | 0개 오류            | PASS |

참조 가이드 및 템플릿

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

BIGboss248/nextjs-wordpress

Create, configure, manage, and validate Google Antigravity customizations including skills, rules, MCP servers, lifecycle hooks, plugins, and custom JSON configs. Use when adding new capabilities to Antigravity, configuring MCP servers, writing rules, creating skills, setting up hooks, or modernizing legacy workflows.

BIGboss248/nextjs-wordpress

Spawn multiple agents into a shared conversation where they debate, disagree, and converge on a solution via a shared chat.json file. Use for architecture decisions, code review debates, design trade-offs, or any problem that benefits from adversarial reasoning. Triggers on "chatroom", "agent debate", "have agents discuss", "agent chatroom", "debate this", or /agent-chatrooms. Also triggers on phrases like "have 3 agents argue about", "multi-agent discussion", or "let them debate".

BIGboss248/nextjs-wordpress

Always-active code intelligence, search, and navigation skill utilizing the codebase-memory MCP server. Enforces an index-first protocol (verifying and refreshing the knowledge graph via index_repository or index_status before searching, required because background auto_watch is disabled to eliminate editor stutter and system lag), followed by graph-first exploration (search_graph, trace_path, get_code_snippet, query_graph, get_architecture, detect_changes) instead of naive text grep or full-file reads. Always activate before searching the codebase, inspecting unknown architecture, finding symbols, or tracing callers/callees.

BIGboss248/nextjs-wordpress

>- Discover, interview, and craft comprehensive UX/UI design specifications (design-spec.md) and design tokens for web components. Triggers on "/component-design", "design component", "design section", "design UI", "wireframe component", or "create design spec".

BIGboss248/nextjs-wordpress

>- Configure and query WooCommerce APIs including WPGraphQL, WooGraphQL, and JWT auth for headless frontends. Use when connecting Next.js to WooCommerce or fetching store catalog data.

BIGboss248/nextjs-wordpress

Orchestrate parallel browser automation using multiple Chrome DevTools MCP instances. Use when a task requires doing the same browser action across many targets simultaneously (e.g., submitting contact forms, filling applications, scraping pages that need JS rendering). Spin up 1-5 parallel Chrome agents.

BIGboss248/nextjs-wordpress

Workflow for spawning an independent subagent to conduct unbiased code reviews and inject adversarial edge-case tests ([ComponentName].edge.test.tsx).

BIGboss248/nextjs-wordpress

>- Build Next.js App Router React components with Suspense skeletons, semantic OKLCH tokens, Jest + RTL unit tests, Playwright visual/hydration checks, and Tailwind logical styling. Triggers on "/nextjs-component-dev", "create component", "new component", "build component", or "develop component".

BIGboss248/nextjs-wordpress

>- Bootstrap, configure, and verify the complete Next.js App Router development environment, developer tooling, testing suites, MCP servers, Docker containerization, and CI/CD. Triggers on "/nextjs-dev-setup", "setup nextjs dev environment", "start a nextjs project", or "containerize nextjs app".

BIGboss248/nextjs-wordpress

>- Configure production health monitoring endpoints (/api/health), Docker Compose probes, and runtime metrics in Next.js App Router applications. Use when asked to "setup health check", "add health endpoint", "docker compose healthcheck nextjs", "configure health monitor", or "/nextjs-healthcheck".

BIGboss248/nextjs-wordpress

Bootstrap, configure, and verify next-intl App Router internationalization (proxy.ts/middleware.ts, next/root-params, [locale] layout, routing). Triggers on "/nextjs-i18n-setup", "setup i18n", "install next-intl", "configure next-intl", "add internationalization", "setup locale routing", "migrate to [locale]".

BIGboss248/nextjs-wordpress

Read/write translation dictionaries (messages/[locale].json), next-intl hooks (getTranslations/useTranslations), providers (Storybook/tests/subtrees), and BiDi styling. Triggers on "/nextjs-i18n-usage", "i18n dictionary", "use translations", "read dictionary", "i18n provider", "next-intl hooks", "storybook i18n", "test i18n", "add translation keys", "localize component", "create a component", "update a component".

BIGboss248/nextjs-wordpress

Step-by-step workflow for designing and building Next.js App Router pages (RSC page.tsx, loading skeleton, metadata, JSON-LD schema, and dynamic static params). Triggers on "/nextjs-page-dev", "create page", "new page", "develop page", "build route", or "implement page".

BIGboss248/nextjs-wordpress

>- Orchestrate end-to-end planning for Next.js App Router projects, generating canonical specifications, design systems, and a 7-phase modular implementation roadmap in docs/plan/. Triggers on "/nextjs-plan", "plan a nextjs project", "plan nextjs app", "create nextjs project plan", "outline nextjs architecture", or "generate plan".

BIGboss248/nextjs-wordpress

Workflow and engineering standards for crafting co-located Storybook CSF3 stories ([ComponentName].stories.tsx) with interactive controls, action spies, and 4 canonical theme variants.

BIGboss248/nextjs-wordpress

>- Build Next.js e-commerce frontends backed by WooCommerce APIs, handling ISR catalogs, cart sessions, and JWT authentication. Use when building or querying Next.js stores with WooCommerce.

BIGboss248/nextjs-wordpress

Self-correcting rules engine and feedback loop that learns from user corrections, mistakes, and project-specific constraints by maintaining a persistent autofix ruleset. Scans learned rules before starting any task, resolves conflicts, and automatically appends new rules upon corrections. Triggers on user corrections ("no, do it this way", "never do X", "always use Y"), /learn, "self repair", "add rule", "update rules", or when diagnosing assumptions and bugs. CRITICAL ALWAYS-ACTIVE LIFECYCLE SKILL. Must always be kept in context, loaded at session start, and consulted before starting ANY task to read and apply active constraints from autofix.json. MUST ALWAYS be triggered immediately whenever the user provides ANY correction, preference, criticism, rejection of an approach, or adjustment ("no", "don't do X", "use Y", "remember", "prefer"), or when any mistake/bug is identified. Automatically and immediately formulates and appends the new imperative rule to the project's autofix.json ruleset file.

BIGboss248/nextjs-wordpress

Setup, automate, and execute SEO audits, CI/CD pre-push/pre-deploy checks, and ranking optimizations using the seo CLI and MCP server.

BIGboss248/nextjs-wordpress

End-to-end repository onboarding and development environment setup skill. Scans repository structure, configures project metadata (docs/project.json), sets up the codebase-memory-mcp code intelligence knowledge graph server (in workspace mcp.json and globally for AGY only), configures git hooks with Husky and Commitlint, establishes multi-stage production Docker containerization, and automates credit-optimized Release Please CI/CD with multi-arch (AMD64 & ARM64) GHCR package deployment. Triggers on "/setup-repository", "setup repository", "setup repo", "initialize repository", "new repo setup", or when preparing any repository for development and AI agent workflows.

BIGboss248/nextjs-wordpress

AI screen scaffolding, layout generation, and variant exploration workflow powered by Google Stitch (StitchMCP). Consumes a component design specification (docs/design/components/[page name]/[component name]/design-spec.md), verifies and reuses the central Stitch project in docs/project.json (or creates/persists one if absent), seeds the project's design system into Stitch, synthesizes layout prompts to generate a screen and create one variant of the given design spec file, downloads and saves Stitch JPG screenshots and HTML code files directly into docs/design/components/[page name]/[component name]/stitch/ using binary-safe PowerShell Invoke-WebRequest, outputs image prompts to the user if visual assets are needed (without calling generate_image to conserve tokens), updates design-spec.md with Stitch layout benchmarks, and audits asset download integrity with an independent subagent. Triggers on "/stitch-design", "generate stitch screen", "create stitch variant", "scaffold screen with stitch", or "stitch...

관련 스킬