Documentation
¶
Overview ¶
Package metrics provides webhook health monitoring for chat apps.
Index ¶
- type ErrorRecord
- type EventType
- type MetricsKey
- type Registry
- func (r *Registry) Clear(platform string, credID int64)
- func (r *Registry) GetAllMetrics() map[MetricsKey]*WebhookMetricsSnapshot
- func (r *Registry) GetMetrics(platform string, credID int64) *WebhookMetricsSnapshot
- func (r *Registry) RecordEvent(platform string, credID int64, eventType EventType, ...)
- type WebhookMetrics
- type WebhookMetricsSnapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorRecord ¶
ErrorRecord records details of an error.
type EventType ¶
type EventType string
EventType represents the type of webhook event being tracked.
const ( EventWebhookReceived EventType = "webhook_received" EventWebhookValidated EventType = "webhook_validated" EventWebhookParseError EventType = "webhook_parse_error" EventMessageProcessed EventType = "message_processed" EventResponseSent EventType = "response_sent" EventResponseError EventType = "response_error" )
type MetricsKey ¶
MetricsKey identifies a metric entry (platform + credential ID).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds metrics for all registered webhook endpoints.
func (*Registry) GetAllMetrics ¶
func (r *Registry) GetAllMetrics() map[MetricsKey]*WebhookMetricsSnapshot
GetAllMetrics returns snapshots of all metrics.
func (*Registry) GetMetrics ¶
func (r *Registry) GetMetrics(platform string, credID int64) *WebhookMetricsSnapshot
GetMetrics returns a snapshot of metrics for a specific key.
type WebhookMetrics ¶
type WebhookMetrics struct {
// contains filtered or unexported fields
}
WebhookMetrics tracks delivery metrics for webhooks.
type WebhookMetricsSnapshot ¶
type WebhookMetricsSnapshot struct {
TotalReceived int64
TotalValidated int64
ParseErrors int64
MessagesProcessed int64
ResponsesSent int64
ResponseErrors int64
LastReceived time.Time
LastValidated time.Time
LastError time.Time
AvgProcessTime time.Duration
RecentErrors []ErrorRecord
}
WebhookMetricsSnapshot is a thread-safe snapshot of webhook metrics.
func (*WebhookMetricsSnapshot) ErrorRate ¶
func (s *WebhookMetricsSnapshot) ErrorRate() float64
ErrorRate calculates the error rate (errors / processed).
func (*WebhookMetricsSnapshot) IsHealthy ¶
func (s *WebhookMetricsSnapshot) IsHealthy() bool
IsHealthy checks if the webhook is healthy (received within last 5 minutes).
func (*WebhookMetricsSnapshot) SuccessRate ¶
func (s *WebhookMetricsSnapshot) SuccessRate() float64
SuccessRate calculates the success rate (validated / received).