monitoring/app/storage/clickhouse/tables/tasks.go
Egor Matveev d11ae23369
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
fix
2025-06-13 23:25:34 +03:00

35 lines
649 B
Go

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()
}