Skip to content

Commit

Permalink
feat(storage): add trace span to Writer
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 RPCs that the Writer
makes.

Fixes googleapis#6144
  • Loading branch information
tritone committed Aug 2, 2023
1 parent bfbf18c commit 25a887a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions storage/storage.go
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
2 changes: 2 additions & 0 deletions storage/writer.go
Expand Up @@ -15,6 +15,7 @@
package storage

import (
"cloud.google.com/go/internal/trace"
"context"
"errors"
"fmt"
Expand Down Expand Up @@ -163,6 +164,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 25a887a

Please sign in to comment.