fix
All checks were successful
Deploy Prod / Deploy prod (pull_request) Successful in 11s
Deploy Dev / Build (pull_request) Successful in 40s
Deploy Dev / Push (pull_request) Successful in 34s
Deploy Dev / Deploy dev (pull_request) Successful in 13s
Deploy Prod / Build (pull_request) Successful in 41s
Deploy Prod / Push (pull_request) Successful in 26s

This commit is contained in:
Egor Matveev 2025-06-15 23:00:45 +03:00
parent 3cdc41f864
commit 357418c66c

View File

@ -3,9 +3,11 @@ package routers
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"log"
"net/http" "net/http"
"os" "os"
tasks "queues-go/app/storage/mongo/collections" tasks "queues-go/app/storage/mongo/collections"
"strconv"
"sync" "sync"
"time" "time"
) )
@ -24,15 +26,19 @@ var MutexMap map[string]*sync.Mutex
func sendLatency(timestamp time.Time, latency int) error { func sendLatency(timestamp time.Time, latency int) error {
loc, _ := time.LoadLocation("Europe/Moscow") loc, _ := time.LoadLocation("Europe/Moscow")
s := fmt.Sprintf( s := fmt.Sprintf(
`{"timestamp":"%s","service":"queues","environment":"%s","name":"latency","count":%s}`, `{"timestamp":"%s","service":"queues","environment":"%s","name":"latency","count":%s}`,
timestamp.In(loc).Format("2006-01-02T15:04:05Z"), timestamp.In(loc).Format("2006-01-02T15:04:05Z"),
os.Getenv("STAGE"), os.Getenv("STAGE"),
latency, strconv.Itoa(latency),
) )
data := []byte(s) data := []byte(s)
r := bytes.NewReader(data) r := bytes.NewReader(data)
_, err := http.Post("http://monitoring:1237/api/v1/metrics/increment", "application/json", r) _, err := http.Post("http://monitoring:1237/api/v1/metrics/increment", "application/json", r)
if err != nil {
log.Printf("ERROR %s", err.Error())
}
return err return err
} }