35 lines
649 B
Go
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()
|
|
}
|