This repository was archived by the owner on Jul 31, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
opencensus/trace/internal Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -27,8 +27,9 @@ class SpanTestPeer {
2727 static void End (absl::Duration latency, Span* span) {
2828 // Set latency.
2929 span->span_impl_for_test ()->EndWithLatencyForTesting (latency);
30- // Then call Span::End to get into stores.
31- span->End ();
30+ // Call Span::ExportSpanForTesting to get span into stores.
31+ span->span_impl_for_test ()->ExportSpanForTesting (
32+ span->span_impl_for_test ());
3233 }
3334};
3435
Original file line number Diff line number Diff line change 2323#include " opencensus/trace/attribute_value_ref.h"
2424#include " opencensus/trace/exporter/attribute_value.h"
2525#include " opencensus/trace/exporter/message_event.h"
26+ #include " opencensus/trace/internal/local_span_store_impl.h"
27+ #include " opencensus/trace/internal/running_span_store_impl.h"
28+ #include " opencensus/trace/internal/span_exporter_impl.h"
2629#include " opencensus/trace/span.h"
2730
2831namespace opencensus {
@@ -134,6 +137,12 @@ void SpanImpl::SetStatus(exporter::Status&& status) {
134137 }
135138}
136139
140+ void SpanImpl::ExportSpanForTesting (const std::shared_ptr<SpanImpl>& span) {
141+ exporter::RunningSpanStoreImpl::Get ()->RemoveSpan (span);
142+ exporter::LocalSpanStoreImpl::Get ()->AddSpan (span);
143+ exporter::SpanExporterImpl::Get ()->AddSpan (span);
144+ }
145+
137146void SpanImpl::End () { EndWithTime (absl::Now ()); }
138147
139148bool SpanImpl::HasEnded () const {
@@ -142,7 +151,9 @@ bool SpanImpl::HasEnded() const {
142151}
143152
144153void SpanImpl::EndWithLatencyForTesting (absl::Duration latency) {
145- EndWithTime (start_time_ + latency);
154+ absl::MutexLock l (&mu_);
155+ has_ended_ = true ;
156+ end_time_ = start_time_ + latency;
146157}
147158
148159void SpanImpl::EndWithTime (absl::Time end_time) {
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ class SpanImpl final {
106106 friend class ::opencensus::trace::exporter::SpanExporterImpl;
107107 friend class ::opencensus::trace::SpanTestPeer;
108108
109+ void ExportSpanForTesting (const std::shared_ptr<SpanImpl>& span);
109110 void EndWithLatencyForTesting (absl::Duration latency) LOCKS_EXCLUDED(mu_);
110111 void EndWithTime (absl::Time end_time) LOCKS_EXCLUDED(mu_);
111112
You can’t perform that action at this time.
0 commit comments