monitoring/app/storage/clickhouse/tables/increments.go
Egor Matveev f2ab91cbce
All checks were successful
Deploy Dev / Build (pull_request) Successful in 58s
Deploy Dev / Push (pull_request) Successful in 36s
Deploy Dev / Deploy dev (pull_request) Successful in 15s
fix
2025-06-15 22:24:06 +03:00

35 lines
633 B
Go

package storage
import (
"context"
"time"
)
type IncrementMetric struct {
Timestamp time.Time `json:"timestamp"`
Service string `json:"service"`
Environment string `json:"environment"`
Name string `json:"name"`
Count int `json:"count"`
}
func AddIncrementMetric(metric IncrementMetric) error {
batch, err := connection().PrepareBatch(context.Background(), "INSERT INTO increments")
if err != nil {
return err
}
err = batch.Append(
metric.Timestamp,
metric.Service,
metric.Environment,
metric.Name,
metric.Count,
)
if err != nil {
return err
}
return batch.Send()
}