From f7ac85bec2806d351529714bd7744a91a9fdefdd Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Thu, 3 Aug 2023 16:18:34 -0400 Subject: [PATCH] feat(storage): add trace span to Writer (#8375) 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 --- storage/storage.go | 1 + storage/writer.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/storage/storage.go b/storage/storage.go index ba485ddcdacb..320439da5432 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -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, diff --git a/storage/writer.go b/storage/writer.go index f06c31162670..aeb7ed418c8d 100644 --- a/storage/writer.go +++ b/storage/writer.go @@ -22,6 +22,8 @@ import ( "sync" "time" "unicode/utf8" + + "cloud.google.com/go/internal/trace" ) // A Writer writes a Cloud Storage object. @@ -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 }