Documentation
¶
Index ¶
- Variables
- func ComputeAttemptRates(data []AttemptMetricsDataPoint, req MetricsRequest)
- func ComputeEventRates(data []EventMetricsDataPoint, req MetricsRequest)
- func EnrichMeasuresForRates(measures []string) []string
- func ValidateMetricsRequest(req MetricsRequest) error
- type AttemptMetricsDataPoint
- type AttemptMetricsResponse
- type AttemptRecord
- type EventMetricsDataPoint
- type EventMetricsResponse
- type Granularity
- type ListAttemptRequest
- type ListAttemptResponse
- type ListEventRequest
- type ListEventResponse
- type LogStore
- type Metrics
- type MetricsMetadata
- type MetricsRequest
- type Records
- type RetrieveAttemptRequest
- type RetrieveEventRequest
- type TimeFilter
- type TimeRange
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidTimeRange = errors.New("invalid time range: start must be before end")
ErrInvalidTimeRange is returned when the time range is invalid (e.g. start >= end). Callers should surface this as a 400.
var ErrResourceLimit = errors.New("metrics query exceeded resource limits")
ErrResourceLimit is returned when a metrics query exceeds server-side resource limits (e.g. too many GROUP BY rows, query timeout). Callers should surface this as a 400 rather than a 500.
Functions ¶
func ComputeAttemptRates ¶ added in v0.15.0
func ComputeAttemptRates(data []AttemptMetricsDataPoint, req MetricsRequest)
ComputeAttemptRates populates Rate, SuccessfulRate, and FailedRate fields on attempt data points from their corresponding count fields and the bucket duration.
func ComputeEventRates ¶ added in v0.15.0
func ComputeEventRates(data []EventMetricsDataPoint, req MetricsRequest)
ComputeEventRates populates Rate fields on event data points from their corresponding count fields and the bucket duration.
func EnrichMeasuresForRates ¶ added in v0.15.0
EnrichMeasuresForRates returns a new measures slice with any missing rate dependencies appended. For example, if "rate" is requested but "count" is not, "count" is added so the SQL query computes it.
func ValidateMetricsRequest ¶ added in v0.15.0
func ValidateMetricsRequest(req MetricsRequest) error
ValidateMetricsRequest checks that the metrics request is well-formed.
Types ¶
type AttemptMetricsDataPoint ¶ added in v0.15.0
type AttemptMetricsDataPoint struct {
TimeBucket *time.Time
// Measures
Count *int
SuccessfulCount *int
FailedCount *int
ErrorRate *float64
// NOTE: The following three measures are equivalent to using "count" with
// the corresponding filters (attempt_number=1 AND manual=false, attempt_number>1,
// manual=true). They exist for composability — callers can request multiple
// measures in a single query instead of issuing separate filtered queries.
// Consider whether they're worth the added surface area or if callers should
// use count+filters.
FirstAttemptCount *int
RetryCount *int
ManualRetryCount *int
AvgAttemptNumber *float64
Rate *float64
SuccessfulRate *float64
FailedRate *float64
// Dimensions
TenantID *string
DestinationID *string
Topic *string
Status *string
Code *string
Manual *bool
AttemptNumber *int
}
type AttemptMetricsResponse ¶ added in v0.15.0
type AttemptMetricsResponse struct {
Data []AttemptMetricsDataPoint
Metadata MetricsMetadata
}
type AttemptRecord ¶ added in v0.13.0
type AttemptRecord struct {
Attempt *models.Attempt
Event *models.Event // optionally populated for query results
}
AttemptRecord represents an attempt query result with optional Event population.
type EventMetricsDataPoint ¶ added in v0.15.0
type EventMetricsResponse ¶ added in v0.15.0
type EventMetricsResponse struct {
Data []EventMetricsDataPoint
Metadata MetricsMetadata
}
type Granularity ¶ added in v0.15.0
Granularity defines the time-bucketing interval for metrics queries. For sub-day units (s, m, h), Value controls both step size and alignment (e.g. 5m → buckets at :00, :05, :10, …). For calendar units with Value=1, alignment is to the natural period start (start of day, Sunday-based week, or first of month). For calendar units with Value>1, alignment uses epoch-anchored intervals (d/w from 1970-01-01/1970-01-04, M from Jan 1970) so that multi-day, multi-week, and multi-month granularities aggregate data correctly.
type ListAttemptRequest ¶ added in v0.13.0
type ListAttemptRequest struct {
Next string
Prev string
Limit int
TimeFilter TimeFilter // optional - filter attempts by time
TenantIDs []string // optional - filter by tenant (if empty, returns all tenants)
EventIDs []string // optional - filter by event ID
DestinationIDs []string // optional
Status string // optional: "success", "failed"
Topics []string // optional
SortOrder string // optional: "asc", "desc" (default: "desc")
}
type ListAttemptResponse ¶ added in v0.13.0
type ListAttemptResponse struct {
Data []*AttemptRecord
Next string
Prev string
}
type ListEventRequest ¶
type ListEventRequest struct {
Next string
Prev string
Limit int
TimeFilter TimeFilter // optional - filter events by time
TenantIDs []string // optional - filter by tenant (if empty, returns all tenants)
EventIDs []string // optional - filter by event ID
DestinationIDs []string // optional
Topics []string // optional
SortOrder string // optional: "asc", "desc" (default: "desc")
}
type ListEventResponse ¶
type Metrics ¶ added in v0.15.0
type Metrics interface {
QueryEventMetrics(ctx context.Context, req MetricsRequest) (*EventMetricsResponse, error)
QueryAttemptMetrics(ctx context.Context, req MetricsRequest) (*AttemptMetricsResponse, error)
}
type MetricsMetadata ¶ added in v0.15.0
type MetricsRequest ¶ added in v0.15.0
type Records ¶ added in v0.15.0
type Records interface {
ListEvent(context.Context, ListEventRequest) (ListEventResponse, error)
ListAttempt(context.Context, ListAttemptRequest) (ListAttemptResponse, error)
RetrieveEvent(ctx context.Context, request RetrieveEventRequest) (*models.Event, error)
RetrieveAttempt(ctx context.Context, request RetrieveAttemptRequest) (*AttemptRecord, error)
InsertMany(context.Context, []*models.LogEntry) error
}
type RetrieveAttemptRequest ¶ added in v0.13.0
type RetrieveEventRequest ¶ added in v0.13.0
type TimeFilter ¶ added in v0.13.0
type TimeFilter struct {
GTE *time.Time // Greater than or equal (>=)
LTE *time.Time // Less than or equal (<=)
GT *time.Time // Greater than (>)
LT *time.Time // Less than (<)
}
TimeFilter represents time-based filter criteria with support for both inclusive (GTE/LTE) and exclusive (GT/LT) comparisons.