metrics

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package metrics provides metrics collection for the DAST crawler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobal

func SetGlobal(c *Collector)

SetGlobal sets the global metrics collector.

Types

type Collector

type Collector struct {
	// contains filtered or unexported fields
}

Collector collects and aggregates metrics.

func Global

func Global() *Collector

Global returns the global metrics collector.

func New

func New() *Collector

New creates a new metrics collector.

func (*Collector) GetAverageResponseTime

func (c *Collector) GetAverageResponseTime() time.Duration

GetAverageResponseTime returns the average response time.

func (*Collector) GetErrorsPerSecond

func (c *Collector) GetErrorsPerSecond() float64

GetErrorsPerSecond returns the current errors per second rate.

func (*Collector) GetRequestsPerSecond

func (c *Collector) GetRequestsPerSecond() float64

GetRequestsPerSecond returns the current requests per second rate.

func (*Collector) RecordAPIEndpoint

func (c *Collector) RecordAPIEndpoint()

RecordAPIEndpoint increments API endpoints.

func (*Collector) RecordBytes

func (c *Collector) RecordBytes(n int64)

RecordBytes records transferred bytes.

func (*Collector) RecordError

func (c *Collector) RecordError(errorType string)

RecordError records an error.

func (*Collector) RecordFormFound

func (c *Collector) RecordFormFound()

RecordFormFound increments found forms.

func (*Collector) RecordPageCrawled

func (c *Collector) RecordPageCrawled()

RecordPageCrawled increments crawled pages.

func (*Collector) RecordPageDiscovered

func (c *Collector) RecordPageDiscovered()

RecordPageDiscovered increments discovered pages.

func (*Collector) RecordRequest

func (c *Collector) RecordRequest()

RecordRequest records an HTTP request.

func (*Collector) RecordResponseTime

func (c *Collector) RecordResponseTime(d time.Duration)

RecordResponseTime records a response time.

func (*Collector) RecordRetry

func (c *Collector) RecordRetry()

RecordRetry records a retry attempt.

func (*Collector) RecordStatusCode

func (c *Collector) RecordStatusCode(code int)

RecordStatusCode records an HTTP status code.

func (*Collector) RecordWebSocket

func (c *Collector) RecordWebSocket()

RecordWebSocket increments WebSocket endpoints.

func (*Collector) Reset

func (c *Collector) Reset()

Reset resets all metrics.

func (*Collector) SetActiveWorkers

func (c *Collector) SetActiveWorkers(n int64)

SetActiveWorkers sets the number of active workers.

func (*Collector) SetBrowserPoolStats

func (c *Collector) SetBrowserPoolStats(size, inUse int64)

SetBrowserPoolStats sets browser pool statistics.

func (*Collector) SetQueueDepth

func (c *Collector) SetQueueDepth(depth int64)

SetQueueDepth sets the current queue depth.

func (*Collector) Snapshot

func (c *Collector) Snapshot() *Snapshot

Snapshot returns a point-in-time snapshot of all metrics.

type Snapshot

type Snapshot struct {
	Timestamp           time.Time        `json:"timestamp"`
	Uptime              time.Duration    `json:"uptime"`
	RequestsTotal       int64            `json:"requests_total"`
	ErrorsTotal         int64            `json:"errors_total"`
	PagesDiscovered     int64            `json:"pages_discovered"`
	PagesCrawled        int64            `json:"pages_crawled"`
	FormsFound          int64            `json:"forms_found"`
	APIEndpoints        int64            `json:"api_endpoints"`
	WebSockets          int64            `json:"websockets"`
	BytesTotal          int64            `json:"bytes_total"`
	RetriesTotal        int64            `json:"retries_total"`
	QueueDepth          int64            `json:"queue_depth"`
	ActiveWorkers       int64            `json:"active_workers"`
	BrowserPoolSize     int64            `json:"browser_pool_size"`
	BrowserPoolInUse    int64            `json:"browser_pool_in_use"`
	RequestsPerSecond   float64          `json:"requests_per_second"`
	ErrorsPerSecond     float64          `json:"errors_per_second"`
	AverageResponseTime time.Duration    `json:"average_response_time"`
	ErrorCounts         map[string]int64 `json:"error_counts"`
	StatusCodes         map[int]int64    `json:"status_codes"`
	ResponseTimeHist    []int64          `json:"response_time_histogram"`
}

Snapshot represents a point-in-time view of metrics.

func (*Snapshot) BrowserPoolUtilization

func (s *Snapshot) BrowserPoolUtilization() float64

BrowserPoolUtilization returns the browser pool utilization (0-1).

func (*Snapshot) ErrorRate

func (s *Snapshot) ErrorRate() float64

ErrorRate returns the error rate (errors/requests).

func (*Snapshot) Summary

func (s *Snapshot) Summary() map[string]interface{}

Summary returns a human-readable summary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL