본문으로 건너뛰기
Skillpedia
배포 및 클라우드 (DevOps)107k · #777

observability-and-instrumentation

하는 일

코드가 실행 중에 무엇을 하는지 이해하도록 돕는 스킬입니다. 코드에 '신호'(로그, 측정값 등)를 추가해 문제를 보고 진단할 수 있게 합니다.

사용하는 경우

  • ✓사람들이 사용할 새 기능을 만들 때.
  • ✓운영 환경에서 문제가 생겼는데 이유를 모를 때.
  • ✓무언가 잘못되었을 때 알림을 받도록 설정할 때.

스킬 링크

https://github.com/addyosmani/agent-skills/blob/main/skills/observability-and-instrumentation/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/addyosmani/agent-skills/blob/main/skills/observability-and-instrumentation/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“특정 고객의 결제가 왜 실패했는지 어떻게 알 수 있나요?”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

코드에 실행 중인 일에 대한 정보(로그, 메트릭, 트레이스)를 만드는 지침을 추가합니다. 이 정보는 시스템 동작을 이해하는 데 도움이 되는 단서 역할을 합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Observability and Instrumentation

Overview

Code you can't observe is code you can't operate. Observability is the ability to answer "what is the system doing and why?" from the outside, using the telemetry the code emits. Instrumentation is not a post-launch add-on — it's written alongside the feature, the same way tests are. If a feature ships without telemetry, the first user-reported bug becomes archaeology instead of a query.

When to Use

  • Building any feature that will run in production
  • Adding a new service, endpoint, background job, or external integration
  • A production incident took too long to diagnose ("we couldn't tell what happened")
  • Setting up or reviewing alerting rules
  • Reviewing a PR that adds I/O, retries, queues, or cross-service calls

NOT for:

  • Diagnosing a failure happening right now — use the debugging-and-error-recovery skill (observability is what makes that skill fast next time)
  • Profiling and optimizing measured slowness — use the performance-optimization skill
  • Launch-day monitoring checklists and rollback triggers — see the shipping-and-launch skill; this skill covers the instrumentation that feeds them

Process

1. Define "working" before instrumenting

Telemetry without a question is noise. Before adding any instrumentation, write down 2–4 questions an on-call engineer will ask about this feature:

FEATURE: checkout payment retry
QUESTIONS ON-CALL WILL ASK:
1. What fraction of payments succeed on first attempt vs after retry?
2. When a payment fails permanently, why? (provider error? timeout? validation?)
3. Is the payment provider slower than usual?
→ Every signal below must help answer one of these.

If you can't name the questions, you're not ready to instrument — you'll log everything and learn nothing.

2. Pick the right signal for each question

Signal Answers Cost profile Example
Structured log "What happened in this specific case?" Per-event; grows with traffic payment_failed with provider error code
Metric "How often / how fast, in aggregate?" Fixed per series; cheap to query p99 latency of provider calls
Trace "Where did time go across services?" Per-request; usually sampled One slow checkout, broken down by hop

Rule of thumb: metrics tell you that something is wrong, traces tell you where, logs tell you why.

3. Structured logging

Log events, not prose. Every log line is a JSON object with a stable event name and machine-readable fields:

// BAD: string interpolation — unqueryable, inconsistent
logger.info(`Payment ${id} failed for user ${userId} after ${n} retries`);

// GOOD: stable event name + structured fields
logger.warn({
  event: 'payment_failed',
  paymentId: id,
  provider: 'stripe',
  errorCode: err.code,
  attempt: n,
}, 'payment failed');

Log levels — use them consistently:

Level Meaning On-call action
error Invariant broken; someone may need to act Investigate
warn Degraded but handled (retry succeeded, fallback used) Watch for trends
info Significant business event (order placed, job finished) None
debug Diagnostic detail Off in production by default

Correlation IDs are mandatory. Generate (or accept) a request ID at the system boundary and attach it to every log line, span, and outbound call. Without it, you cannot reconstruct a single request from interleaved logs:

// Express: child logger per request, ID propagated downstream
app.use((req, res, next) => {
  req.id = req.headers['x-request-id'] ?? crypto.randomUUID();
  req.log = logger.child({ requestId: req.id });
  res.setHeader('x-request-id', req.id);
  next();
});

When several entry points write to one log, name the entry point. A correlation ID identifies a run; it does not say which code path started it. The same job reached by a scheduler, by a replay endpoint, and by a manual CLI run produces interchangeable lines in one sink, so attributing a line falls back to elimination — cross-reading the scheduler's history, the process table, a deploy log — and that argument holds only as long as those external records happen to still exist. Stamp the entry point where the run starts, next to the correlation ID, and propagate both the same way:

// One helper for every entry point: the run's own logger carries both fields.

…
자주 묻는 질문

'로그', '메트릭', '트레이스'는 무엇인가요?

로그는 특정 이벤트의 기록입니다. 메트릭은 시간에 따른 데이터 요약입니다(예: 시간당 오류 수). 트레이스는 요청이 여러 서비스를 거치는 경로를 보여 줍니다.

코드가 끝난 뒤에 추가하면 안 되나요?

코드를 작성하는 동안 이 정보를 추가하는 것이 훨씬 쉽고 효과적입니다. 나중에 추가하면 단서 없이 미스터리를 푸는 것과 같습니다.

'correlation IDs'는 무엇인가요?

서로 다른 시점이나 시스템의 다른 부분에서 일어나더라도, 하나의 작업이나 요청과 관련된 모든 정보(로그, 메트릭, 트레이스)를 연결하는 고유 식별자입니다.

상세 정보

작성자의 원본 설명

Instruments code so production behavior is visible and diagnosable. Use when adding logging, metrics, tracing, or alerting. Use when shipping any feature that runs in production and you need evidence it works. Use when production issues are reported but you can't tell what happened from the available data.

repo: addyosmani/agent-skills

인기도

GitHub 스타
107k
순위
#777
라이선스
MIT
업데이트
2026. 10. 13.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬