Skip to content

Conversation

@iamonah
Copy link

@iamonah iamonah commented Nov 11, 2025

Refactor Gorilla Mux middleware for cleaner and more accurate telemetry capture. This replaces the httptest.NewRecorder-based approach with a custom responseRecorder that handles implicit 200 OK responses, optimizes body capture, simplifies request handling, and ensures compatibility with Monoscope and OpenTelemetry.

Closes #

How to test

  1. Set up a local Gorilla Mux server using the updated monoscopegorilla.Middleware.
  2. Test key scenarios:
    • Handler with explicit WriteHeader(201).
    • Handler writing body without WriteHeader (should imply 200 OK).
    • Handler with no body (e.g., HEAD or empty response).
  3. Verify:
    • Telemetry spans are generated correctly.
    • Status codes are accurate (including fallbacks).
    • Bodies are captured based on config flags (CaptureRequestBody, CaptureResponseBody).
    • No issues with duplicate writes or headers.

Checklist

  • Make sure you have described your changes and added all relevant screenshots or data.
  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests).
  • Make sure to add/update documentation regarding your changes (or request one from the team).
  • You are NOT deprecating/removing a feature.

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