Skip to content

Open-source status page, incident response and uptime monitoring

✨ refactor TCP request handling to use 'URI' instead of 'URL' for con… (#1076)

Thibault Le Ouay06268d865cb3
diff --git a/apps/checker/handlers/tcp.go b/apps/checker/handlers/tcp.go
index 670d75ee8..e51409bf1 100644
--- a/apps/checker/handlers/tcp.go
+++ b/apps/checker/handlers/tcp.go
@@ -99,7 +99,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
op := func() error {
called++
- res, err := checker.PingTcp(int(req.Timeout), req.URL)
+ res, err := checker.PingTcp(int(req.Timeout), req.URI)
if err != nil {
return fmt.Errorf("unable to check tcp %s", err)
@@ -107,7 +107,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
timingAsString, err := json.Marshal(res)
if err != nil {
- return fmt.Errorf("error while parsing timing data %s: %w", req.URL, err)
+ return fmt.Errorf("error while parsing timing data %s: %w", req.URI, err)
}
latency := res.TCPDone - res.TCPStart
@@ -123,7 +123,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
Latency: latency,
CronTimestamp: req.CronTimestamp,
Trigger: trigger,
- URI: req.URL,
+ URI: req.URI,
}
response = TCPResponse{
@@ -191,7 +191,7 @@ func (h Handler) TCPHandler(c *gin.Context) {
MonitorID: monitorId,
Error: 1,
Trigger: trigger,
- URI: req.URL,
+ URI: req.URI,
}, dataSourceName); err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to send event to tinybird")
}
@@ -254,7 +254,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) {
op := func() error {
called++
timestamp := time.Now().UTC().UnixMilli()
- res, err := checker.PingTcp(int(req.Timeout), req.URL)
+ res, err := checker.PingTcp(int(req.Timeout), req.URI)
if err != nil {
return fmt.Errorf("unable to check tcp %s", err)
@@ -272,7 +272,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) {
timingAsString, err := json.Marshal(res)
if err != nil {
- return fmt.Errorf("error while parsing timing data %s: %w", req.URL, err)
+ return fmt.Errorf("error while parsing timing data %s: %w", req.URI, err)
}
latency := res.TCPDone - res.TCPStart
@@ -287,7 +287,7 @@ func (h Handler) TCPHandlerRegion(c *gin.Context) {
Latency: latency,
RequestId: req.RequestId,
Trigger: "api",
- URI: req.URL,
+ URI: req.URI,
}
if req.RequestId != 0 {
diff --git a/apps/checker/request/request.go b/apps/checker/request/request.go
index 4b145f2a8..a940d2a53 100644
--- a/apps/checker/request/request.go
+++ b/apps/checker/request/request.go
@@ -66,7 +66,7 @@ type HttpCheckerRequest struct {
type TCPCheckerRequest struct {
Status string `json:"status"`
WorkspaceID string `json:"workspaceId"`
- URL string `json:"url"`
+ URI string `json:"uri"`
MonitorID string `json:"monitorId"`
Trigger string `json:"trigger,omitempty"`
RawAssertions []json.RawMessage `json:"assertions,omitempty"`
diff --git a/apps/web/src/app/api/checker/test/tcp/route.ts b/apps/web/src/app/api/checker/test/tcp/route.ts
index 56d7004e2..9c4032a33 100644
--- a/apps/web/src/app/api/checker/test/tcp/route.ts
+++ b/apps/web/src/app/api/checker/test/tcp/route.ts
@@ -49,7 +49,7 @@ async function checkTCP(url: string, region: MonitorFlyRegion) {
},
method: "POST",
body: JSON.stringify({
- url,
+ uri: url,
}),
next: { revalidate: 0 },
});