Package burp.mcp.util

Class MetricsCollector

java.lang.Object
burp.mcp.util.MetricsCollector

public class MetricsCollector extends Object
Thread-safe metrics collector for the MCP server. Tracks request counts, latencies (ring buffer), tool call counts, error counts, and uptime. Supports a Prometheus-style export.
  • Constructor Details

    • MetricsCollector

      public MetricsCollector()
  • Method Details

    • setEnabled

      public void setEnabled(boolean enabled)
    • isEnabled

      public boolean isEnabled()
    • recordRequest

      public void recordRequest()
    • recordError

      public void recordError()
    • recordRateLimited

      public void recordRateLimited()
    • recordServerBusy

      public void recordServerBusy()
    • recordLatencyMs

      public void recordLatencyMs(long ms)
    • recordToolCall

      public void recordToolCall(String toolName)
    • setCacheStats

      public void setCacheStats(long hits, long misses)
    • setActiveConnections

      public void setActiveConnections(int n)
    • getUptimeSeconds

      public long getUptimeSeconds()
    • resetUptime

      public void resetUptime()
      Restart the uptime clock (listener restarted from the UI).
    • getTotalRequests

      public long getTotalRequests()
    • getErrorCount

      public long getErrorCount()
    • getRateLimitedCount

      public long getRateLimitedCount()
    • getServerBusyCount

      public long getServerBusyCount()
    • getRequestsPerMinute

      public long getRequestsPerMinute()
    • getAvgLatencyMs

      public double getAvgLatencyMs()
    • getPercentileMs

      public long getPercentileMs(double pct)
    • getToolCounts

      public Map<String,Long> getToolCounts()
    • getCacheHitRate

      public double getCacheHitRate()
    • getActiveConnections

      public int getActiveConnections()
    • toMetricsMap

      public Map<String,Object> toMetricsMap()
      Produces a JSON-compatible map of all metrics.
    • toPrometheusFormat

      public String toPrometheusFormat()
      Produces Prometheus text format.