Class ExportStats

java.lang.Object
ai.attackframework.tools.burp.utils.ExportStats

public final class ExportStats extends Object
Thread-safe per-index export stats for OpenSearch pushes.

Session-scoped: counts and last error/duration are not persisted. Used by StatsPanel and by the tool-index stats snapshot. Index keys align with short names: traffic, tool, settings, sitemap, findings.

  • Method Details

    • getIndexKeys

      public static List<String> getIndexKeys()
      Returns the list of index keys (traffic, tool, settings, sitemap, findings).
    • getTrafficSourceKeys

      public static List<String> getTrafficSourceKeys()
      Returns known traffic source keys used for source-level traffic stats.
    • getTrafficToolTypeKeys

      public static List<String> getTrafficToolTypeKeys()
      Returns known traffic tool type keys shown in Config > Traffic.
    • recordSuccess

      public static void recordSuccess(String indexKey, long count)
      Records successful document push(es) for the given index.
      Parameters:
      indexKey - index key (e.g. "traffic")
      count - number of documents; ignored if <= 0
    • recordFailure

      public static void recordFailure(String indexKey, long count)
      Records failed document push(es) for the given index.
      Parameters:
      indexKey - index key (e.g. "traffic")
      count - number of failures; ignored if <= 0
    • recordTrafficSourceSuccess

      public static void recordTrafficSourceSuccess(String sourceKey, long count)
      Records successful traffic pushes for a specific traffic source.
      Parameters:
      sourceKey - source key (for example "proxy_live_http")
      count - number of successful documents; ignored if <= 0
    • recordTrafficSourceFailure

      public static void recordTrafficSourceFailure(String sourceKey, long count)
      Records failed traffic pushes for a specific traffic source.
      Parameters:
      sourceKey - source key (for example "proxy_live_http")
      count - number of failed documents; ignored if <= 0
    • recordLastPush

      public static void recordLastPush(String indexKey, long durationMs)
      Records the duration in ms of the last push for the given index.
      Parameters:
      indexKey - index key
      durationMs - duration in milliseconds, or -1 if unknown
    • recordLastError

      public static void recordLastError(String indexKey, String message)
      Records the last error for the given index.
      Parameters:
      indexKey - index key
      message - error message; null or empty clears the stored error
    • getSuccessCount

      public static long getSuccessCount(String indexKey)
      Returns the session total of documents successfully pushed for the given index.
    • getFailureCount

      public static long getFailureCount(String indexKey)
      Returns the session total of failed push attempts for the given index.
    • getExportedBytes

      public static long getExportedBytes(String indexKey)
      Returns estimated successful payload bytes pushed for the given index this session.
    • recordExportedBytes

      public static void recordExportedBytes(String indexKey, long bytes)
      Records estimated successful payload bytes for the given index.
      Parameters:
      indexKey - index key (e.g. "traffic")
      bytes - estimated successful payload bytes; ignored if <= 0
    • getTrafficSourceSuccessCount

      public static long getTrafficSourceSuccessCount(String sourceKey)
      Returns successful traffic pushes for a specific traffic source.
    • getTrafficSourceFailureCount

      public static long getTrafficSourceFailureCount(String sourceKey)
      Returns failed traffic pushes for a specific traffic source.
    • recordTrafficToolTypeCaptured

      public static void recordTrafficToolTypeCaptured(String toolTypeKey, long count)
      Records captured traffic events for a specific traffic tool type.

      This tracks accepted events at capture time (before queue drain), useful for visibility into tool-source distribution.

    • getTrafficToolTypeCapturedCount

      public static long getTrafficToolTypeCapturedCount(String toolTypeKey)
      Returns captured traffic event count for a specific tool type.
    • getLastPushDurationMs

      public static long getLastPushDurationMs(String indexKey)
      Returns last push duration in ms, or -1 if not set.
    • getLastError

      public static String getLastError(String indexKey)
      Returns the last recorded error message for the given index, or null if none.
    • getQueueSize

      public static int getQueueSize(String indexKey)
      Returns the number of documents currently queued for retry for the given index (0 when no retry coordinator or queue empty).
    • recordTrafficQueueDrop

      public static void recordTrafficQueueDrop(long count)
      Records that one or more documents were dropped from the traffic queue (queue full, drop oldest).
      Parameters:
      count - number of documents dropped; ignored if <= 0
    • getTrafficQueueDrops

      public static long getTrafficQueueDrops()
      Returns the session total of documents dropped from the traffic queue because it was full.
      Returns:
      total drop count (0 or positive)
    • recordTrafficSpillEnqueued

      public static void recordTrafficSpillEnqueued(long count)
      Records one or more traffic documents persisted to spill storage.
      Parameters:
      count - number of spilled documents; ignored if <= 0
    • getTrafficSpillEnqueued

      public static long getTrafficSpillEnqueued()
      Returns total spilled traffic documents persisted this session.
    • recordTrafficSpillDequeued

      public static void recordTrafficSpillDequeued(long count)
      Records one or more traffic documents drained from spill storage.
      Parameters:
      count - number of drained spilled documents; ignored if <= 0
    • getTrafficSpillDequeued

      public static long getTrafficSpillDequeued()
      Returns total spilled traffic documents drained back into memory this session.
    • recordTrafficSpillDrop

      public static void recordTrafficSpillDrop(long count)
      Records one or more traffic documents dropped because spill storage was unavailable/full.
      Parameters:
      count - number of dropped spill documents; ignored if <= 0
    • getTrafficSpillDrops

      public static long getTrafficSpillDrops()
      Returns total traffic documents dropped due to spill rejection this session.
    • recordTrafficSpillRecovered

      public static void recordTrafficSpillRecovered(long count)
      Records one or more spill documents recovered on startup.
      Parameters:
      count - recovered spill document count; ignored if <= 0
    • getTrafficSpillRecovered

      public static long getTrafficSpillRecovered()
      Returns total spill documents recovered on startup this session.
    • recordTrafficSpillExpiredPruned

      public static void recordTrafficSpillExpiredPruned(long count)
      Records one or more spill files removed by retention cleanup.
      Parameters:
      count - pruned spill file count; ignored if <= 0
    • getTrafficSpillExpiredPruned

      public static long getTrafficSpillExpiredPruned()
      Returns total spill files pruned by retention this session.
    • recordTrafficDropReason

      public static void recordTrafficDropReason(String reason, long count)
      Records a reason-coded traffic drop event.
      Parameters:
      reason - non-blank reason key
      count - number of dropped documents for that reason
    • getTrafficDropReasonCount

      public static long getTrafficDropReasonCount(String reason)
      Returns the total for one reason-coded traffic drop key (0 when absent).
    • recordTrafficToolSourceFallback

      public static void recordTrafficToolSourceFallback()
      Records a response-path export decision that used request-side tool-type fallback.

      This is used for observability when response tool source is absent but request-side correlation by message id still allows correct traffic export gating.

    • getTrafficToolSourceFallbacks

      public static long getTrafficToolSourceFallbacks()
      Returns total response-path tool-source fallbacks recorded this session.
    • getTotalSuccessCount

      public static long getTotalSuccessCount()
      Session total: sum of docs pushed across all indexes.
    • getTotalFailureCount

      public static long getTotalFailureCount()
      Session total: sum of failures across all indexes.
    • getTotalExportedBytes

      public static long getTotalExportedBytes()
      Session total: sum of estimated successful payload bytes across all indexes.
    • recordRetryQueueDrop

      public static void recordRetryQueueDrop(String indexKey, long count)
      Per-index retry queue: count of documents dropped when the retry queue was full.
    • getRetryQueueDrops

      public static long getRetryQueueDrops(String indexKey)
      Returns the session total of documents dropped from the retry queue for the given index.
    • getTotalRetryQueueDrops

      public static long getTotalRetryQueueDrops()
      Returns the session total of documents dropped from retry queues across all indexes.
    • getThroughputDocsPerSecLast60s

      public static double getThroughputDocsPerSecLast60s()
      Returns documents per second over the last 60 seconds (rolling throughput). Prunes entries older than the window. Thread-safe.
      Returns:
      docs/sec (0.0 or positive)
    • getThroughputDocsPerSecLast10s

      public static double getThroughputDocsPerSecLast10s()
      Returns documents per second over the last 10 seconds (rolling throughput). Prunes entries older than the window. Thread-safe.
      Returns:
      docs/sec (0.0 or positive)
    • recordExportStartRequested

      public static void recordExportStartRequested()
      Records that a new export start was requested.

      Resets startup latency tracking so the next successful traffic push can produce an updated start-to-first-traffic metric.

    • getStartToFirstTrafficMs

      public static long getStartToFirstTrafficMs()
      Returns milliseconds from the latest export Start request to the first successful traffic push, or -1 when not available yet.
    • getExportStartRequestedAtMs

      public static long getExportStartRequestedAtMs()
      Returns timestamp (epoch ms) for latest export Start request, or -1.
    • recordProxyHistorySnapshot

      public static void recordProxyHistorySnapshot(int attempted, int success, long durationMs, int finalChunkTarget)
      Records summary metrics for the latest proxy-history snapshot push.
      Parameters:
      attempted - attempted document count
      success - successful document count
      durationMs - wall-clock duration in milliseconds
      finalChunkTarget - final chunk target doc count at end of run
    • getLastProxyHistorySnapshot

      public static ExportStats.ProxyHistorySnapshotStats getLastProxyHistorySnapshot()
      Returns the latest proxy-history snapshot stats, or null when none recorded.