lab6: OpenTelemetry (traces, metrics, logs), Collector, Prometheus, Loki, Tempo, Grafana; перенос trace context через outbox и AMQP

This commit is contained in:
2026-11-12 12:10:30 +03:00
parent 470d9d6f1e
commit 010739d9fa
118 changed files with 15009 additions and 3 deletions
+39
View File
@@ -0,0 +1,39 @@
package service
import (
"encoding/base64"
"strings"
"time"
"github.com/google/uuid"
)
func encodeCursor(scope string, createdAt time.Time, id string) string {
raw := scope + "|" + createdAt.UTC().Format(time.RFC3339Nano) + "|" + id
return base64.RawURLEncoding.EncodeToString([]byte(raw))
}
func decodeCursor(cursor, expectedScope string) (time.Time, string, error) {
raw, err := base64.RawURLEncoding.DecodeString(cursor)
if err != nil {
return time.Time{}, "", ErrInvalidInput
}
parts := strings.SplitN(string(raw), "|", 3)
if len(parts) != 3 {
return time.Time{}, "", ErrInvalidInput
}
if _, err := uuid.Parse(parts[0]); err != nil {
return time.Time{}, "", ErrInvalidInput
}
if parts[0] != expectedScope {
return time.Time{}, "", ErrInvalidInput
}
t, err := time.Parse(time.RFC3339Nano, parts[1])
if err != nil {
return time.Time{}, "", ErrInvalidInput
}
if _, err := uuid.Parse(parts[2]); err != nil {
return time.Time{}, "", ErrInvalidInput
}
return t, parts[2], nil
}