1919#include < unordered_map>
2020#include < vector>
2121
22+ #include " absl/base/attributes.h"
2223#include " absl/memory/memory.h"
2324#include " gtest/gtest.h"
2425#include " opencensus/trace/exporter/attribute_value.h"
3738namespace opencensus {
3839namespace trace {
3940
40- struct SpanTestPeer {
41+ class SpanTestPeer {
42+ public:
4143 static void SetSampled (TraceOptions* opts, bool is_sampled) {
4244 opts->SetSampled (is_sampled);
4345 }
4446};
4547
4648namespace exporter {
47- struct RunningSpanStoreImplTestPeer {
49+ class RunningSpanStoreImplTestPeer {
50+ public:
4851 static void ClearForTesting () {
4952 RunningSpanStoreImpl::Get ()->ClearForTesting ();
5053 }
@@ -53,23 +56,20 @@ struct RunningSpanStoreImplTestPeer {
5356namespace {
5457constexpr uint8_t trace_id[] = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ,
5558 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 };
56- constexpr uint8_t span_id1[] = {1 , 0 , 0 , 0 , 0 , 0 , 0 , 11 };
57- constexpr uint8_t span_id2[] = {2 , 0 , 0 , 0 , 0 , 0 , 0 , 22 };
58- constexpr uint8_t span_id3[] = {3 , 0 , 0 , 0 , 0 , 0 , 0 , 33 };
59+ constexpr uint8_t span_id[] = {2 , 0 , 0 , 0 , 0 , 0 , 0 , 22 };
5960
6061TEST (RunningSpanStoreTest, ForceSamplingViaStartSpanOptions) {
6162 // Parent isn't sampled, child is.
6263 // Child Span with forced sampling.
63- SpanContext parent_ctx2 {TraceId (trace_id), SpanId (span_id2 )};
64+ SpanContext parent_ctx {TraceId (trace_id), SpanId (span_id )};
6465 AlwaysSampler sampler;
6566 RunningSpanStoreImplTestPeer::ClearForTesting ();
66- auto span2 =
67- Span::StartSpanWithRemoteParent (" Span2" , parent_ctx2, {&sampler});
68- EXPECT_TRUE (span2.IsSampled ());
67+ auto span = Span::StartSpanWithRemoteParent (" Span" , parent_ctx, {&sampler});
68+ EXPECT_TRUE (span.IsSampled ());
6969 EXPECT_EQ (1 , RunningSpanStore::GetRunningSpans ({" " , 1 }).size ());
7070 EXPECT_EQ (0 , RunningSpanStore::GetRunningSpans ({" " , 0 }).size ())
7171 << " Hit max_spans_to_return." ;
72- span2 .End ();
72+ span .End ();
7373 EXPECT_EQ (0 , RunningSpanStore::GetRunningSpans ({" " , 1 }).size ());
7474}
7575
0 commit comments