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

Commit 95573e6

Browse files
author
Ian Sturdy
authored
Update header documentation in opencensus/stats. (#74)
* Update header documentation in opencensus/stats. * Update view.h Nit. * Clarify wording.
1 parent bd74a0d commit 95573e6

File tree

6 files changed

+42
-9
lines changed

6 files changed

+42
-9
lines changed

opencensus/stats/aggregation.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ namespace stats {
2929
class Aggregation final {
3030
public:
3131
// Count aggregation counts the number of records, ignoring their individual
32-
// values.
32+
// values. Note that 'count' measures (e.g. the count of RPCs received) should
33+
// use Sum() aggregation to correctly handle non-unit recorded values.
3334
static Aggregation Count() {
3435
return Aggregation(Type::kCount, BucketBoundaries::Explicit({}));
3536
}
@@ -39,8 +40,9 @@ class Aggregation final {
3940
return Aggregation(Type::kSum, BucketBoundaries::Explicit({}));
4041
}
4142

42-
// Distribution aggregation records the number of records in each bucket
43-
// defined by 'buckets', and calculates distribution stats from that.
43+
// Distribution aggregation calculates distribution statistics (count, mean,
44+
// range, and sum of squared deviation) and tracks a histogram of recorded
45+
// values according to 'buckets'.
4446
static Aggregation Distribution(BucketBoundaries buckets) {
4547
return Aggregation(Type::kDistribution, std::move(buckets));
4648
}

opencensus/stats/measure_descriptor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class MeasureDescriptor final {
3333
kInt64,
3434
};
3535

36+
// See documentation on MeasureRegistry::Register*() for details of these
37+
// fields.
3638
const std::string& name() const { return name_; }
3739
const std::string& units() const { return units_; }
3840
const std::string& description() const { return description_; }

opencensus/stats/measure_registry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MeasureRegistry final {
3737
// registered with GetMeasure*ByName before registering it.
3838
//
3939
// 'name' should be a globally unique identifier. It is recommended that this
40-
// be in the format "<domain>/<path>", e.g. "example.com/Foo/FooUsage".
40+
// be in the format "<domain>/<path>", e.g. "example.com/client/foo_usage".
4141
// 'units' are the units of recorded values. The recommended grammar is:
4242
// - Expression = Component { "." Component } {"/" Component }
4343
// - Component = [ PREFIX ] UNIT [ Annotation ] | Annotation | "1"

opencensus/stats/stats_exporter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ class StatsExporter final {
4949
const std::vector<std::pair<ViewDescriptor, ViewData>>& data) = 0;
5050
};
5151

52-
// This should only be called by push exporters' Register() methods.
52+
// Registers a new handler. Every few seconds, each registered handler will be
53+
// called with the present data for each registered view. This should only be
54+
// called by push exporters' Register() methods.
5355
static void RegisterPushHandler(std::unique_ptr<Handler> handler);
5456

5557
// Retrieves current data for all registered views, for implementing pull

opencensus/stats/view.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
namespace opencensus {
2323
namespace stats {
2424

25+
// View is an RAII handle for on-task data collection--once a View is
26+
// instantiated, OpenCensus will collect data for it, which can be accessed with
27+
// View::GetData(). To register a view for export, rather than on-task
28+
// collection, use ViewDescriptor::RegisterForExport() instead.
29+
//
2530
// View objects are thread-safe.
2631
class View {
2732
public:

opencensus/stats/view_descriptor.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,59 @@
2626
namespace opencensus {
2727
namespace stats {
2828

29-
// ViewDescriptor provides metadata for a view, including its identity and the
30-
// data to be collected.
29+
// ViewDescriptor provides metadata for a view: a unique name, the measure to
30+
// collect data for, how to aggregate that data, and what tag keys to break it
31+
// down by.
32+
// In order to collect data for a ViewDescriptor, it must either be registered
33+
// for export (by calling RegisterForExport() on the fully-defined descriptor)
34+
// or converted into a View to collect data on-task (see view.h).
35+
//
3136
// ViewDescriptor is a value type, and is thread-compatible.
32-
// TODO: DOCS: Document members.
3337
class ViewDescriptor final {
3438
public:
3539
//////////////////////////////////////////////////////////////////////////////
3640
// View definition
3741

42+
// Creates a ViewDescriptor with Cumulative aggregation.
3843
ViewDescriptor();
3944

45+
// Sets the name of the ViewDescriptor. Names must be unique within the
46+
// library; it is recommended that it be in the format "<domain>/<path>",
47+
// where "<path>" uniquely specifies the measure, aggregation, and columns
48+
// (e.g. "example.com/Foo/FooUsage-sum-key1-key2").
4049
ViewDescriptor& set_name(absl::string_view name);
4150
const std::string& name() const { return name_; }
4251

4352
// Sets the measure. If no measure is registered under 'name' any View created
4453
// with the descriptor will be invalid.
4554
ViewDescriptor& set_measure(absl::string_view name);
46-
55+
// Accesses the descriptor of the view's measure. If no measure has been
56+
// registered under the name set using set_measure(), this returns an invalid
57+
// descriptor with blank fields.
4758
const MeasureDescriptor& measure_descriptor() const;
4859

60+
// Sets and retrieves the ViewDescriptor's aggregation. See aggregation.h for
61+
// details of the options.
4962
ViewDescriptor& set_aggregation(const Aggregation& aggregation);
5063
const Aggregation& aggregation() const { return aggregation_; }
5164

65+
// Retrieves the AggregationWindow--see internal/aggregation_window.h for
66+
// details. For exported views this should be left at the default Cumulative;
67+
// for on-task data needing other windows, internal/set_aggregation_window.h
68+
// provides an interface for setting this field.
5269
const AggregationWindow& aggregation_window() const {
5370
return aggregation_window_;
5471
}
5572

73+
// Adds a dimension to the view's data. When data is recorded it can specify a
74+
// number of tags, key-value pairs; the aggregated data for each view will be
75+
// broken down by the distinct values of each tag key matching one of the
76+
// view's columns.
5677
ViewDescriptor& add_column(absl::string_view tag_key);
5778
size_t num_columns() const { return columns_.size(); }
5879
const std::vector<std::string>& columns() const { return columns_; }
5980

81+
// Sets a human-readable description for the view.
6082
ViewDescriptor& set_description(absl::string_view description);
6183
const std::string& description() const { return description_; }
6284

0 commit comments

Comments
 (0)