From 65517943099786e8b570807e35354aabfca6021d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Elek?= Date: Wed, 21 Feb 2024 14:21:28 +0100 Subject: [PATCH] bigquery: monkit stat and timeout for BQ eventkit injection Change-Id: I923004513ed27b15b5e285430df5a23ae2d88c64 --- eventkitd-bigquery/bigquery/destination.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eventkitd-bigquery/bigquery/destination.go b/eventkitd-bigquery/bigquery/destination.go index a724bd0..999b861 100644 --- a/eventkitd-bigquery/bigquery/destination.go +++ b/eventkitd-bigquery/bigquery/destination.go @@ -1,3 +1,6 @@ +// Copyright (C) 2024 Storj Labs, Inc. +// See LICENSE for copying information. + package bigquery import ( @@ -38,6 +41,8 @@ func NewBigQueryDestination(ctx context.Context, appName string, project string, // Submit implements Destination. func (b *BigQueryDestination) Submit(events ...*eventkit.Event) { + var err error + defer mon.Task()(nil)(&err) records := map[string][]*Record{} for _, event := range events { var tags []*pb.Tag @@ -65,7 +70,9 @@ func (b *BigQueryDestination) Submit(events ...*eventkit.Event) { }) } - err := b.client.SaveRecord(context.Background(), records) + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) + defer cancel() + err = b.client.SaveRecord(ctx, records) if err != nil { fmt.Println("WARN: Couldn't save eventkit record to BQ: ", err) }