Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 0eef1b9

Browse files
g-easyVizerai
authored andcommitted
Simplify local_span_store_test and SpanImpl. (#77)
1 parent 36261e2 commit 0eef1b9

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

opencensus/trace/internal/local_span_store_test.cc

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@
2222
namespace opencensus {
2323
namespace trace {
2424

25-
class SpanTestPeer {
26-
public:
27-
static void End(absl::Duration latency, Span* span) {
28-
// Set latency.
29-
span->span_impl_for_test()->EndWithLatencyForTesting(latency);
30-
// Call Span::ExportSpanForTesting to get span into stores.
31-
span->span_impl_for_test()->ExportSpanForTesting(
32-
span->span_impl_for_test());
33-
}
34-
};
35-
3625
namespace exporter {
3726
class LocalSpanStoreImplTestPeer {
3827
public:
@@ -48,16 +37,14 @@ TEST(LocalSpanStoreTest, GetSummary) {
4837
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr,
4938
{nullptr, /*record_events=*/true});
5039
span.AddAnnotation("Annotation");
51-
SpanTestPeer::End(absl::Microseconds(15), &span);
40+
span.End();
5241

5342
auto summary = LocalSpanStore::GetSummary();
5443
EXPECT_EQ(1, summary.per_span_name_summary.size());
5544
EXPECT_EQ(1, summary.per_span_name_summary["SpanName"]
5645
.number_of_latency_sampled_spans.size());
57-
EXPECT_EQ(
58-
1,
59-
summary.per_span_name_summary["SpanName"].number_of_latency_sampled_spans
60-
[LocalSpanStore::LatencyBucketBoundary::k10us_to_100us]);
46+
// TODO: EXPECT it ended up in the right bucket in
47+
// number_of_latency_sampled_spans[].
6148
}
6249

6350
} // namespace

opencensus/trace/internal/span_impl.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,13 @@ void SpanImpl::SetStatus(exporter::Status&& status) {
137137
}
138138
}
139139

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-
146140
void SpanImpl::End() { EndWithTime(absl::Now()); }
147141

148142
bool SpanImpl::HasEnded() const {
149143
absl::MutexLock l(&mu_);
150144
return has_ended_;
151145
}
152146

153-
void SpanImpl::EndWithLatencyForTesting(absl::Duration latency) {
154-
absl::MutexLock l(&mu_);
155-
has_ended_ = true;
156-
end_time_ = start_time_ + latency;
157-
}
158-
159147
void SpanImpl::EndWithTime(absl::Time end_time) {
160148
absl::MutexLock l(&mu_);
161149
if (!has_ended_) {

opencensus/trace/internal/span_impl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ 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);
110-
void EndWithLatencyForTesting(absl::Duration latency) LOCKS_EXCLUDED(mu_);
111109
void EndWithTime(absl::Time end_time) LOCKS_EXCLUDED(mu_);
112110

113111
// Makes a deep copy of span contents and returns copied data in SpanData.

0 commit comments

Comments
 (0)