Production counters and timings for tokenizer and parser operations.
Import path: github.com/ajitpratap0/GoSQLX/pkg/metrics (pkg.go.dev)
Part of the GoSQLX API reference.
Enable metrics collection.
metrics.Enable()Disable metrics collection.
Check if enabled.
Reset all metrics.
Record tokenization metrics.
Record parsing metrics.
Record pool get operation.
Record pool put operation.
Record pool cache hit.
Record pool cache miss.
Record error occurrence.
Get current metrics snapshot.
snapshot := metrics.GetSnapshot()
fmt.Printf("Total queries: %d\n", snapshot.TotalQueries)
fmt.Printf("Success rate: %.2f%%\n", snapshot.SuccessRate)type MetricsSnapshot struct {
TotalQueries int64
SuccessfulQueries int64
FailedQueries int64
SuccessRate float64
TotalTokens int64
AvgTokensPerQuery float64
PoolStats map[string]PoolStats
ErrorCounts map[string]int64
}type PoolStats struct {
Gets int64
Puts int64
Hits int64
Misses int64
HitRate float64
}Enhancements:
- Parser operation metrics (duration, errors, statement counts)
- AST pool metrics (gets/puts/balance)
- Statement pool metrics
- Expression pool metrics
- Tokenizer pool metrics with hit rate tracking
- Thread-safe atomic counters