Skip to content

Commit

Permalink
http in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Dec 30, 2024
1 parent bb063c9 commit f87410d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
8 changes: 8 additions & 0 deletions mirrord/agent/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ pub(crate) static STEAL_UNFILTERED_CONNECTION_SUBSCRIPTION: LazyLock<IntGauge> =
.expect("Valid at initialization!")
});

pub(crate) static HTTP_REQUEST_IN_PROGRESS_COUNT: LazyLock<IntGauge> = LazyLock::new(|| {
register_int_gauge!(
"mirrord_agent_http_request_in_progress_count",
"amount of in-progress http requests in the mirrord-agent"
)
.expect("Valid at initialization!")
});

pub(crate) static TCP_OUTGOING_CONNECTION: LazyLock<IntGauge> = LazyLock::new(|| {
register_int_gauge!(
"mirrord_agent_tcp_outgoing_connection_count",
Expand Down
25 changes: 19 additions & 6 deletions mirrord/agent/src/steal/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use tracing::{warn, Level};

use crate::{
error::{AgentError, AgentResult},
metrics::HTTP_REQUEST_IN_PROGRESS_COUNT,
steal::{
connections::{
ConnectionMessageIn, ConnectionMessageOut, StolenConnection, StolenConnections,
Expand All @@ -55,6 +56,22 @@ struct MatchedHttpRequest {
}

impl MatchedHttpRequest {
fn new(
connection_id: ConnectionId,
port: Port,
request_id: RequestId,
request: Request<Incoming>,
) -> Self {
HTTP_REQUEST_IN_PROGRESS_COUNT.inc();

Self {
connection_id,
port,
request_id,
request,
}
}

async fn into_serializable(self) -> AgentResult<HttpRequest<InternalHttpBody>, hyper::Error> {
let (
Parts {
Expand Down Expand Up @@ -258,6 +275,7 @@ impl Client {
}
});

HTTP_REQUEST_IN_PROGRESS_COUNT.dec();
true
}
}
Expand Down Expand Up @@ -518,12 +536,7 @@ impl TcpConnectionStealer {
return Ok(());
}

let matched_request = MatchedHttpRequest {
connection_id,
request,
request_id: id,
port,
};
let matched_request = MatchedHttpRequest::new(connection_id, port, id, request);

if !client.send_request_async(matched_request) {
self.connections
Expand Down

0 comments on commit f87410d

Please sign in to comment.