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

Commit db9e2bb

Browse files
authored
Change MBy to By units. (#109)
This reflects the default gRPC views which use bytes as units.
1 parent e5363c9 commit db9e2bb

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

examples/helloworld/helloworld.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ABSL_CONST_INIT const absl::string_view kVideoSizeMeasureName =
4141
opencensus::stats::MeasureInt VideoSizeMeasure() {
4242
static const opencensus::stats::MeasureInt video_size =
4343
opencensus::stats::MeasureRegistry::RegisterInt(
44-
kVideoSizeMeasureName, "MBy", "size of processed videos");
44+
kVideoSizeMeasureName, "By", "size of processed videos");
4545
return video_size;
4646
}
4747

@@ -62,6 +62,8 @@ int main(int argc, char **argv) {
6262
// Call measure so that it is initialized.
6363
VideoSizeMeasure();
6464

65+
constexpr int64_t kMiB = 1 << 20;
66+
6567
// Create view to see the processed video size distribution broken down by
6668
// frontend. The view has bucket boundaries (0, 256, 65536) that will group
6769
// measure values into histogram buckets.
@@ -71,7 +73,8 @@ int main(int argc, char **argv) {
7173
.set_description("processed video size over time")
7274
.set_measure(kVideoSizeMeasureName)
7375
.set_aggregation(opencensus::stats::Aggregation::Distribution(
74-
opencensus::stats::BucketBoundaries::Exponential(8, 1 << 8, 2)))
76+
opencensus::stats::BucketBoundaries::Explicit(
77+
{0, 16 * kMiB, 256 * kMiB})))
7578
.add_column(kFrontendKey);
7679
opencensus::stats::View view(video_size_view);
7780
video_size_view.RegisterForExport();
@@ -87,7 +90,7 @@ int main(int argc, char **argv) {
8790
// Sleep for [1,10] milliseconds to fake work.
8891
absl::SleepFor(absl::Milliseconds(rand() % 10 + 1));
8992
// Record the processed video size.
90-
opencensus::stats::Record({{VideoSizeMeasure(), 25648}},
93+
opencensus::stats::Record({{VideoSizeMeasure(), 25 * kMiB}},
9194
{{kFrontendKey, "video size"}});
9295
span.AddAnnotation("Finished processing video.");
9396
span.End();

0 commit comments

Comments
 (0)