Documentation
¶
Index ¶
- Constants
- Variables
- func MetricsMiddleware(m *Metrics) func(http.Handler) http.Handler
- func RateLimitMiddleware(cfg *config.Config, limiter *RateLimiter) func(http.Handler) http.Handler
- type ContextKey
- type JWTClaims
- type Metrics
- func (m *Metrics) GetSnapshot() MetricsSnapshot
- func (m *Metrics) PrometheusFormat() string
- func (m *Metrics) PrometheusFormatSnapshot(snapshot MetricsSnapshot) string
- func (m *Metrics) RecordCacheHit()
- func (m *Metrics) RecordCacheMiss()
- func (m *Metrics) RecordEntityCreate()
- func (m *Metrics) RecordEntityDelete()
- func (m *Metrics) RecordEntityList()
- func (m *Metrics) RecordEntityRead()
- func (m *Metrics) RecordEntityUpdate()
- func (m *Metrics) RecordGraphQuery()
- func (m *Metrics) RecordOQLQuery()
- func (m *Metrics) RecordSearchQuery()
- type MetricsSnapshot
- type RateLimiter
- type TenantGrant
Constants ¶
const ( ContextKeySubject = authmw.ContextKeySubject ContextKeyAuthMethod = authmw.ContextKeyAuthMethod ContextKeyTenantGrant = authmw.ContextKeyTenantGrant )
Variables ¶
var ( AuthMiddleware = authmw.AuthMiddleware GetSubject = authmw.GetSubject GetAuthMethod = authmw.GetAuthMethod TenantGrantFromContext = authmw.TenantGrantFromContext )
Functions ¶
func MetricsMiddleware ¶
MetricsMiddleware creates a middleware that collects request metrics
func RateLimitMiddleware ¶
RateLimitMiddleware creates a rate limiting middleware
Types ¶
type ContextKey ¶
type ContextKey = authmw.ContextKey
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics collects server metrics for observability
func (*Metrics) GetSnapshot ¶
func (m *Metrics) GetSnapshot() MetricsSnapshot
GetSnapshot returns a snapshot of current metrics
func (*Metrics) PrometheusFormat ¶
PrometheusFormat returns metrics in Prometheus exposition format.
func (*Metrics) PrometheusFormatSnapshot ¶
func (m *Metrics) PrometheusFormatSnapshot(snapshot MetricsSnapshot) string
PrometheusFormatSnapshot renders an already-built snapshot. Use this when the caller has augmented the snapshot (e.g. with blob usage figures) before rendering, to avoid a second GetSnapshot call.
func (*Metrics) RecordCacheHit ¶
func (m *Metrics) RecordCacheHit()
RecordCacheHit records a cache hit
func (*Metrics) RecordCacheMiss ¶
func (m *Metrics) RecordCacheMiss()
RecordCacheMiss records a cache miss
func (*Metrics) RecordEntityCreate ¶
func (m *Metrics) RecordEntityCreate()
RecordEntityCreate records an entity creation
func (*Metrics) RecordEntityDelete ¶
func (m *Metrics) RecordEntityDelete()
RecordEntityDelete records an entity deletion
func (*Metrics) RecordEntityList ¶
func (m *Metrics) RecordEntityList()
RecordEntityList records an entity list operation
func (*Metrics) RecordEntityRead ¶
func (m *Metrics) RecordEntityRead()
RecordEntityRead records an entity read
func (*Metrics) RecordEntityUpdate ¶
func (m *Metrics) RecordEntityUpdate()
RecordEntityUpdate records an entity update
func (*Metrics) RecordGraphQuery ¶
func (m *Metrics) RecordGraphQuery()
RecordGraphQuery records a graph query
func (*Metrics) RecordOQLQuery ¶
func (m *Metrics) RecordOQLQuery()
RecordOQLQuery records an OQL query
func (*Metrics) RecordSearchQuery ¶
func (m *Metrics) RecordSearchQuery()
RecordSearchQuery records a search query
type MetricsSnapshot ¶
type MetricsSnapshot struct {
Uptime time.Duration
RequestsTotal uint64
RequestsByPath map[string]uint64
RequestsByCode map[int]uint64
RequestErrors uint64
ActiveRequests int64
LatencyAvgMs float64
LatencySumSec float64 // total latency in seconds (for Prometheus _sum)
LatencyCount uint64 // total observations (for Prometheus _count)
LatencyBuckets map[string]uint64
EntityCreates uint64
EntityReads uint64
EntityUpdates uint64
EntityDeletes uint64
EntityLists uint64
CacheHits uint64
CacheMisses uint64
SearchQueries uint64
OQLQueries uint64
GraphQueries uint64
// Blob store usage — populated by the server from the UsageSampler cache.
// All zero when the blob store is disabled or the sampler has not yet run.
BlobEnabled bool
BlobBlobCount int64
BlobKeyCount int64
BlobBytes int64
BlobTenants int64
}
MetricsSnapshot is a point-in-time snapshot of metrics
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a fixed-window rate limiter. This allows up to 2x burst at window boundaries; a sliding-window approach would prevent that but adds complexity. Acceptable for the current use case.
func NewRateLimiter ¶
func NewRateLimiter(cfg *config.Config) *RateLimiter
NewRateLimiter creates a new rate limiter
func (*RateLimiter) Stop ¶
func (rl *RateLimiter) Stop()
Stop stops the rate limiter cleanup goroutine
type TenantGrant ¶
type TenantGrant = authmw.TenantGrant