Skip to content

Commit 0d02f21

Browse files
Fixes #207 - Add Style guide for proto comments. (#717)
* Fixes #207 - Add Style guide for proto comments. * Update comments to match style guide. * Fixes from review. * Update opentelemetry/proto/metrics/v1/metrics.proto Co-authored-by: Tigran Najaryan <[email protected]> --------- Co-authored-by: Tigran Najaryan <[email protected]>
1 parent 81d6676 commit 0d02f21

File tree

6 files changed

+75
-33
lines changed

6 files changed

+75
-33
lines changed

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ for general information about the project.
2121
After making any changes to .proto files make sure to generate all
2222
implementation by running `make gen-all`.
2323

24+
## Style-Guide
25+
26+
OpenTelemetry follows the [protocol buffer style guide](https://protobuf.dev/programming-guides/style/) with the following clarifications:
27+
28+
- All Messages and fields should be documented via comments.
29+
- Field comments should document purpose or behavior with active verbs, or
30+
a simple definition noun phrase (similar to a dictionary entry).
31+
- valid: "Represents ..."
32+
valid: "Additional attributes that describe the scope."
33+
- not-valid: "used to represent..."
34+
- Message and field comments may reference the field or message by name.
35+
- valid: "AnyValue ..."
36+
- valid: "The value ..."
37+
2438
## Further Help
2539

2640
If you have any questions or need assistance while contributing, feel free to reach out to the [`#otel-specification`](https://cloud-native.slack.com/archives/C01N7PP1THC) Slack channel.

opentelemetry/proto/common/v1/common.proto

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ option java_package = "io.opentelemetry.proto.common.v1";
2222
option java_outer_classname = "CommonProto";
2323
option go_package = "go.opentelemetry.io/proto/otlp/common/v1";
2424

25-
// AnyValue is used to represent any type of attribute value. AnyValue may contain a
25+
// Represents any type of attribute value. AnyValue may contain a
2626
// primitive value such as a string or integer or it may contain an arbitrary nested
2727
// object containing arrays, key-value lists and primitives.
2828
message AnyValue {
@@ -59,24 +59,35 @@ message KeyValueList {
5959
repeated KeyValue values = 1;
6060
}
6161

62-
// KeyValue is a key-value pair that is used to store Span attributes, Link
62+
// Represents a key-value pair that is used to store Span attributes, Link
6363
// attributes, etc.
6464
message KeyValue {
65+
// The key name of the pair.
6566
string key = 1;
67+
68+
// The value of the pair.
6669
AnyValue value = 2;
6770
}
6871

6972
// InstrumentationScope is a message representing the instrumentation scope information
7073
// such as the fully qualified name and version.
7174
message InstrumentationScope {
75+
// A name denoting the Instrumentation scope.
7276
// An empty instrumentation scope name means the name is unknown.
7377
string name = 1;
78+
79+
// Defines the version of the instrumentation scope.
80+
// An empty instrumentation scope version means the version is unknown.
7481
string version = 2;
7582

7683
// Additional attributes that describe the scope. [Optional].
7784
// Attribute keys MUST be unique (it is not allowed to have more than one
7885
// attribute with the same key).
7986
repeated KeyValue attributes = 3;
87+
88+
// The number of attributes that were discarded. Attributes
89+
// can be discarded because their keys are too long or because there are too many
90+
// attributes. If this value is 0, then no attributes were dropped.
8091
uint32 dropped_attributes_count = 4;
8192
}
8293

opentelemetry/proto/metrics/v1/metrics.proto

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ message ScopeMetrics {
187187
message Metric {
188188
reserved 4, 6, 8;
189189

190-
// name of the metric.
190+
// The name of the metric.
191191
string name = 1;
192192

193-
// description of the metric, which can be used in documentation.
193+
// A description of the metric, which can be used in documentation.
194194
string description = 2;
195195

196-
// unit in which the metric value is reported. Follows the format
196+
// The unit in which the metric value is reported. Follows the format
197197
// described by https://unitsofmeasure.org/ucum.html.
198198
string unit = 3;
199199

@@ -228,25 +228,31 @@ message Metric {
228228
// AggregationTemporality is not included. Consequently, this also means
229229
// "StartTimeUnixNano" is ignored for all data points.
230230
message Gauge {
231+
// The time series data points.
232+
// Note: Multiple time series may be included (same timestamp, different attributes).
231233
repeated NumberDataPoint data_points = 1;
232234
}
233235

234236
// Sum represents the type of a scalar metric that is calculated as a sum of all
235237
// reported measurements over a time interval.
236238
message Sum {
239+
// The time series data points.
240+
// Note: Multiple time series may be included (same timestamp, different attributes).
237241
repeated NumberDataPoint data_points = 1;
238242

239243
// aggregation_temporality describes if the aggregator reports delta changes
240244
// since last report time, or cumulative changes since a fixed start time.
241245
AggregationTemporality aggregation_temporality = 2;
242246

243-
// If "true" means that the sum is monotonic.
247+
// Represents whether the sum is monotonic.
244248
bool is_monotonic = 3;
245249
}
246250

247251
// Histogram represents the type of a metric that is calculated by aggregating
248252
// as a Histogram of all reported measurements over a time interval.
249253
message Histogram {
254+
// The time series data points.
255+
// Note: Multiple time series may be included (same timestamp, different attributes).
250256
repeated HistogramDataPoint data_points = 1;
251257

252258
// aggregation_temporality describes if the aggregator reports delta changes
@@ -257,6 +263,8 @@ message Histogram {
257263
// ExponentialHistogram represents the type of a metric that is calculated by aggregating
258264
// as a ExponentialHistogram of all reported double measurements over a time interval.
259265
message ExponentialHistogram {
266+
// The time series data points.
267+
// Note: Multiple time series may be included (same timestamp, different attributes).
260268
repeated ExponentialHistogramDataPoint data_points = 1;
261269

262270
// aggregation_temporality describes if the aggregator reports delta changes
@@ -274,6 +282,8 @@ message ExponentialHistogram {
274282
// because the count and sum fields of a SummaryDataPoint are assumed to be
275283
// cumulative values.
276284
message Summary {
285+
// The time series data points.
286+
// Note: Multiple time series may be included (same timestamp, different attributes).
277287
repeated SummaryDataPoint data_points = 1;
278288
}
279289

@@ -554,12 +564,12 @@ message ExponentialHistogramDataPoint {
554564
// 1970.
555565
fixed64 time_unix_nano = 3;
556566

557-
// count is the number of values in the population. Must be
567+
// The number of values in the population. Must be
558568
// non-negative. This value must be equal to the sum of the "bucket_counts"
559569
// values in the positive and negative Buckets plus the "zero_count" field.
560570
fixed64 count = 4;
561571

562-
// sum of the values in the population. If count is zero then this field
572+
// The sum of the values in the population. If count is zero then this field
563573
// must be zero.
564574
//
565575
// Note: Sum should only be filled out when measuring non-negative discrete
@@ -586,7 +596,7 @@ message ExponentialHistogramDataPoint {
586596
// values depend on the range of the data.
587597
sint32 scale = 6;
588598

589-
// zero_count is the count of values that are either exactly zero or
599+
// The count of values that are either exactly zero or
590600
// within the region considered zero by the instrumentation at the
591601
// tolerated degree of precision. This bucket stores values that
592602
// cannot be expressed using the standard exponential formula as
@@ -605,12 +615,12 @@ message ExponentialHistogramDataPoint {
605615
// Buckets are a set of bucket counts, encoded in a contiguous array
606616
// of counts.
607617
message Buckets {
608-
// Offset is the bucket index of the first entry in the bucket_counts array.
618+
// The bucket index of the first entry in the bucket_counts array.
609619
//
610620
// Note: This uses a varint encoding as a simple form of compression.
611621
sint32 offset = 1;
612622

613-
// bucket_counts is an array of count values, where bucket_counts[i] carries
623+
// An array of count values, where bucket_counts[i] carries
614624
// the count of the bucket at index (offset+i). bucket_counts[i] is the count
615625
// of values greater than base^(offset+i) and less than or equal to
616626
// base^(offset+i+1).
@@ -630,10 +640,10 @@ message ExponentialHistogramDataPoint {
630640
// measurements that were used to form the data point
631641
repeated Exemplar exemplars = 11;
632642

633-
// min is the minimum value over (start_time, end_time].
643+
// The minimum value over (start_time, end_time].
634644
optional double min = 12;
635645

636-
// max is the maximum value over (start_time, end_time].
646+
// The maximum value over (start_time, end_time].
637647
optional double max = 13;
638648

639649
// ZeroThreshold may be optionally set to convey the width of the zero

opentelemetry/proto/profiles/v1development/profiles.proto

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ message Profile {
300300
// This field is optional; an ID may be assigned to an ID-less profile in a later step.
301301
bytes profile_id = 8;
302302

303-
// dropped_attributes_count is the number of attributes that were discarded. Attributes
303+
// The number of attributes that were discarded. Attributes
304304
// can be discarded because their keys are too long or because there are too many
305305
// attributes. If this value is 0, then no attributes were dropped.
306306
uint32 dropped_attributes_count = 9;
@@ -333,8 +333,11 @@ message Link {
333333

334334
// ValueType describes the type and units of a value.
335335
message ValueType {
336-
int32 type_strindex = 1; // Index into ProfilesDictionary.string_table.
337-
int32 unit_strindex = 2; // Index into ProfilesDictionary.string_table.
336+
// Index into ProfilesDictionary.string_table.
337+
int32 type_strindex = 1;
338+
339+
// Index into ProfilesDictionary.string_table.
340+
int32 unit_strindex = 2;
338341
}
339342

340343
// Each Sample records values encountered in some program context. The program
@@ -437,7 +440,7 @@ message Line {
437440
// Describes a function, including its human-readable name, system name,
438441
// source file, and starting line number in the source.
439442
message Function {
440-
// Function name. Empty string if not available.
443+
// The function name. Empty string if not available.
441444
int32 name_strindex = 1;
442445
// Function name, as identified by the system. For instance,
443446
// it can be a C++ mangled name. Empty string if not available.
@@ -452,7 +455,11 @@ message Function {
452455
// for profiles than opentelemetry.proto.common.v1.KeyValue
453456
// Specifically, uses the string table for keys and allows optional unit information.
454457
message KeyValueAndUnit {
458+
// The index into the string table for the attribute's key.
455459
int32 key_strindex = 1;
460+
// The value of the attribute.
456461
opentelemetry.proto.common.v1.AnyValue value = 2;
457-
int32 unit_strindex = 3; // zero indicates implicit (by semconv) or non-defined unit.
462+
// The index into the string table for the attribute's unit.
463+
// zero indicates implicit (by semconv) or non-defined unit.
464+
int32 unit_strindex = 3;
458465
}

opentelemetry/proto/resource/v1/resource.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ message Resource {
4141
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute.
4242
repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
4343

44-
// dropped_attributes_count is the number of dropped attributes. If the value is 0, then
44+
// The number of dropped attributes. If the value is 0, then
4545
// no attributes were dropped.
4646
uint32 dropped_attributes_count = 2;
4747

opentelemetry/proto/trace/v1/trace.proto

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,23 @@ message Span {
182182
// and `SERVER` (callee) to identify queueing latency associated with the span.
183183
SpanKind kind = 6;
184184

185-
// start_time_unix_nano is the start time of the span. On the client side, this is the time
185+
// The start time of the span. On the client side, this is the time
186186
// kept by the local machine where the span execution starts. On the server side, this
187187
// is the time when the server's application handler starts running.
188188
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
189189
//
190190
// This field is semantically required and it is expected that end_time >= start_time.
191191
fixed64 start_time_unix_nano = 7;
192192

193-
// end_time_unix_nano is the end time of the span. On the client side, this is the time
193+
// The end time of the span. On the client side, this is the time
194194
// kept by the local machine where the span execution ends. On the server side, this
195195
// is the time when the server application handler stops running.
196196
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
197197
//
198198
// This field is semantically required and it is expected that end_time >= start_time.
199199
fixed64 end_time_unix_nano = 8;
200200

201-
// attributes is a collection of key/value pairs. Note, global attributes
201+
// A collection of key/value pairs. Note, global attributes
202202
// like server name can be set using the resource API. Examples of attributes:
203203
//
204204
// "/http/user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
@@ -220,22 +220,22 @@ message Span {
220220
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute.
221221
repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
222222

223-
// dropped_attributes_count is the number of attributes that were discarded. Attributes
223+
// The number of attributes that were discarded. Attributes
224224
// can be discarded because their keys are too long or because there are too many
225225
// attributes. If this value is 0, then no attributes were dropped.
226226
uint32 dropped_attributes_count = 10;
227227

228228
// Event is a time-stamped annotation of the span, consisting of user-supplied
229229
// text description and key-value pairs.
230230
message Event {
231-
// time_unix_nano is the time the event occurred.
231+
// The time the event occurred.
232232
fixed64 time_unix_nano = 1;
233233

234-
// name of the event.
234+
// The name of the event.
235235
// This field is semantically required to be set to non-empty string.
236236
string name = 2;
237237

238-
// attributes is a collection of attribute key/value pairs on the event.
238+
// A collection of attribute key/value pairs on the event.
239239
// Attribute keys MUST be unique (it is not allowed to have more than one
240240
// attribute with the same key).
241241
//
@@ -250,15 +250,15 @@ message Span {
250250
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute.
251251
repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
252252

253-
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
253+
// The number of dropped attributes. If the value is 0,
254254
// then no attributes were dropped.
255255
uint32 dropped_attributes_count = 4;
256256
}
257257

258-
// events is a collection of Event items.
258+
// A collection of Event items.
259259
repeated Event events = 11;
260260

261-
// dropped_events_count is the number of dropped events. If the value is 0, then no
261+
// The number of dropped events. If the value is 0, then no
262262
// events were dropped.
263263
uint32 dropped_events_count = 12;
264264

@@ -277,7 +277,7 @@ message Span {
277277
// The trace_state associated with the link.
278278
string trace_state = 3;
279279

280-
// attributes is a collection of attribute key/value pairs on the link.
280+
// A collection of attribute key/value pairs on the link.
281281
// Attribute keys MUST be unique (it is not allowed to have more than one
282282
// attribute with the same key).
283283
//
@@ -292,7 +292,7 @@ message Span {
292292
// https://github.com/open-telemetry/opentelemetry-specification/blob/v1.47.0/specification/common/README.md#attribute.
293293
repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
294294

295-
// dropped_attributes_count is the number of dropped attributes. If the value is 0,
295+
// The number of dropped attributes. If the value is 0,
296296
// then no attributes were dropped.
297297
uint32 dropped_attributes_count = 5;
298298

@@ -316,11 +316,11 @@ message Span {
316316
fixed32 flags = 6;
317317
}
318318

319-
// links is a collection of Links, which are references from this span to a span
319+
// A collection of Links, which are references from this span to a span
320320
// in the same or different trace.
321321
repeated Link links = 13;
322322

323-
// dropped_links_count is the number of dropped links after the maximum size was
323+
// The number of dropped links after the maximum size was
324324
// enforced. If this value is 0, then no links were dropped.
325325
uint32 dropped_links_count = 14;
326326

0 commit comments

Comments
 (0)