Skip to content

Commit

Permalink
🔥 tcp timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultleouay committed Oct 9, 2024
1 parent 988916d commit 516e646
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/checker/handlers/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type TCPData struct {
Timing string `json:"timing"`
ErrorMessage string `json:"errorMessage"`
Region string `json:"region"`
Trigger string `json:"trigger"`

RequestId int64 `json:"requestId,omitempty"`
WorkspaceID int64 `json:"workspaceId"`
Expand Down Expand Up @@ -111,6 +112,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
Timing: string(timingAsString),
Latency: latency,
CronTimestamp: req.CronTimestamp,
Trigger: "cron",
}

if req.Status == "active" && req.DegradedAfter > 0 && latency > req.DegradedAfter {
Expand Down Expand Up @@ -167,6 +169,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
Region: h.Region,
MonitorID: monitorId,
Error: 1,
Trigger: "cron",
}, dataSourceName); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
}
Expand Down Expand Up @@ -277,6 +280,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) {
Timing: string(timingAsString),
Latency: latency,
RequestId: req.RequestId,
Trigger: "API",
}

if req.RequestId != 0 {
Expand All @@ -297,6 +301,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) {
MonitorID: monitorId,
Error: 1,
RequestId: req.RequestId,
Trigger: "api",
}, dataSourceName); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
}
Expand Down
2 changes: 2 additions & 0 deletions packages/tinybird/datasources/tcp_response.datasource
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ SCHEMA >
`latency` Int64 `json:$.latency`,
`errorMessage` Nullable(String) `json:$.errorMessage`,
`error` Int16 `json:$.error`
`trigger` Nullable(String) `json:$.trigger`,


ENGINE "MergeTree"
ENGINE_PARTITION_KEY "toYYYYMM(fromUnixTimestamp64Milli(timestamp))"
Expand Down

0 comments on commit 516e646

Please sign in to comment.