Skip to content

Lightpanda: the headless browser designed for AI and automation

add robots evicted metric

Muki Kiboigo5f04c699d57d
diff --git a/src/Metrics.zig b/src/Metrics.zig
index 38f77323f..c7dabee96 100644
--- a/src/Metrics.zig
+++ b/src/Metrics.zig
@@ -92,6 +92,7 @@ http_navigation_delay_ms: Histogram(&.{
}) = .{},
robots_status: CounterEnum("category", @import("network/http.zig").StatusCategory) = .{},
robots_access: CounterEnum("result", enum { allow, deny }) = .{},
+robots_evictions: Counter = .{},
cors_check: CounterEnum("result", enum { same_origin, no_cors, simple, preflight }) = .{},
cors_preflight: CounterEnum("result", enum { allowed, blocked }) = .{},
cors_response: CounterEnum("result", enum { allowed, blocked }) = .{},
@@ -130,6 +131,7 @@ const help = .{
.http_navigation_delay_ms = "Time in milliseconds a throttled top-level navigation waited",
.robots_status = "robots.txt response status",
.robots_access = "robots.txt result",
+ .robots_evictions = "robots.txt cache entries evicted to stay within limit",
.cors_check = "CORS initial classification: same_origin/no_cors need no CORS handling, simple needs response validation only, preflight needs an OPTIONS round-trip first",
.cors_preflight = "CORS preflight (OPTIONS) results, one per request that required one",
.cors_response = "CORS actual-response validation results",
diff --git a/src/network/Robots.zig b/src/network/Robots.zig
index 38122c421..b1fe63b40 100644
--- a/src/network/Robots.zig
+++ b/src/network/Robots.zig
@@ -233,6 +233,7 @@ pub const RobotStore = struct {
if (try self.evictions.insert(gop.key_ptr.*)) |evict_key| {
if (self.map.fetchRemove(evict_key)) |kv| {
+ lp.metrics.robots_evictions.incr();
self.allocator.free(kv.key);
var entry = kv.value;
self.freeEntry(&entry);