-
Notifications
You must be signed in to change notification settings - Fork 32
/
event.go
54 lines (45 loc) · 1.21 KB
/
event.go
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
package datadog
import (
"fmt"
"github.com/segmentio/stats"
)
// EventPriority is an enumeration providing the available datadog event
// priority levels.
type EventPriority string
const (
EventPriorityNormal EventPriority = "normal"
EventPriorityLow EventPriority = "low"
)
// EventAlertType is an enumeration providing the available datadog event
// allert types.
type EventAlertType string
const (
EventAlertTypeError EventAlertType = "error"
EventAlertTypeWarning EventAlertType = "warning"
EventAlertTypeInfo EventAlertType = "info"
EventAlertTypeSuccess EventAlertType = "success"
)
// Event is a representation of a datadog event
type Event struct {
Title string
Text string
Ts int64
Priority EventPriority
Host string
Tags []stats.Tag
AlertType EventAlertType
AggregationKey string
SourceTypeName string
EventType string
}
// String satisfies the fmt.Stringer interface.
func (e Event) String() string {
return fmt.Sprint(e)
}
// Format satisfies the fmt.Formatter interface.
func (e Event) Format(f fmt.State, _ rune) {
buf := bufferPool.Get().(*buffer)
buf.b = appendEvent(buf.b[:0], e)
f.Write(buf.b)
bufferPool.Put(buf)
}