feat: add route exclusion for health check endpoints#27
Merged
karthikeyangs9 merged 8 commits intomainfrom Mar 30, 2026
Merged
Conversation
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>
4 tasks
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>
…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>
…ent into feat/route-exclusion-rebased
muktaa
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased from #10 onto current main (cherry-picked 3 commits cleanly after #11, #13, #14, #21, #25 merged).
Summary
/health,/metrics,/ready, etc.) don't generate trace spansLAST9_EXCLUDED_PATHS,LAST9_EXCLUDED_PATH_PREFIXES,LAST9_EXCLUDED_PATH_PATTERNSenv vars with sensible defaultsWithFilter/WithSkipper) — excluded paths never create spansGetRouteMatcher()public API for middleware authorsDefault excluded paths
LAST9_EXCLUDED_PATHS)/health,/healthz,/metrics,/ready,/live,/pingLAST9_EXCLUDED_PATH_PREFIXES)LAST9_EXCLUDED_PATH_PATTERNS)/*/health,/*/healthz,/*/metrics,/*/ready,/*/live,/*/pingSet 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 valuesagent_test.go—TestGetRouteMatcherverifies matcher is built from config afterStart()go build ./...andgo vet ./...cleanagent.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