querylog: the writer queue defaults to 1024 entries, and a live stream allocates its ring on subscribe instead of at boot
This commit is contained in:
@@ -189,6 +189,9 @@ pub const Sample = struct {
|
||||
/// Exchanges the pool ended on this process's own resources. Pool-wide for
|
||||
/// the same reason as `upstream_budget_exhausted_total`.
|
||||
upstream_local_resource_total: ?u64 = null,
|
||||
/// Live streams refused because their ring could not be allocated. Absent
|
||||
/// while no hub is wired.
|
||||
live_stream_allocation_failures_total: ?u64 = null,
|
||||
peaks: PeakSample = .{},
|
||||
};
|
||||
|
||||
@@ -307,6 +310,8 @@ pub fn collect(state: *server.WebState, io: std.Io, arena: Allocator) Allocator.
|
||||
}
|
||||
}
|
||||
|
||||
if (state.hub) |hub| sample.live_stream_allocation_failures_total = hub.ringAllocationFailures(io);
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
@@ -525,6 +530,14 @@ pub fn render(w: *std.Io.Writer, sample: Sample) std.Io.Writer.Error!void {
|
||||
);
|
||||
try w.print("nxdns_upstream_local_resource_total {d}\n", .{total});
|
||||
}
|
||||
if (sample.live_stream_allocation_failures_total) |total| {
|
||||
try counter(
|
||||
w,
|
||||
"nxdns_live_stream_allocation_failures_total",
|
||||
"Live query streams refused because their buffer could not be allocated.",
|
||||
total,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn renderPeaks(w: *std.Io.Writer, peaks: PeakSample) std.Io.Writer.Error!void {
|
||||
@@ -1818,3 +1831,14 @@ test "the local-resource counter renders pool-wide, without a url label" {
|
||||
defer testing.allocator.free(absent);
|
||||
try testing.expect(!std.mem.containsAtLeast(u8, absent, 1, "nxdns_upstream_local_resource_total"));
|
||||
}
|
||||
|
||||
test "live stream allocation failures render as a counter, absent without a hub" {
|
||||
const text = try renderToString(testing.allocator, .{ .live_stream_allocation_failures_total = 2 });
|
||||
defer testing.allocator.free(text);
|
||||
try testing.expect(std.mem.containsAtLeast(u8, text, 1, "# TYPE nxdns_live_stream_allocation_failures_total counter\n"));
|
||||
try testing.expect(std.mem.containsAtLeast(u8, text, 1, "nxdns_live_stream_allocation_failures_total 2\n"));
|
||||
|
||||
const absent = try renderToString(testing.allocator, .{});
|
||||
defer testing.allocator.free(absent);
|
||||
try testing.expect(!std.mem.containsAtLeast(u8, absent, 1, "nxdns_live_stream_allocation_failures"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user