Skip to content

feat: add route exclusion for health check endpoints#27

Merged
karthikeyangs9 merged 8 commits intomainfrom
feat/route-exclusion-rebased
Mar 30, 2026
Merged

feat: add route exclusion for health check endpoints#27
karthikeyangs9 merged 8 commits intomainfrom
feat/route-exclusion-rebased

Conversation

@prathamesh-sonpatki
Copy link
Copy Markdown
Member

Rebased from #10 onto current main (cherry-picked 3 commits cleanly after #11, #13, #14, #21, #25 merged).

Summary

  • Adds configurable path exclusion so health check endpoints (/health, /metrics, /ready, etc.) don't generate trace spans
  • Three-layer matcher (exact, prefix, glob) via LAST9_EXCLUDED_PATHS, LAST9_EXCLUDED_PATH_PREFIXES, LAST9_EXCLUDED_PATH_PATTERNS env vars with sensible defaults
  • Wires into each OTel middleware's native filter (WithFilter/WithSkipper) — excluded paths never create spans
  • GetRouteMatcher() public API for middleware authors

Default excluded paths

Mechanism Defaults
Exact (LAST9_EXCLUDED_PATHS) /health, /healthz, /metrics, /ready, /live, /ping
Prefix (LAST9_EXCLUDED_PATH_PREFIXES) none
Glob (LAST9_EXCLUDED_PATH_PATTERNS) /*/health, /*/healthz, /*/metrics, /*/ready, /*/live, /*/ping

Set any env var to "" to opt out of its defaults.

Test plan

  • internal/routematcher — 22 table-driven tests (exact, prefix, glob, nil receiver, empty, combined, no false positives)
  • config/config_test.go — env var parsing, defaults, opt-out, custom values
  • agent_test.goTestGetRouteMatcher verifies matcher is built from config after Start()
  • All unit tests pass on Go 1.22, 1.23, 1.24
  • go build ./... and go vet ./... clean
  • Conflicts resolved: agent.go (functional options + atomic pointer), config/config.go (SamplerRatio fields), agent_test.go/config/config_test.go (both test suites kept)

🤖 Generated with Claude Code

prathamesh-sonpatki and others added 3 commits March 29, 2026 18:54
Health check endpoints (/health, /metrics, /ready, etc.) generate noise
and inflate trace volume. This adds configurable path exclusion that
leverages each OTel middleware's native filter mechanism (WithFilter/
WithSkipper), so excluded paths never create spans.

Three-layer matcher (exact, prefix, glob) configured via env vars:
- LAST9_EXCLUDED_PATHS (default: /health,/healthz,/metrics,/ready,/live,/ping)
- LAST9_EXCLUDED_PATH_PREFIXES (default: none)
- LAST9_EXCLUDED_PATH_PATTERNS (default: /*/health,/*/healthz,/*/metrics,/*/ready,/*/live,/*/ping)

Set any env var to "" to opt out of its defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix fieldalignment (govet) and gofmt issues:
- Reorder struct fields for optimal GC pointer scanning
- Use named fields in TestIsEmpty struct literals
- Run gofmt for consistent formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document the route exclusion feature including default excluded paths,
configuration env vars, usage examples, and matching behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
karthikeyangs9
karthikeyangs9 previously approved these changes Mar 29, 2026
Move SampleRate and SamplerRatio (float64, non-pointer) after all slice
fields so the GC scan range shrinks from 184 to 168 bytes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
karthikeyangs9 and others added 3 commits March 29, 2026 19:07
…teral

Replace `opts := []T{}` with `var opts []T` in echo, gin, and gorilla
middleware — idiomatic Go for nil-initialized slices that may stay empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@muktaa muktaa self-requested a review March 30, 2026 00:32
@karthikeyangs9 karthikeyangs9 merged commit 6bf5507 into main Mar 30, 2026
10 checks passed
@prathamesh-sonpatki prathamesh-sonpatki deleted the feat/route-exclusion-rebased branch April 7, 2026 10:04
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.

3 participants