-
Notifications
You must be signed in to change notification settings - Fork 307
/
reporting_types.go
149 lines (130 loc) · 3.77 KB
/
reporting_types.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package types
import (
"database/sql"
"encoding/json"
)
type Config struct {
ClientName string
ConnInfo string
}
const (
CORE_REPORTING_CLIENT = "core"
WAREHOUSE_REPORTING_CLIENT = "warehouse"
SUPPORTED_TRANSFORMER_API_VERSION = 2
DEFAULT_REPORTING_ENABLED = true
DEFAULT_REPLAY_ENABLED = false
)
var (
DiffStatus = "diff"
// Module names
GATEWAY = "gateway"
DESTINATION_FILTER = "destination_filter"
TRACKINGPLAN_VALIDATOR = "tracking_plan_validator"
USER_TRANSFORMER = "user_transformer"
EVENT_FILTER = "event_filter"
DEST_TRANSFORMER = "dest_transformer"
ROUTER = "router"
BATCH_ROUTER = "batch_router"
WAREHOUSE = "warehouse"
)
type Client struct {
Config
DbHandle *sql.DB
}
type StatusDetail struct {
Status string `json:"state"`
Count int64 `json:"count"`
StatusCode int `json:"statusCode"`
SampleResponse string `json:"sampleResponse"`
SampleEvent json.RawMessage `json:"sampleEvent"`
EventName string `json:"eventName"`
EventType string `json:"eventType"`
}
type ReportByStatus struct {
InstanceDetails
ConnectionDetails
PUDetails
ReportMetadata
StatusDetail *StatusDetail
}
type InstanceDetails struct {
WorkspaceID string `json:"workspaceId"`
Namespace string `json:"namespace"`
InstanceID string `json:"instanceId"`
}
type ReportMetadata struct {
ReportedAt int64 `json:"reportedAt"`
}
type Metric struct {
InstanceDetails
ConnectionDetails
PUDetails
ReportMetadata
StatusDetails []*StatusDetail `json:"reports"`
}
type ConnectionDetails struct {
SourceID string `json:"sourceId"`
DestinationID string `json:"destinationId"`
SourceBatchID string `json:"sourceBatchId"`
SourceTaskID string `json:"sourceTaskId"`
SourceTaskRunID string `json:"sourceTaskRunId"`
SourceJobID string `json:"sourceJobId"`
SourceJobRunID string `json:"sourceJobRunId"`
SourceDefinitionId string `json:"sourceDefinitionId"`
DestinationDefinitionId string `string:"destinationDefinitionId"`
SourceCategory string `json:"sourceCategory"`
}
type PUDetails struct {
InPU string `json:"inReportedBy"`
PU string `json:"reportedBy"`
TerminalPU bool `json:"terminalState"`
InitialPU bool `json:"initialState"`
}
type PUReportedMetric struct {
ConnectionDetails
PUDetails
StatusDetail *StatusDetail
}
func CreateConnectionDetail(sid, did, sbid, stid, strid, sjid, sjrid, sdid, ddid, sc string) *ConnectionDetails {
return &ConnectionDetails{
SourceID: sid,
DestinationID: did,
SourceBatchID: sbid,
SourceTaskID: stid,
SourceTaskRunID: strid,
SourceJobID: sjid,
SourceJobRunID: sjrid,
SourceDefinitionId: sdid,
DestinationDefinitionId: ddid,
SourceCategory: sc,
}
}
func CreateStatusDetail(status string, count int64, code int, resp string, event json.RawMessage, eventName, eventType string) *StatusDetail {
return &StatusDetail{
Status: status,
Count: count,
StatusCode: code,
SampleResponse: resp,
SampleEvent: event,
EventName: eventName,
EventType: eventType,
}
}
func CreatePUDetails(inPU, pu string, terminalPU, initialPU bool) *PUDetails {
return &PUDetails{
InPU: inPU,
PU: pu,
TerminalPU: terminalPU,
InitialPU: initialPU,
}
}
func AssertSameKeys(m1 map[string]*ConnectionDetails, m2 map[string]*StatusDetail) {
if len(m1) != len(m2) {
panic("maps length don't match") // TODO improve msg
}
for k := range m1 {
if _, ok := m2[k]; !ok {
panic("key in map1 not found in map2") // TODO improve msg
}
}
}