collab: Attach User-Agent
to handle connection
span (#35282)
This PR makes it so we attach the value from the `User-Agent` header to the `handle connection` span. We'll start sending this header in https://github.com/zed-industries/zed/pull/35280. Release Notes: - N/A
This commit is contained in:
parent
f9224b1d74
commit
77dc65d826
2 changed files with 10 additions and 0 deletions
|
@ -23,6 +23,7 @@ use anyhow::{Context as _, anyhow, bail};
|
||||||
use async_tungstenite::tungstenite::{
|
use async_tungstenite::tungstenite::{
|
||||||
Message as TungsteniteMessage, protocol::CloseFrame as TungsteniteCloseFrame,
|
Message as TungsteniteMessage, protocol::CloseFrame as TungsteniteCloseFrame,
|
||||||
};
|
};
|
||||||
|
use axum::headers::UserAgent;
|
||||||
use axum::{
|
use axum::{
|
||||||
Extension, Router, TypedHeader,
|
Extension, Router, TypedHeader,
|
||||||
body::Body,
|
body::Body,
|
||||||
|
@ -750,6 +751,7 @@ impl Server {
|
||||||
address: String,
|
address: String,
|
||||||
principal: Principal,
|
principal: Principal,
|
||||||
zed_version: ZedVersion,
|
zed_version: ZedVersion,
|
||||||
|
user_agent: Option<String>,
|
||||||
geoip_country_code: Option<String>,
|
geoip_country_code: Option<String>,
|
||||||
system_id: Option<String>,
|
system_id: Option<String>,
|
||||||
send_connection_id: Option<oneshot::Sender<ConnectionId>>,
|
send_connection_id: Option<oneshot::Sender<ConnectionId>>,
|
||||||
|
@ -762,9 +764,14 @@ impl Server {
|
||||||
user_id=field::Empty,
|
user_id=field::Empty,
|
||||||
login=field::Empty,
|
login=field::Empty,
|
||||||
impersonator=field::Empty,
|
impersonator=field::Empty,
|
||||||
|
user_agent=field::Empty,
|
||||||
geoip_country_code=field::Empty
|
geoip_country_code=field::Empty
|
||||||
);
|
);
|
||||||
principal.update_span(&span);
|
principal.update_span(&span);
|
||||||
|
if let Some(user_agent) = user_agent {
|
||||||
|
span.record("user_agent", user_agent);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(country_code) = geoip_country_code.as_ref() {
|
if let Some(country_code) = geoip_country_code.as_ref() {
|
||||||
span.record("geoip_country_code", country_code);
|
span.record("geoip_country_code", country_code);
|
||||||
}
|
}
|
||||||
|
@ -1172,6 +1179,7 @@ pub async fn handle_websocket_request(
|
||||||
ConnectInfo(socket_address): ConnectInfo<SocketAddr>,
|
ConnectInfo(socket_address): ConnectInfo<SocketAddr>,
|
||||||
Extension(server): Extension<Arc<Server>>,
|
Extension(server): Extension<Arc<Server>>,
|
||||||
Extension(principal): Extension<Principal>,
|
Extension(principal): Extension<Principal>,
|
||||||
|
user_agent: Option<TypedHeader<UserAgent>>,
|
||||||
country_code_header: Option<TypedHeader<CloudflareIpCountryHeader>>,
|
country_code_header: Option<TypedHeader<CloudflareIpCountryHeader>>,
|
||||||
system_id_header: Option<TypedHeader<SystemIdHeader>>,
|
system_id_header: Option<TypedHeader<SystemIdHeader>>,
|
||||||
ws: WebSocketUpgrade,
|
ws: WebSocketUpgrade,
|
||||||
|
@ -1227,6 +1235,7 @@ pub async fn handle_websocket_request(
|
||||||
socket_address,
|
socket_address,
|
||||||
principal,
|
principal,
|
||||||
version,
|
version,
|
||||||
|
user_agent.map(|header| header.to_string()),
|
||||||
country_code_header.map(|header| header.to_string()),
|
country_code_header.map(|header| header.to_string()),
|
||||||
system_id_header.map(|header| header.to_string()),
|
system_id_header.map(|header| header.to_string()),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -256,6 +256,7 @@ impl TestServer {
|
||||||
ZedVersion(SemanticVersion::new(1, 0, 0)),
|
ZedVersion(SemanticVersion::new(1, 0, 0)),
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
Some(connection_id_tx),
|
Some(connection_id_tx),
|
||||||
Executor::Deterministic(cx.background_executor().clone()),
|
Executor::Deterministic(cx.background_executor().clone()),
|
||||||
None,
|
None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue