Repository navigation
Expand file tree
/
Copy patherrors.go
More file actions
89 lines (72 loc) · 2.91 KB
/
Copy patherrors.go
File metadata and controls
89 lines (72 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package guardagent
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
// Typed errors. Callers should test with errors.Is for the sentinels and
// errors.As for the structural types.
var (
// ErrBufferFull is the sentinel matched by every BufferFullError via
// errors.Is. BufferFullError itself is returned by SendEvent and
// SendMetric only when the configured overflow policy is OverflowRaise.
ErrBufferFull = errors.New("guardagent: buffer full")
// ErrClosed is returned by SendEvent, SendMetric, and Flush after Stop.
ErrClosed = errors.New("guardagent: agent is stopped")
// ErrCircuitOpen is returned by Flush while the transport circuit
// breaker is open.
ErrCircuitOpen = errors.New("guardagent: transport circuit breaker is open")
// ErrInvalidEvent is returned when an event or metric fails
// validation. It wraps the item-specific detail.
ErrInvalidEvent = errors.New("guardagent: invalid telemetry item")
// ErrInternal is returned when an exported method recovered from an
// unexpected panic. The agent stays usable; the panic is logged.
ErrInternal = errors.New("guardagent: internal error")
)
// BufferFullError reports that the per-kind buffer is full under the
// OverflowRaise policy. It matches ErrBufferFull with errors.Is.
type BufferFullError struct {
Kind string // "event" or "metric"
MaxLen int
}
func (e *BufferFullError) Error() string {
return fmt.Sprintf("guardagent: %s buffer full at maxlen=%d and overflow policy is raise", e.Kind, e.MaxLen)
}
// Is makes errors.Is(err, ErrBufferFull) true for every BufferFullError.
func (e *BufferFullError) Is(target error) bool { return target == ErrBufferFull }
// ConfigError reports one or more invalid configuration fields.
type ConfigError struct {
Problems []string
}
func (e *ConfigError) Error() string {
return "guardagent: invalid configuration: " + strings.Join(e.Problems, "; ")
}
// PermanentError reports a non-retryable HTTP rejection from the ingestion
// API (400, 404, 422). The affected batch is durably dropped (persisted
// records confirmed), never requeued.
type PermanentError struct {
StatusCode int
Detail string
}
func (e *PermanentError) Error() string {
return fmt.Sprintf("guardagent: permanent rejection with status %d: %s", e.StatusCode, e.Detail)
}
// RateLimitedError reports that the ingestion API answered 429 and the
// Retry-After budget was exhausted without a successful retry. The affected
// batch is requeued.
type RateLimitedError struct {
RetryAfter time.Duration
}
func (e *RateLimitedError) Error() string {
return "guardagent: rate limited, retry after " + strconv.FormatInt(int64(e.RetryAfter.Seconds()), 10) + "s"
}
// payloadTooLargeError marks a 413 response so sendBatch can recurse into
// the split-or-drop path. It never escapes the package.
type payloadTooLargeError struct {
detail string
}
func (e *payloadTooLargeError) Error() string {
return "guardagent: payload too large: " + e.detail
}