Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can β€” learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company πŸ‘‡

fix(monitor/collectors/coinbase): use envelope timestamp (per-ticker time field is not in real Coinbase frames)

CarterPerez-dev9c35e14ae872
diff --git a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/coinbase/collector.go b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/coinbase/collector.go
index 457a51aa..5682b576 100644
--- a/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/coinbase/collector.go
+++ b/PROJECTS/advanced/monitor-the-situation-dashboard/backend/internal/collectors/coinbase/collector.go
@@ -103,10 +103,14 @@ func (c *Collector) handleConn(ctx context.Context, conn *Conn) error {
loopErr := ReadLoop(ctx, conn, seq, func(hctx context.Context, f Frame) error {
switch f.Kind {
case FrameTypeTicker, FrameTypeSnapshot:
+ ts := f.Timestamp.UTC()
+ if ts.IsZero() {
+ ts = time.Now().UTC()
+ }
for _, tk := range f.Tickers {
tick := Tick{
Symbol: tk.ProductID,
- TS: tk.Time.UTC(),
+ TS: ts,
Price: tk.Price,
Volume24h: tk.Volume24h,
}