chore: extract observability data types into pkg/observability (Phase 2 prep)#44
Merged
Merged
Conversation
… 2 prep) Carve the cross-cutting request-log, stats, and tracing primitives out of pkg/gateway/ into a new pkg/observability package. Leave Go type aliases in pkg/gateway so the 77 external importers — including ~50 service tests asserting on gateway.RequestEntry field shapes — keep compiling unchanged. Moved: - pkg/observability/request_log.go: RequestEntry, RequestLog, RequestFilter, RequestStats, RequestBroadcaster, plus a new NextRequestID() helper that replaces the package-level requestIDCounter the middleware was incrementing inline. - pkg/observability/trace.go: TraceContext, TraceSummary, TimelineSpan, TraceStore + helpers, GenerateTraceID/GenerateSpanID. Verbatim from pkg/gateway/tracing.go. - pkg/observability/traceid/: moved from pkg/gateway/traceid/ (sole importer was the trace file above; no external users). Stays in pkg/gateway: - LoggingMiddleware + LoggingMiddlewareWithOpts and the request parsers (detectServiceFromRequest, extractCallerID, serviceFromAuth, etc.). - responseRecorder, body-capture const, mem/goroutine sampling. - SetServicePrefixes from PR #36. pkg/gateway/tracing.go becomes ~25 lines of aliases. pkg/gateway/logging.go loses ~200 lines of moved data-type definitions but keeps all middleware. Zero behavior change — aliases preserve type identity, JSON tags, and method sets. Verified all packages green except the same pre-existing pkg/platform/store testcontainers/Docker failure that's been failing on every PR in this branch. Unblocks Phase 2 (extract reverse proxy from pkg/gateway/ into pkg/edge): the proxy can now import pkg/observability directly without depending on pkg/gateway. Closes #43 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 2, 2026
Viridian-Inc
added a commit
that referenced
this pull request
May 2, 2026
…#46) Closes the original Phase 2 from #37. With observability primitives now in pkg/observability (#44), the L7 reverse proxy and its TLS-cert helper can finally leave pkg/gateway without circular imports. Moved verbatim into pkg/edge: - proxy.go: ProxyRoute, ProxyServer, ServicePorts, BuildRoutes, BuildRoutesWithPorts, NewProxyServer{,WithOpts}, StartProxy{,WithOpts}, ProxyOpts, plus all internal handlers (logProxyRequest, proxyToWithOpts, addCORSHeaders, rewriteResponseBody, isWebSocketUpgrade, proxyWebSocket, statusRecorder). - certs.go: CertPair, EnsureCerts, all OS trust helpers, file/PEM I/O. - proxy_test.go and certs_test.go. Internal references to RequestLog / RequestStats / RequestBroadcaster / RequestEntry / GenerateTraceID updated to import from pkg/observability directly (no longer go through gateway aliases). pkg/gateway/proxy.go and pkg/gateway/certs.go shrink to type aliases + forwarder functions so external callers (cmd/gateway/main.go and any historical importers) continue to compile. cmd/gateway/main.go migrated to import pkg/edge directly — edge is the canonical home now. The gateway aliases stay in place for safety. Test sweep green except the same pre-existing pkg/platform/store testcontainers/Docker failure that's been failing on every PR in this branch (Docker not running on this machine; reproduces on origin/main). Closes #45 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Phase 2 of the package split (#37) needs a home for the cross-cutting observability primitives shared between the AWS gateway, the reverse proxy, the admin API, and the dataplane: `RequestEntry`, `RequestLog`, `RequestStats`, `RequestBroadcaster`, `TraceContext`, `TraceStore`, `GenerateTraceID`/`GenerateSpanID`. This PR carves them into `pkg/observability/` and leaves Go type aliases in `pkg/gateway/`, so the 77 external importers — including ~50 service tests asserting on `gateway.RequestEntry` field shapes — keep compiling unchanged.
Moved:
Stays in `pkg/gateway/`:
`pkg/gateway/tracing.go` becomes ~25 lines of aliases. `pkg/gateway/logging.go` loses ~200 lines of moved data-type definitions but keeps every middleware.
Closes #43.
Behavior change
None. Aliases preserve type identity, JSON tags, method sets, and interface satisfaction. The wire format on `/api/requests/` and `/api/traces/` is byte-identical.
Test plan
What this unblocks
Phase 2 of the package split: extracting `pkg/gateway/proxy.go` + `pkg/gateway/certs.go` into `pkg/edge` (or `pkg/revproxy`). With this PR landed, the proxy can import `pkg/observability` directly without depending on `pkg/gateway` — the precondition that was blocking the split.
🤖 Generated with Claude Code