Skip to content

feat: exclude health endpoints from tracing#46

Open
bramwelt wants to merge 2 commits intomainfrom
tbramwell/LFXV2-1583-exclude-health-endpoints-tracing
Open

feat: exclude health endpoints from tracing#46
bramwelt wants to merge 2 commits intomainfrom
tbramwell/LFXV2-1583-exclude-health-endpoints-tracing

Conversation

@bramwelt
Copy link
Copy Markdown
Contributor

Summary

  • Add otelhttp.WithFilter to otelhttp.NewHandler to skip span creation for /healthz, /livez, and /readyz Kubernetes probe endpoints
  • Reduces high-volume, low-value trace noise from liveness/readiness probes

Test plan

  • go build ./... passes

Issue: LFXV2-1583

🤖 Generated with Claude Code

Add otelhttp.WithFilter to skip span creation for
/healthz, /livez, and /readyz probe requests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1583
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Copilot AI review requested due to automatic review settings April 27, 2026 20:35
@bramwelt bramwelt requested a review from a team as a code owner April 27, 2026 20:35
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7a535bbe-e242-4bec-b673-c1842af9fa0e

📥 Commits

Reviewing files that changed from the base of the PR and between aed8081 and 4e742f4.

📒 Files selected for processing (1)
  • main.go
✅ Files skipped from review due to trivial changes (1)
  • main.go

Walkthrough

OpenTelemetry HTTP instrumentation in main.go is now wrapped around http.DefaultServeMux with a request filter that skips tracing and metrics for /livez and /readyz, while instrumenting all other paths.

Changes

Cohort / File(s) Summary
OpenTelemetry HTTP Handler Filtering
main.go
Wrapped http.DefaultServeMux with otelhttp.NewHandler and added a request filter that excludes /livez and /readyz from tracing/metrics while keeping instrumentation for other routes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: excluding health endpoints from tracing, which aligns with the core objective of reducing trace noise from Kubernetes probe endpoints.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation (reducing trace noise from health checks) and implementation (using otelhttp.WithFilter), though it mentions /healthz which was later removed per the commit feedback.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tbramwell/LFXV2-1583-exclude-health-endpoints-tracing

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces OpenTelemetry trace noise by preventing span creation for Kubernetes probe endpoints on the service’s HTTP listener.

Changes:

  • Wrap http.DefaultServeMux with otelhttp.NewHandler using otelhttp.WithFilter.
  • Skip tracing for /livez and /readyz (and currently also /healthz) requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread main.go Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
main.go (1)

262-267: Nice trace-noise reduction; consider centralizing probe paths.

Line 263–266 hardcodes probe routes in the filter. Consider moving these paths to a shared constant/set (reused by both handler registration and filter logic) to avoid drift in future endpoint changes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@main.go` around lines 262 - 267, The filter passed into otelhttp.NewHandler
currently hardcodes probe paths ("/healthz", "/livez", "/readyz"); extract these
into a shared constant or set (e.g., a slice or map named probePaths or
probePathSet) and use that shared symbol in both the handler registration and
the otelhttp.WithFilter func logic so the probe list is maintained in one place
and cannot drift between registration and filtering; update the
otelhttp.NewHandler call to reference the shared probePaths/probePathSet and
ensure the same symbol is used wherever the probe endpoints are registered or
checked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@main.go`:
- Around line 262-267: The filter passed into otelhttp.NewHandler currently
hardcodes probe paths ("/healthz", "/livez", "/readyz"); extract these into a
shared constant or set (e.g., a slice or map named probePaths or probePathSet)
and use that shared symbol in both the handler registration and the
otelhttp.WithFilter func logic so the probe list is maintained in one place and
cannot drift between registration and filtering; update the otelhttp.NewHandler
call to reference the shared probePaths/probePathSet and ensure the same symbol
is used wherever the probe endpoints are registered or checked.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6792171e-a6f2-48c8-953e-2d7156adb938

📥 Commits

Reviewing files that changed from the base of the PR and between f36ca40 and aed8081.

📒 Files selected for processing (1)
  • main.go

Address review comments from copilot-pull-request-reviewer[bot]:

- main.go: remove /healthz from OTel filter; only /livez and /readyz
  are registered in this service (per copilot-pull-request-reviewer[bot])

Resolves 1 review thread.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1583
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt
Copy link
Copy Markdown
Contributor Author

Review Feedback Addressed

Commit: 4e742f4

Changes Made

  • main.go:265: Removed /healthz from the OTel tracing filter — this service only registers /livez and /readyz via http.HandleFunc. fga-sync uses plain net/http (not Goa), so no generated path helpers are available; the remaining string literals match the registered routes exactly (per copilot-pull-request-reviewer[bot])

Threads Resolved

1 of 1 unresolved threads addressed in this iteration.

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.

2 participants