mirror of
https://github.com/block/buzz.git
synced 2026-11-25 18:52:52 +00:00
test(relay): capture access logs with the production JSON formatter
The capture helpers built a generic flattened JSON layer, which could drift from the TraceContextJson formatter main.rs installs. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This commit is contained in:
@@ -1331,7 +1331,7 @@ pub(crate) mod tests {
|
||||
tracing_subscriber::registry().with(
|
||||
tracing_subscriber::fmt::layer()
|
||||
.json()
|
||||
.flatten_event(true)
|
||||
.event_format(crate::telemetry::TraceContextLookup::default().json_formatter(false))
|
||||
.with_writer(move || writer.clone()),
|
||||
)
|
||||
}
|
||||
@@ -1346,7 +1346,7 @@ pub(crate) mod tests {
|
||||
(r, out)
|
||||
}
|
||||
|
||||
/// Run `f` with JSON logs (flattened, as in production) captured.
|
||||
/// Run `f` with JSON logs captured, using production's JSON formatter.
|
||||
pub(crate) fn capture<R>(f: impl FnOnce() -> R) -> (R, Captured) {
|
||||
let _lock = crate::test_support::tracing_dispatch_lock();
|
||||
let out = Captured::default();
|
||||
|
||||
@@ -2697,7 +2697,7 @@ pub(crate) mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Each parsed REQ and COUNT frame advances its read counter by exactly
|
||||
/// Each parsed REQ, sync and COUNT frame advances its read counter by exactly
|
||||
/// one, even when refused; other frames count nothing.
|
||||
#[tokio::test(flavor = "current_thread")]
|
||||
async fn dispatcher_counts_each_req_and_count_frame_once() {
|
||||
@@ -2714,13 +2714,14 @@ pub(crate) mod tests {
|
||||
for raw in [
|
||||
serde_json::json!(["REQ", "r", {"kinds": [1]}]),
|
||||
serde_json::json!(["COUNT", "c", {"kinds": [1]}]),
|
||||
serde_json::json!(["REQ", "y", {"artifact": "current", "#h": [uuid::Uuid::new_v4().to_string()]}]),
|
||||
serde_json::json!(["CLOSE", "r"]),
|
||||
] {
|
||||
handle_text_message(raw.to_string(), Arc::clone(&conn), Arc::clone(&state)).await;
|
||||
}
|
||||
|
||||
let scrape = handle.render();
|
||||
for kind in ["req", "count"] {
|
||||
for kind in ["req", "count", "sync"] {
|
||||
assert!(
|
||||
scrape.contains(&format!("buzz_ws_reads_total{{type=\"{kind}\"}} 1\n")),
|
||||
"{scrape}"
|
||||
|
||||
Reference in New Issue
Block a user