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

Commit 13e9555

Browse files
author
Ian Sturdy
authored
Switch Record() to use the DeltaProducer. (#131)
1 parent e5d36d6 commit 13e9555

15 files changed

Lines changed: 56 additions & 412 deletions

opencensus/plugins/grpc/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ cc_test(
7070
":grpc_plugin",
7171
"//opencensus/plugins/grpc/internal/testing:echo_proto",
7272
"//opencensus/stats",
73+
"//opencensus/stats:test_utils",
7374
"@com_github_grpc_grpc//:grpc++",
7475
"@com_google_absl//absl/strings",
7576
"@com_google_absl//absl/time",

opencensus/plugins/grpc/internal/stats_plugin_end2end_test.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "opencensus/plugins/grpc/grpc_plugin.h"
2727
#include "opencensus/plugins/grpc/internal/testing/echo.grpc.pb.h"
2828
#include "opencensus/stats/stats.h"
29+
#include "opencensus/stats/testing/test_utils.h"
2930

3031
namespace opencensus {
3132
namespace testing {
@@ -129,6 +130,7 @@ TEST_F(StatsPluginEnd2EndTest, ErrorCount) {
129130
::grpc::Status status = stub_->Echo(&context, request, &response);
130131
}
131132
absl::SleepFor(absl::Milliseconds(500));
133+
stats::testing::TestUtils::Flush();
132134

133135
EXPECT_THAT(client_method_view.GetData().double_data(),
134136
::testing::UnorderedElementsAre(::testing::Pair(
@@ -179,6 +181,7 @@ TEST_F(StatsPluginEnd2EndTest, RequestResponseBytes) {
179181
EXPECT_EQ("foo", response.message());
180182
}
181183
absl::SleepFor(absl::Milliseconds(500));
184+
stats::testing::TestUtils::Flush();
182185

183186
EXPECT_THAT(
184187
client_request_bytes_view.GetData().distribution_data(),
@@ -232,6 +235,7 @@ TEST_F(StatsPluginEnd2EndTest, Latency) {
232235
const double max_time = absl::ToDoubleMilliseconds(absl::Now() - start_time);
233236

234237
absl::SleepFor(absl::Milliseconds(500));
238+
stats::testing::TestUtils::Flush();
235239

236240
EXPECT_THAT(
237241
client_latency_view.GetData().distribution_data(),
@@ -292,6 +296,7 @@ TEST_F(StatsPluginEnd2EndTest, StartFinishCount) {
292296
EXPECT_EQ("foo", response.message());
293297
}
294298
absl::SleepFor(absl::Milliseconds(500));
299+
stats::testing::TestUtils::Flush();
295300

296301
EXPECT_THAT(client_started_count_view.GetData().double_data(),
297302
::testing::UnorderedElementsAre(::testing::Pair(
@@ -327,6 +332,7 @@ TEST_F(StatsPluginEnd2EndTest, RequestResponseCount) {
327332
EXPECT_EQ("foo", response.message());
328333
}
329334
absl::SleepFor(absl::Milliseconds(500));
335+
stats::testing::TestUtils::Flush();
330336

331337
EXPECT_THAT(client_request_count_view.GetData().distribution_data(),
332338
::testing::UnorderedElementsAre(::testing::Pair(

opencensus/stats/BUILD

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,6 @@ cc_test(
137137
],
138138
)
139139

140-
cc_test(
141-
name = "delta_producer_stats_test",
142-
srcs = ["internal/delta_producer_stats_test.cc"],
143-
copts = TEST_COPTS,
144-
deps = [
145-
":core",
146-
"@com_google_googletest//:gtest_main",
147-
],
148-
)
149-
150140
cc_test(
151141
name = "distribution_test",
152142
srcs = ["internal/distribution_test.cc"],
@@ -212,6 +202,7 @@ cc_test(
212202
deps = [
213203
":core",
214204
":recording",
205+
":test_utils",
215206
"@com_google_absl//absl/types:optional",
216207
"@com_google_googletest//:gtest_main",
217208
],

opencensus/stats/examples/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cc_test(
3232
copts = TEST_COPTS,
3333
deps = [
3434
"//opencensus/stats",
35+
"@com_google_absl//absl/time",
3536
"@com_google_googletest//:gtest_main",
3637
],
3738
)

opencensus/stats/examples/view_and_recording_example.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
#include "absl/time/clock.h"
16+
#include "absl/time/time.h"
1517
#include "opencensus/stats/stats.h"
1618

1719
#include "gtest/gtest.h"
@@ -80,6 +82,8 @@ TEST(ViewAndRecordingExample, Sum) {
8082
// Once the view is created, usage records under example.com/Bar/FooUsage.
8183
foo.Use(1);
8284
foo.Use(4);
85+
// Sleep to allow the data to propagate to views.
86+
absl::SleepFor(absl::Seconds(6));
8387

8488
// The stats consumer can now query the recorded data.
8589
if (view.IsValid()) {

opencensus/stats/internal/delta_producer.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,5 @@ void DeltaProducer::RunHarvesterLoop() {
139139
}
140140
}
141141

142-
void ExperimentalDeltaProducerRecord(
143-
std::initializer_list<Measurement> measurements, TagSet tags) {
144-
DeltaProducer::Get()->Record(measurements, std::move(tags));
145-
}
146-
147142
} // namespace stats
148143
} // namespace opencensus

opencensus/stats/internal/delta_producer.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ class DeltaProducer final {
120120
std::thread harvester_thread_ GUARDED_BY(harvester_mu_);
121121
};
122122

123-
// TODO: Replace Record with this when ready.
124-
void ExperimentalDeltaProducerRecord(
125-
std::initializer_list<Measurement> measurements, TagSet tags = TagSet({}));
126-
127123
} // namespace stats
128124
} // namespace opencensus
129125

0 commit comments

Comments
 (0)