Skip to content

feat: add metrics-coverage analyzer#63

Open
marcus wants to merge 1 commit intomainfrom
feat/metrics-coverage
Open

feat: add metrics-coverage analyzer#63
marcus wants to merge 1 commit intomainfrom
feat/metrics-coverage

Conversation

@marcus
Copy link
Owner

@marcus marcus commented Mar 20, 2026

Summary

  • Adds nightshift metrics-coverage [path] command that scans Go source files using go/ast to detect metrics instrumentation patterns (Prometheus, OpenTelemetry, StatsD, expvar, custom counters/gauges)
  • Computes per-package coverage (ratio of instrumented exported functions to total), identifies gaps (uninstrumented HTTP handlers, error paths, public API functions), and assigns risk levels (critical/high/medium/low)
  • Results render as markdown or JSON (--json), with optional SQLite persistence (--save) via new migration v6 (metrics_coverage_results table)

Test plan

  • Unit tests for scanner with various Go source strings (no files, no exports, uninstrumented, Prometheus, expvar, HTTP handlers, error returns, custom keywords, multiple packages)
  • Unit tests for coverage summary computation and risk assessment
  • Unit tests for report generation and markdown rendering (sections, gaps, no-gaps case, recommendations)
  • All existing tests continue to pass (migration v6 applies cleanly)
  • gofmt, go vet, go build pass cleanly

🤖 Generated with Claude Code

Adds a `nightshift metrics-coverage` command that scans Go source files
using go/ast to detect metrics instrumentation patterns (Prometheus,
OpenTelemetry, StatsD, expvar, custom counters). Computes per-package
coverage ratios, identifies uninstrumented HTTP handlers and error paths,
and assigns risk levels. Results render as markdown or JSON, with optional
SQLite persistence via migration v6.

Nightshift-Task: metrics-coverage
Nightshift-Ref: https://github.com/marcus/nightshift

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant