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

Commit 76e7fc0

Browse files
zyfjeffg-easy
authored andcommitted
Fix build warning for unused variable and mismatched tags. (#13)
* Fix build warnning for unused variable and mismatched tags * Fix build warning and format code style
1 parent f0a2bc6 commit 76e7fc0

8 files changed

Lines changed: 29 additions & 26 deletions

File tree

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ bin
2020

2121
# Other
2222
TAGS
23+
24+
# Bazel
25+
bazel-bin
26+
bazel-genfiles
27+
bazel-opencensus-cpp
28+
bazel-out
29+
bazel-testlogs

opencensus/stats/examples/exporter_example.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
#include "gtest/gtest.h"
2222
#include "opencensus/stats/stats.h"
2323

24-
namespace opencensus {
25-
namespace stats {
26-
27-
struct StatsExporterTest {
28-
static constexpr auto& ExportForTesting = StatsExporter::ExportForTesting;
29-
};
30-
31-
} // namespace stats
32-
} // namespace opencensus
33-
3424
namespace opencensus_examples {
3525
namespace {
3626

opencensus/trace/internal/local_span_store_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
namespace opencensus {
2323
namespace trace {
2424

25-
struct SpanTestPeer {
25+
class SpanTestPeer {
26+
public:
2627
static void End(absl::Duration latency, Span* span) {
2728
// Set latency.
2829
span->span_impl_for_test()->EndWithLatencyForTesting(latency);
@@ -32,7 +33,8 @@ struct SpanTestPeer {
3233
};
3334

3435
namespace exporter {
35-
struct LocalSpanStoreImplTestPeer {
36+
class LocalSpanStoreImplTestPeer {
37+
public:
3638
static void ClearForTesting() {
3739
LocalSpanStoreImpl::Get()->ClearForTesting();
3840
}

opencensus/trace/internal/running_span_store_test.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
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"
@@ -37,14 +38,16 @@
3738
namespace opencensus {
3839
namespace 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

4648
namespace exporter {
47-
struct RunningSpanStoreImplTestPeer {
49+
class RunningSpanStoreImplTestPeer {
50+
public:
4851
static void ClearForTesting() {
4952
RunningSpanStoreImpl::Get()->ClearForTesting();
5053
}
@@ -53,23 +56,20 @@ struct RunningSpanStoreImplTestPeer {
5356
namespace {
5457
constexpr 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

6061
TEST(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

opencensus/trace/internal/span.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ TraceId GenerateRandomTraceId() {
6161

6262
} // namespace
6363

64-
struct SpanGenerator {
64+
class SpanGenerator {
65+
public:
6566
static Span Generate(absl::string_view name, const SpanContext* parent_ctx,
6667
bool has_remote_parent,
6768
const StartSpanOptions& options) {

opencensus/trace/internal/span_options_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace opencensus {
3232
namespace trace {
3333

3434
// Helper class to peer into SpanImpl implementation details.
35-
struct SpanTestPeer {
35+
class SpanTestPeer {
36+
public:
3637
static exporter::Status GetStatus(Span* span) {
3738
// This is a hack so that we don't have to add a status() accessor to the
3839
// public API.

opencensus/trace/internal/span_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
namespace opencensus {
2929
namespace trace {
3030

31-
struct SpanTestPeer {
31+
class SpanTestPeer {
32+
public:
3233
static SpanId GetParentSpanId(Span* span) {
3334
return span->span_impl_for_test()->parent_span_id();
3435
}

opencensus/trace/internal/trace_options_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
namespace opencensus {
2020
namespace trace {
2121

22-
struct SpanTestPeer {
22+
class SpanTestPeer {
23+
public:
2324
static void SetSampled(TraceOptions* opts, bool is_sampled) {
2425
opts->SetSampled(is_sampled);
2526
}

0 commit comments

Comments
 (0)