|
26 | 26 | namespace opencensus { |
27 | 27 | namespace stats { |
28 | 28 |
|
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 | +// |
31 | 36 | // ViewDescriptor is a value type, and is thread-compatible. |
32 | | -// TODO: DOCS: Document members. |
33 | 37 | class ViewDescriptor final { |
34 | 38 | public: |
35 | 39 | ////////////////////////////////////////////////////////////////////////////// |
36 | 40 | // View definition |
37 | 41 |
|
| 42 | + // Creates a ViewDescriptor with Cumulative aggregation. |
38 | 43 | ViewDescriptor(); |
39 | 44 |
|
| 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"). |
40 | 49 | ViewDescriptor& set_name(absl::string_view name); |
41 | 50 | const std::string& name() const { return name_; } |
42 | 51 |
|
43 | 52 | // Sets the measure. If no measure is registered under 'name' any View created |
44 | 53 | // with the descriptor will be invalid. |
45 | 54 | 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. |
47 | 58 | const MeasureDescriptor& measure_descriptor() const; |
48 | 59 |
|
| 60 | + // Sets and retrieves the ViewDescriptor's aggregation. See aggregation.h for |
| 61 | + // details of the options. |
49 | 62 | ViewDescriptor& set_aggregation(const Aggregation& aggregation); |
50 | 63 | const Aggregation& aggregation() const { return aggregation_; } |
51 | 64 |
|
| 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. |
52 | 69 | const AggregationWindow& aggregation_window() const { |
53 | 70 | return aggregation_window_; |
54 | 71 | } |
55 | 72 |
|
| 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. |
56 | 77 | ViewDescriptor& add_column(absl::string_view tag_key); |
57 | 78 | size_t num_columns() const { return columns_.size(); } |
58 | 79 | const std::vector<std::string>& columns() const { return columns_; } |
59 | 80 |
|
| 81 | + // Sets a human-readable description for the view. |
60 | 82 | ViewDescriptor& set_description(absl::string_view description); |
61 | 83 | const std::string& description() const { return description_; } |
62 | 84 |
|
|
0 commit comments