원클릭으로
add-telemetry
AI-powered OpenTelemetry instrumentation tool - automatically adds telemetry to uninstrumented code
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
AI-powered OpenTelemetry instrumentation tool - automatically adds telemetry to uninstrumented code
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create documentation-first PRDs that guide development through user-facing content
Complete PRD implementation workflow - create branch, push changes, create PR, merge, and close issue
Analyze existing PRD to identify and recommend the single highest-priority task to work on next
Analyze existing PRD with telemetry data to identify and recommend the single highest-priority task to work on next
Start working on a PRD implementation
Update PRD based on design decisions and strategic changes made during conversations
| name | add-telemetry |
| description | AI-powered OpenTelemetry instrumentation tool - automatically adds telemetry to uninstrumented code |
| category | development |
| disable-model-invocation | true |
Verify the Datadog MCP server is connected before proceeding:
// Test MCP connection
mcp__datadog__search_datadog_services max_tokens:100
If this fails, exit immediately with an error message.
When no target specified, find recently changed code:
# Check recent changes for JS/TS files
git diff --name-only HEAD~5..HEAD | grep -E '\.(js|ts)$'
Identify all uninstrumented functions in the target file(s):
tracer.startActiveSpan() callsChange Detection: Use git diffs to identify which functions have significant changes and may need telemetry enhancements for new logic.
Philosophy: This is experimental telemetry for AI development assistance - identify ALL uninstrumented functions for comprehensive visibility unless they are high-frequency operations that would create excessive spans. Prioritize development insight over production performance.
Detect if any telemetry (OTEL calls, traces, spans, loggers, metrics) was removed in recent commits. If telemetry was removed, show the user what was removed and ask whether it should be restored, providing a recommendation based on the development value of the removed telemetry. If the user says restore, restore the removed telemetry. If the user says the removal was intentional, clean up any now-unused standards/builders from the standards module.
Check which conventions are already available:
Read src/telemetry/standards.js to inventory what exists:
OTEL.attrs?OTEL.span?Compare operations from Step 2 against existing standards:
If all needed conventions exist, skip to Step 5.
For each missing convention identified in Step 3:
Check SEMATTRS imports - Can we import from @opentelemetry/semantic-conventions?
Research OTEL docs - Is this an official convention not in SEMATTRS?
https://opentelemetry.io/docs/specs/semconv/file/ (for file operations)https://opentelemetry.io/docs/specs/semconv/http/ (for network operations)https://opentelemetry.io/docs/specs/semconv/general/ (for general operations)'file.operation')commit_story.* attributeAll conventions (official and custom) must be added as builders to maintain the "no hardcoded strings" principle:
OTEL.attrs following existing patternscommit_story.* namespace only for truly custom attributesGenerate complete instrumentation with correlated spans, metrics, and logs for each uninstrumented function. The correlation is critical: metrics emitted within spans automatically inherit trace context, and logs can reference span IDs, allowing AI assistants to connect performance metrics with specific execution paths and log messages.
Before instrumenting any file, verify:
tracing.js or logging.js. If yes, skip instrumentation and explain why to avoid circular dependencies.tracer.startActiveSpan() calls and nest new spans within them.Add these imports if not present:
trace and SpanStatusCode from @opentelemetry/apiOTEL from the telemetry standards modulecreateNarrativeLogger from the trace logger utilitytrace.getTracer('commit-story', '1.0.0')Note: If you need to set parent spans, also import context as otelContext from @opentelemetry/api.
Transform each function to:
tracer.startActiveSpan() with appropriate OTEL.span builder'code.function' attribute with the function nameIMPORTANT - Parent Span Context: If you need to set a parent span (e.g., when a parentSpan parameter is passed), you MUST use the OpenTelemetry context API:
const ctx = trace.setSpan(otelContext.active(), parentSpan);
return tracer.startActiveSpan(
OTEL.span.operation(),
{ attributes: { 'code.function': 'myFunction' } },
ctx, // Pass context as third parameter
async (span) => { ... }
);
Note: The parent option in the options object is NOT valid and will be silently ignored.
Within each span, emit metrics using the dual emission pattern:
commit_story.* namespace for custom metricsOTEL.metrics.histogram() for durations, gauge() for sizes/counts, counter() for totalsObject.entries(attrs).forEach(...)Within each span, add narrative logging that tells the story of the operation:
createNarrativeLogger('category.operation') using meaningful operation nameslogger.start() at beginning with description of what's startinglogger.progress() for significant milestones, data discoveries, or state changeslogger.decision() when choosing between code paths or making important choiceslogger.complete() on success with summary of what was accomplishedlogger.error() on failure with context about what went wrong and whyThe goal is to create a human-readable narrative that explains the reasoning and flow, not just events. Think "development story" rather than "technical log".
REQUIREMENT: You MUST validate 100% of added telemetry. Every span, metric, and log must be verified in Datadog before completing this command.
Before starting validation, create an inventory of ALL telemetry added in Step 5:
journal.discover_reflections)commit_story.reflection.discovery_duration_ms)journal.reflection_discovery)Run existing validation script to check syntax and imports:
npm run validate:telemetry
If this fails, fix the reported issues and re-run until it passes.
Run the existing test and check console output for span names:
npm run test:trace
Review the trace output to see which of your instrumented functions were triggered. If none appear, you'll need custom tests for all of them.
For any instrumented functions NOT covered by Step 6.3, create and run a test script that imports and calls each uncovered function with realistic parameters. Verify that span traces appear in the console output before proceeding.
Wait 60 seconds for telemetry to reach Datadog:
console.log("⏱️ Waiting 60 seconds for telemetry ingestion...");
console.log(" This ensures if data isn't found, it's an instrumentation or test coverage issue, not timing");
Initial Check: service:commit-story-dev from:now-5m to confirm logs, metrics, and traces are flowing
For EVERY item in your validation inventory from Step 6.1, verify in Datadog:
REQUIREMENT: Every single item must be found. No exceptions.
If any telemetry is missing from Datadog, fix the instrumentation code and repeat the test-wait-verify cycle until 100% of your inventory is found.
CRITICAL: Do not mark this command as complete unless every span, metric, and log is validated in Datadog.
Remove any temporary test files created during validation (e.g., test-otel-*.js scripts).