fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 57s
Deploy Dev / Push (pull_request) Successful in 35s
Deploy Dev / Deploy dev (pull_request) Successful in 12s

This commit is contained in:
Egor Matveev
2025-06-13 23:25:34 +03:00
parent 3d73678be0
commit d11ae23369
4 changed files with 69 additions and 8 deletions

View File

@@ -9,12 +9,12 @@ import (
)
type EndpointMetric struct {
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Endpoint string `json:"endpoint"`
StatusCode int `json:"status_code"`
ResponseTime int `json:"response_time"`
Method string `json:"method"`
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Endpoint string `json:"endpoint"`
StatusCode int `json:"status_code"`
ResponseTime int `json:"response_time"`
Method string `json:"method"`
}
func AddEndpointMetric(metric EndpointMetric) error {

View File

@@ -0,0 +1,34 @@
package storage
import (
"context"
"time"
)
type TaskMetric struct {
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Queue string `json:"queue"`
Success bool `json:"success"`
ExecutionTimeMs int `json:"execution_time_ms"`
}
func AddTaskMetric(metric TaskMetric) error {
batch, err := connection().PrepareBatch(context.Background(), "INSERT INTO tasks")
if err != nil {
return err
}
err = batch.Append(
metric.Timestamp,
metric.Service,
metric.Queue,
metric.Success,
metric.ExecutionTimeMs,
)
if err != nil {
return err
}
return batch.Send()
}