Skip to content

Commit 9acde9e

Browse files
committed
Improve logs of graphkb clients.
1 parent 413f546 commit 9acde9e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/client/transaction.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func withRetryOnTooManyRequests(fn func() error, backoffFactor float64, maxRetri
6666
}
6767
trials++
6868
if trials == maxRetries {
69-
return fmt.Errorf("Too many retries... Aborting")
69+
return fmt.Errorf("Too many retries... Aborting: %v", err)
7070
}
7171
}
7272
}
@@ -87,9 +87,10 @@ func (cgt *Transaction) Commit() (*knowledge.Graph, error) {
8787
fmt.Println("Start uploading the graph...")
8888

8989
progress := pb.New(len(bulk.GetAssetRemovals()) + len(bulk.GetAssetUpserts()) + len(bulk.GetRelationRemovals()) + len(bulk.GetRelationUpserts()))
90-
defer progress.Finish()
9190

9291
progress.Start()
92+
defer progress.Finish()
93+
9394
p := utils.NewWorkerPool(cgt.parallelization)
9495
defer p.Close()
9596

@@ -113,7 +114,7 @@ func (cgt *Transaction) Commit() (*knowledge.Graph, error) {
113114
}
114115
f := p.Exec(func() error {
115116
if err := withRetryOnTooManyRequests(func() error { return cgt.client.DeleteRelations(relations) }, cgt.retryBackoffFactor, cgt.retryCount, cgt.retryDelay); err != nil {
116-
return fmt.Errorf("Unable to remove the relations %v: %v", relations, err)
117+
return fmt.Errorf("Unable to remove the relations: %v", err)
117118
}
118119
progress.Add(len(relations))
119120
return nil
@@ -128,7 +129,7 @@ func (cgt *Transaction) Commit() (*knowledge.Graph, error) {
128129
}
129130
f := p.Exec(func() error {
130131
if err := withRetryOnTooManyRequests(func() error { return cgt.client.InsertAssets(assets) }, cgt.retryBackoffFactor, cgt.retryCount, cgt.retryDelay); err != nil {
131-
return fmt.Errorf("Unable to upsert the asset %v: %v", assets, err)
132+
return fmt.Errorf("Unable to upsert the assets: %v", err)
132133
}
133134
progress.Add(len(assets))
134135
return nil
@@ -153,7 +154,7 @@ func (cgt *Transaction) Commit() (*knowledge.Graph, error) {
153154
}
154155
f := p.Exec(func() error {
155156
if err := withRetryOnTooManyRequests(func() error { return cgt.client.DeleteAssets(assets) }, cgt.retryBackoffFactor, cgt.retryCount, cgt.retryDelay); err != nil {
156-
return fmt.Errorf("Unable to remove the asset %v: %v", assets, err)
157+
return fmt.Errorf("Unable to remove the assets: %v", err)
157158
}
158159
progress.Add(len(assets))
159160
return nil
@@ -168,7 +169,7 @@ func (cgt *Transaction) Commit() (*knowledge.Graph, error) {
168169
}
169170
f := p.Exec(func() error {
170171
if err := withRetryOnTooManyRequests(func() error { return cgt.client.InsertRelations(relations) }, cgt.retryBackoffFactor, cgt.retryCount, cgt.retryDelay); err != nil {
171-
return fmt.Errorf("Unable to upsert the relation %v: %v", relations, err)
172+
return fmt.Errorf("Unable to upsert the relations: %v", err)
172173
}
173174
progress.Add(len(relations))
174175
return nil

0 commit comments

Comments
 (0)