Skip to content

Commit

Permalink
Add TraceSpans to tensorstore
Browse files Browse the repository at this point in the history
TraceSpan adds scoped traces to tensorstore, however there
is no current integration with any other telemetry libraries.

LoggingTraceSpan incorporates TraceSpan along with scoped logging.

Also inspects Executor uses and updates some TraceContext propagation.

PiperOrigin-RevId: 700720206
Change-Id: I324c544b6588516e2c0de9a701d5e49cda726065
  • Loading branch information
laramiel authored and copybara-github committed Nov 27, 2024
1 parent 758b6e1 commit 63df973
Show file tree
Hide file tree
Showing 24 changed files with 704 additions and 191 deletions.
1 change: 1 addition & 0 deletions tensorstore/driver/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ tensorstore_cc_library(
"//tensorstore/internal/json_binding",
"//tensorstore/internal/json_binding:bindable",
"//tensorstore/internal/json_binding:data_type",
"//tensorstore/internal/tracing",
"//tensorstore/kvstore",
"//tensorstore/serialization",
"//tensorstore/serialization:registry",
Expand Down
2 changes: 2 additions & 0 deletions tensorstore/driver/copy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "tensorstore/internal/nditerable_data_type_conversion.h"
#include "tensorstore/internal/nditerable_util.h"
#include "tensorstore/internal/tagged_ptr.h"
#include "tensorstore/internal/tracing/trace_span.h"
#include "tensorstore/open_mode.h"
#include "tensorstore/progress.h"
#include "tensorstore/read_write_options.h"
Expand Down Expand Up @@ -140,6 +141,7 @@ struct CopyState : public internal::AtomicReferenceCount<CopyState> {
Promise<void> copy_promise;
Promise<void> commit_promise;
IntrusivePtr<CommitState> commit_state{new CommitState};
internal_tracing::TraceSpan tspan{"tensorstore.Copy"};

void SetError(absl::Status error) {
SetDeferredResult(copy_promise, std::move(error));
Expand Down
3 changes: 3 additions & 0 deletions tensorstore/driver/read.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "tensorstore/internal/nditerable_transformed_array.h"
#include "tensorstore/internal/nditerable_util.h"
#include "tensorstore/internal/tagged_ptr.h"
#include "tensorstore/internal/tracing/trace_span.h"
#include "tensorstore/internal/type_traits.h"
#include "tensorstore/open_mode.h"
#include "tensorstore/progress.h"
Expand All @@ -50,6 +51,7 @@
#include "tensorstore/resize_options.h"
#include "tensorstore/transaction.h"
#include "tensorstore/util/element_pointer.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/execution/sender.h"
#include "tensorstore/util/executor.h"
#include "tensorstore/util/extents.h"
Expand Down Expand Up @@ -108,6 +110,7 @@ struct ReadState
Promise<PromiseValue> promise;
std::atomic<Index> copied_elements{0};
Index total_elements;
internal_tracing::TraceSpan tspan{"tensorstore.Read"};

void SetError(absl::Status error) {
SetDeferredResult(promise, std::move(error));
Expand Down
3 changes: 3 additions & 0 deletions tensorstore/driver/write.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
#include "tensorstore/internal/nditerable_transformed_array.h"
#include "tensorstore/internal/nditerable_util.h"
#include "tensorstore/internal/tagged_ptr.h"
#include "tensorstore/internal/tracing/trace_span.h"
#include "tensorstore/internal/type_traits.h"
#include "tensorstore/open_mode.h"
#include "tensorstore/progress.h"
#include "tensorstore/read_write_options.h"
#include "tensorstore/resize_options.h"
#include "tensorstore/transaction.h"
#include "tensorstore/util/element_pointer.h"
#include "tensorstore/util/execution/any_receiver.h"
#include "tensorstore/util/execution/sender.h"
#include "tensorstore/util/executor.h"
#include "tensorstore/util/future.h"
Expand Down Expand Up @@ -125,6 +127,7 @@ struct WriteState : public internal::AtomicReferenceCount<WriteState> {
Promise<void> copy_promise;
Promise<void> commit_promise;
IntrusivePtr<CommitState> commit_state{new CommitState};
internal_tracing::TraceSpan tspan{"tensorstore.Write"};

void SetError(absl::Status error) {
SetDeferredResult(copy_promise, std::move(error));
Expand Down
1 change: 1 addition & 0 deletions tensorstore/internal/os/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ tensorstore_cc_library(
"//tensorstore/internal/log:verbose_flag",
"//tensorstore/internal/metrics",
"//tensorstore/internal/metrics:metadata",
"//tensorstore/internal/tracing",
"//tensorstore/util:quote_string",
"//tensorstore/util:result",
"//tensorstore/util:status",
Expand Down
Loading

0 comments on commit 63df973

Please sign in to comment.