pub struct RequestEvent {
pub request_id: String,
pub ts: i64,
pub proxy: String,
pub session_id: Option<String>,
pub method: String,
pub tool: Option<String>,
pub latency_us: i64,
pub status: RequestStatus,
pub error_code: Option<String>,
pub error_msg: Option<String>,
pub bytes_in: Option<i64>,
pub bytes_out: Option<i64>,
}Expand description
One completed MCP request, ready to be written to the requests table.
Built from the same data the proxy already computes for logging and cloud emission (method, tool name, latency, status, sizes). No extra parsing needed.
Fields§
§request_id: StringUUIDv7 generated by mcpr — time-ordered, globally unique. Used for cloud emitter correlation and as the primary lookup key.
ts: i64Unix milliseconds (UTC) when the request was received. Millisecond resolution is sufficient for latency tracking and avoids i64 overflow concerns that nanosecond timestamps would introduce.
proxy: StringProxy name from config (e.g., “api-server”). Tags every row so a shared database can hold data from multiple proxies.
session_id: Option<String>MCP session ID from the mcp-session-id header.
Nullable: pre-handshake probes or malformed clients may not have one.
Soft foreign key to sessions.session_id (no hard FK constraint —
avoids ordering edge cases in the async writer).
method: StringMCP JSON-RPC method (e.g., “tools/call”, “resources/read”, “initialize”). Stored as-is from the protocol layer — no normalization.
tool: Option<String>Tool name for tools/call requests, None for other methods.
Extracted from the JSON-RPC params by the proxy’s MCP parser.
latency_us: i64Wall-clock time from proxy receiving the request to getting the upstream response. Includes network round-trip to upstream — this is what the AI client experiences. Stored in microseconds for sub-millisecond precision.
status: RequestStatusWhether the request succeeded, failed, or timed out.
error_code: Option<String>MCP error code if status is Error (e.g., “-32600”, “-32601”).
None for successful requests.
error_msg: Option<String>Human-readable error message, truncated to 512 chars at the call site. None for successful requests.
bytes_in: Option<i64>Request payload size in bytes. None if not measured.
bytes_out: Option<i64>Response payload size in bytes. None if not measured.