Skip to content

edge: add ProxyRoute.Service to retire host-substring service detection #47

@Viridian-Inc

Description

@Viridian-Inc

Problem

In `pkg/edge/proxy.go::logProxyRequest` (after #46) the service-name attribution for proxied requests still relies on a string-match cascade against the Host header:

```go
if strings.Contains(host, "bff") {
service = "bff"
} else if strings.Contains(host, "graphql") {
...
```

Two places to keep in sync — add `cargo.` to the route table and the request flows correctly but logs as `"proxy"` instead of the real service. This is the wart I flagged at the start of the original split conversation.

Fix

Add `Service string` to `ProxyRoute`. Set it in `BuildRoutesWithPorts` for every route that should attribute (skip the cloudmock-internal routes since they're already filtered out as internal traffic). `logProxyRequest` reads `route.Service` first; the host-substring cascade is preserved as a fallback for hand-rolled route tables that don't set it (backwards compat).

New test `TestBuildRoutes_ServiceLabels` pins the mapping for both `.localhost` rows and primary-domain rows, plus asserts that the internal `cloudmock.localhost` / `admin.*` rows leave `Service` blank.

PR follows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions