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

Commit 79c699a

Browse files
g-easyVizerai
authored andcommitted
Remove record_events from public API for now. (#78)
This is in preparation for changing how SpanStores work.
1 parent 0eef1b9 commit 79c699a

File tree

5 files changed

+21
-48
lines changed

5 files changed

+21
-48
lines changed

opencensus/trace/examples/span_example.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,6 @@ TEST(SpanExample, AlwaysSample) {
5151
span.End();
5252
}
5353

54-
TEST(SpanExample, RecordEvents) {
55-
auto span = ::opencensus::trace::Span::StartSpan(
56-
"MyRootSpan", /*parent=*/nullptr,
57-
{/*sampler=*/nullptr, /*record_events=*/true});
58-
span.End();
59-
}
60-
6154
void PretendCallback(::opencensus::trace::Span&& s) {
6255
s.AddAnnotation("Performing work.");
6356
s.End();

opencensus/trace/internal/local_span_store_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ namespace {
3434

3535
TEST(LocalSpanStoreTest, GetSummary) {
3636
exporter::LocalSpanStoreImplTestPeer::ClearForTesting();
37-
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr,
38-
{nullptr, /*record_events=*/true});
37+
static AlwaysSampler sampler;
38+
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr, {&sampler});
3939
span.AddAnnotation("Annotation");
4040
span.End();
4141

opencensus/trace/internal/span.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class SpanGenerator {
9393
}
9494
SpanContext context(trace_id, span_id, trace_options);
9595
SpanImpl* impl = nullptr;
96-
if (trace_options.IsSampled() || options.record_events) {
97-
// Only Spans that are recording are backed by a SpanImpl.
96+
if (trace_options.IsSampled()) {
97+
// Only Spans that are sampled are backed by a SpanImpl.
9898
impl =
9999
new SpanImpl(context, TraceConfigImpl::Get()->current_trace_params(),
100100
name, parent_span_id, has_remote_parent);

opencensus/trace/internal/span_test.cc

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,14 @@ class SpanTestPeer {
4646

4747
namespace {
4848

49-
constexpr bool kRecordEvents = true;
50-
5149
TEST(SpanTest, SampledSpan) {
5250
AlwaysSampler sampler;
5351
auto span = Span::StartSpan("MySpan", /*parent=*/nullptr, {&sampler});
5452
EXPECT_TRUE(span.IsSampled());
5553
EXPECT_TRUE(span.IsRecording()) << "Sampled spans must be recording.";
5654
}
5755

58-
TEST(SpanTest, RecordingButNotSampledSpan) {
59-
NeverSampler sampler;
60-
auto span =
61-
Span::StartSpan("MySpan", /*parent=*/nullptr, {&sampler, kRecordEvents});
62-
EXPECT_FALSE(span.IsSampled());
63-
EXPECT_TRUE(span.IsRecording());
64-
}
65-
66-
TEST(SpanTest, NotRecordingAndNotSampledSpan) {
56+
TEST(SpanTest, NotSampledSpan) {
6757
NeverSampler sampler;
6858
auto span = Span::StartSpan("MySpan", /*parent=*/nullptr, {&sampler});
6959
EXPECT_FALSE(span.IsSampled());
@@ -84,8 +74,8 @@ TEST(SpanTest, ChildInheritsSamplingFromParent) {
8474
}
8575

8676
TEST(SpanTest, AddAttributesLastValueWins) {
87-
auto span =
88-
Span::StartSpan("SpanName", /*parent=*/nullptr, {nullptr, kRecordEvents});
77+
AlwaysSampler sampler;
78+
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr, {&sampler});
8979
span.AddAttributes({{"key", "value1"},
9080
{"key", 123},
9181
{"another_key", "another_value"},
@@ -100,8 +90,8 @@ TEST(SpanTest, AddAttributesLastValueWins) {
10090
}
10191

10292
TEST(SpanTest, AddAttributesWithArrayAndVector) {
103-
auto span =
104-
Span::StartSpan("SpanName", /*parent=*/nullptr, {nullptr, kRecordEvents});
93+
AlwaysSampler sampler;
94+
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr, {&sampler});
10595
std::array<std::pair<absl::string_view, AttributeValueRef>, 3>
10696
attributes_array = {
10797
{{"str_key", "value1"}, {"int_key", 123}, {"bool_key", true}}};
@@ -119,8 +109,8 @@ TEST(SpanTest, AddAttributesWithArrayAndVector) {
119109
}
120110

121111
TEST(SpanTest, AddAnnotationLastAttributeWins) {
122-
auto span =
123-
Span::StartSpan("SpanName", /*parent=*/nullptr, {nullptr, kRecordEvents});
112+
AlwaysSampler sampler;
113+
auto span = Span::StartSpan("SpanName", /*parent=*/nullptr, {&sampler});
124114
span.AddAnnotation("Annotation text.", {{"key", "value1"},
125115
{"key", 123},
126116
{"another_key", "another_value"},
@@ -144,13 +134,12 @@ TEST(SpanTest, AddAnnotationLastAttributeWins) {
144134
}
145135

146136
TEST(SpanTest, ParentLinksFromOptions) {
147-
auto parent0 =
148-
Span::StartSpan("Parent0", /*parent=*/nullptr, {nullptr, kRecordEvents});
149-
auto parent1 =
150-
Span::StartSpan("Parent1", /*parent=*/nullptr, {nullptr, kRecordEvents});
151-
auto span = Span::StartSpan("MyRootSpan",
152-
/*parent=*/nullptr,
153-
{nullptr, kRecordEvents, {&parent0, &parent1}});
137+
AlwaysSampler sampler;
138+
auto parent0 = Span::StartSpan("Parent0", /*parent=*/nullptr, {&sampler});
139+
auto parent1 = Span::StartSpan("Parent1", /*parent=*/nullptr, {&sampler});
140+
auto span =
141+
Span::StartSpan("MyRootSpan",
142+
/*parent=*/nullptr, {&sampler, {&parent0, &parent1}});
154143
// Check that StartSpan added parent links to span.
155144
{
156145
auto data = SpanTestPeer::ToSpanData(&span);
@@ -185,7 +174,7 @@ TEST(SpanTest, FullSpanTest) {
185174
auto parent = Span::StartSpan("parent");
186175
auto related_span =
187176
Span::StartSpan("RelatedSpan", /*parent=*/nullptr, {&sampler});
188-
StartSpanOptions opts = {&sampler, kRecordEvents, {&related_span}};
177+
StartSpanOptions opts = {&sampler, {&related_span}};
189178
auto span = ::opencensus::trace::Span::StartSpan("MyRootSpan", &parent, opts);
190179
auto child = Span::StartSpan("child", &span);
191180

opencensus/trace/span.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,9 @@ using AttributesRef =
5050

5151
// Options for Starting a Span.
5252
struct StartSpanOptions {
53-
StartSpanOptions(
54-
Sampler* sampler = nullptr, // Default Sampler.
55-
bool record_events = false, // Only record events if the Span is sampled.
56-
const std::vector<Span*>& parent_links = {})
57-
: sampler(sampler),
58-
record_events(record_events),
59-
parent_links(parent_links) {}
53+
StartSpanOptions(Sampler* sampler = nullptr, // Default Sampler.
54+
const std::vector<Span*>& parent_links = {})
55+
: sampler(sampler), parent_links(parent_links) {}
6056

6157
// The Sampler to use. It must remain valid for the duration of the
6258
// StartSpan() call. If nullptr, use the default Sampler from TraceConfig.
@@ -65,11 +61,6 @@ struct StartSpanOptions {
6561
// All sampled Spans record events.
6662
const Sampler* sampler;
6763

68-
// This option can be used to request recording of events for non-sampled
69-
// Spans. Spans that record events show up in the RunningSpanStore and
70-
// LocalSpanStore in the running process.
71-
const bool record_events;
72-
7364
// Pointers to Spans in *other Traces* that are parents of this Span. They
7465
// must remain valid for the duration of the StartSpan() call.
7566
const std::vector<Span*> parent_links;

0 commit comments

Comments
 (0)