add monitoring
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
aovantsev
2025-10-05 09:58:13 +03:00
parent ebf4bdeede
commit 85221dfb1f
9 changed files with 223 additions and 25 deletions

View File

@@ -27,10 +27,13 @@ func CreateCounterHandler(c *gin.Context) {
).Scan(&counter.ID, &counter.UserID, &counter.Name, &counter.Description, &counter.CreatedAt, &counter.UpdatedAt)
if err != nil {
RecordDBOperation("insert", "counters")
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to create counter"})
return
}
RecordDBOperation("insert", "counters")
c.JSON(http.StatusCreated, counter)
}
@@ -61,11 +64,14 @@ func GetCountersHandler(c *gin.Context) {
rows, err := db.Query(query, args...)
if err != nil {
RecordDBOperation("select", "counters")
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to fetch counters"})
return
}
defer rows.Close()
RecordDBOperation("select", "counters")
counters := []CounterWithStats{} // Initialize as empty slice, not nil
for rows.Next() {
var counter CounterWithStats