sourcegraph/internal/requestclient
Robert Lin 38d4e83e59
feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113)
Propagates a for-reference-only record of the first `User-Agent` seen
when a request gets into Sourcegraph across services and contexts. This
allows telemetry to try and indicate where a request originates from
(https://github.com/sourcegraph/sourcegraph/pull/64112), rather than
only having the most recent user-agent.

A new header and `requestclient.Client` property
`X-Forwarded-For-User-Agent` and `ForwardedForUserAgent` is used to
explicitly forward this. Strictly speaking I think we're supposed to
just forward `User-Agent` but it looks like in multiple places we
add/clobber the `User-Agent` ourselves.

The gRPC propagator currently sets user-agent on outgoing requests, this
change also makes that consistent with the HTTP transport, such that
both only explicitly propagate `X-Forwarded-For-User-Agent`

## Test plan

Unit tests
2024-07-29 14:17:25 -07:00
..
geolocation Replace all traditional for-loops (#60988) 2024-03-11 16:05:47 +02:00
BUILD.bazel feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00
client_test.go requestclient: add country-level geolocation data (#58386) 2023-11-22 14:51:48 -08:00
client.go feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00
grpc_test.go feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00
grpc.go feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00
http_test.go feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00
http.go feat/requestclient: propagate original User-Agent as X-Forwarded-For-User-Agent (#64113) 2024-07-29 14:17:25 -07:00