Skip to content

Commit

Permalink
feat(storage): add trace span to Writer (#8375)
Browse files Browse the repository at this point in the history
Adds a trace span that covers a Writer from open to close. Nested spans already cover individual requests / RPCs that the Writer makes.

Fixes #6144
  • Loading branch information
tritone authored Aug 3, 2023
1 parent 4b68747 commit f7ac85b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,7 @@ func (o *ObjectHandle) ReadCompressed(compressed bool) *ObjectHandle {
// It is the caller's responsibility to call Close when writing is done. To
// stop writing without saving the data, cancel the context.
func (o *ObjectHandle) NewWriter(ctx context.Context) *Writer {
ctx = trace.StartSpan(ctx, "cloud.google.com/go/storage.Object.Writer")
return &Writer{
ctx: ctx,
o: o,
Expand Down
3 changes: 3 additions & 0 deletions storage/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"sync"
"time"
"unicode/utf8"

"cloud.google.com/go/internal/trace"
)

// A Writer writes a Cloud Storage object.
Expand Down Expand Up @@ -163,6 +165,7 @@ func (w *Writer) Close() error {
<-w.donec
w.mu.Lock()
defer w.mu.Unlock()
trace.EndSpan(w.ctx, w.err)
return w.err
}

Expand Down

0 comments on commit f7ac85b

Please sign in to comment.