Skip to content

Commit 0c3a7f6

Browse files
author
jmacd
committed
Document each kind
1 parent 50e0331 commit 0c3a7f6

2 files changed

Lines changed: 172 additions & 95 deletions

File tree

opentelemetry/proto/metrics/v1/gen.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
)
3030

3131
var (
32-
cumulativeProps = []string{"Instantaneous", "Cumulative", "Delta"}
32+
cumulativeProps = []string{"Instantaneous", "Delta", "Cumulative"}
3333
addingProps = []string{"Adding", "Grouping"}
3434
monoProps = []string{"Monotonic", ""}
3535
syncProps = []string{"Synchronous", "Asynchronous"}
@@ -72,6 +72,7 @@ var (
7272
if a == "Grouping" && m == "Monotonic" {
7373
continue
7474
}
75+
7576
mfrag := ""
7677
mname := ""
7778
if m == "Monotonic" {
@@ -80,6 +81,9 @@ var (
8081
}
8182
for _, c := range cumulativeProps {
8283
for _, s := range syncProps {
84+
if c == "Instantaneous" && s == "Asynchronous" {
85+
continue
86+
}
8387
sfrag := ""
8488
sname := ""
8589
if s == "Asynchronous" {
@@ -109,7 +113,7 @@ func main() {
109113
}
110114

111115
for i, fn := range fullnames {
112-
fmt.Println(`fmt.Printf(" %-*s = %-*s; // %s\n", `, maxNameSize, ",", strconv.Quote(fn), ",", 4, ",", `fmt.Sprintf("%#x",`, fn, `)`, ",", strconv.Quote(fullvalues[i]), ")")
116+
fmt.Println(`fmt.Printf(" %s = %s; // %s\n", `, strconv.Quote(fn), ",", `fmt.Sprintf("%#x",`, fn, `)`, ",", strconv.Quote(fullvalues[i]), ")")
113117
}
114118
fmt.Println(`}`)
115119
}

opentelemetry/proto/metrics/v1/metrics.proto

Lines changed: 166 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ message Metric {
114114
// by MetricDescriptor.value_type field.
115115

116116
repeated ScalarDataPoint scalar_data_points = 2;
117-
repeated HistogramDataPoint histogram_data_points = 4;
118-
repeated SummaryDataPoint summary_data_points = 5;
117+
repeated HistogramDataPoint histogram_data_points = 3;
118+
repeated SummaryDataPoint summary_data_points = 4;
119119
}
120120

121121
// Defines a metric type and its schema.
@@ -138,6 +138,14 @@ message MetricDescriptor {
138138
INVALID_VALUE_TYPE = 0;
139139

140140
// ScalarInt64 implies that the value is found in Metric.scalar_data_points[].value_int64.
141+
//
142+
// When paired with GROUPING kind, the value corresponds with an
143+
// individual measurement. Paired with ADDING kind, the value
144+
//
145+
// . When paired with ADDING kind, the value
146+
//
147+
//
148+
// When INSTANTANEOUS, this
141149
SCALAR_INT64 = 1;
142150

143151
// ScalarDouble implies that the value is found in Metric.scalar_data_points[].value_double.
@@ -171,32 +179,41 @@ message MetricDescriptor {
171179
// instrument, and the Sum and Count of the resulting aggregation
172180
// may be interpreted differently depending on structure.
173181
//
174-
// _Monotonic_ is a boolean option that may be applied to
182+
// MONOTONIC is a boolean option that may be applied to
175183
// ADDING-structure metrics.
176184
//
177-
// _Asynchronous_ is a boolean option that may be applied to all
185+
// ASYNCHRONOUS is a boolean option that may be applied to all
178186
// metrics. When set, an ASYNCHRONOUS kind indicates that the
179187
// corresponding measurement was made through a callback called by
180-
// the SDK. When measurements originate from an OpenTelemetry
181-
// API, the ASYNCHRONOUS kind allows the interpreter to recognize
182-
// values that were emitted by the same callback invokation, which
183-
// are permitted to record at most one value per label set under
184-
// the specification. This property can be safetly disregarded
185-
// and not set when importing data from other sources, but when
186-
// set its presence is always meaningful. It means:
188+
// the SDK. TimeUnixNano is deliberate, not the result of an
189+
// application-level event.
190+
//
191+
// When measurements originate from an OpenTelemetry API, the
192+
// ASYNCHRONOUS kind allows the interpreter to recognize values
193+
// that were emitted by the same callback invokation, as
194+
// identified by equal an Resource and TimeUnixNano.
195+
// OpenTelemetry callbacks are permitted to record at most one
196+
// value per label set under the specification. This property can
197+
// be safetly disregarded and not set when importing data from
198+
// other sources, but when set its presence is always meaningful.
199+
//
200+
// ASYNCHRONOUS means that:
187201
// - The count of events is a measure of the rate of SDK collection
188202
// times the aggregated cardinality, therefore cannot be used
189203
// to extrapolate application-specific rate information.
190-
// - Measurements with the same Resource and StartTimeUnixNano
191-
// form a meaningful ratio, and the set of measurements is coherent.
192-
// - Trace context MUST not be set.
204+
// - Measurements with the same Resource and TimeUnixNano
205+
// form a meaningful ratio, and the set of measurements at this
206+
// instant are coherent, resulting from a single callback.
207+
// - Trace context MUST not be set in exemplars.
208+
// TODO(#159): raw values.
193209
//
210+
// ASYNCHRONOUS is incompatible with INSTANTANEOUS.
194211
enum KindElement {
195212
// INVALID_KIND_MASK is not used.
196213
INVALID_KIND_MASK = 0;
197214

198-
// One of the following three MUST be set. There are 3 exclusive
199-
// Temporality kinds.
215+
// The three Temporality kinds are exclusive of one another. One
216+
// of the following three MUST be set.
200217

201218
// INSTANTANEOUS is a metric whose values are measured at a particular
202219
// instant. The values are not aggregated over any time interval and are
@@ -261,10 +278,17 @@ message MetricDescriptor {
261278
// 12. The 1 second collection cycle ends. A metric is exported for the
262279
// number of requests received over the interval of time t_1 to
263280
// t_0+1 with a value of 1.
281+
//
282+
// Note that the first value in a sequence of CUMULATIVE metrics
283+
// after a reset is equivalent in value to a DELTA metric for the
284+
// period since the reset. Although a CUMULATIVE metric could
285+
// technically be reset after every collection event and still be
286+
// described as CUMULATIVE, exporters should use DELTA if there is
287+
// no intention of repeating the StartTimeUnixNano timestamp.
264288
CUMULATIVE = 0x4;
265289

266-
// One of the following two MUST be set. There are 2 exclusive
267-
// Structure kinds.
290+
// The two Structure kinds are exclusive of one another. One
291+
// of the Structure kind elements MUST be set.
268292

269293
// ADDING structure means the measurement determines a sum. For
270294
// DELTA kind this is expressed as the change in sum since the
@@ -274,34 +298,29 @@ message MetricDescriptor {
274298
ADDING = 0x8;
275299

276300
// GROUPING structure means the value has been computed by
277-
// combining individual values in a meaningful aggregation.
301+
// combining individual values through a meaningful aggregation.
278302
// GROUPING structure implies the sum of measurements is not
279303
// necessarily meaningful. These may be expressed as DELTA
280304
// kind, indicating an aggregation of values since the last
281305
// collection, or as CUMULATIVE kind, indicating an aggregation
282306
// of values since the last StartTimeUnixNano reset. These may
283307
// also be expressed as INSTANTANEOUS kind when reporting a
284-
// scalar value type.
308+
// scalar value type. TODO(#159) or raw value.
285309
GROUPING = 0x10;
286310

287311
// MONOTONIC may be set in conjunction with ADDING kinds. When
288-
// set, MONOTONIC indicates that the calculated sum can be
289-
// monitored as a non-negative rate of change.
290-
//
291-
// For DELTA
292-
// kind, this implies non-negative value series. For CUMULATIVE
293-
// kind, this implies a non-decreasing value series.
294-
//
295-
// Observers of
296-
// MONOTONIC metrics should never see the value decrease without a
297-
// reset (i.e., StartTimeUnixNano advances), otherwise a
298-
// decreasing MONOTONIC metric suggests an SDK bug.
312+
// set, MONOTONIC indicates that the calculated sum is
313+
// non-decreasing, therefore can be monitored as a non-negative
314+
// rate of change.
299315
MONOTONIC = 0x20;
300316

301317
// ASYNCHRONOUS may be set for any kind of metric, indicating it
302-
// was generated through asynchronous events in which the SDK
303-
// calls the application. If ASYNCHRONOUS is not set, it implies
304-
// the event originated from the application calling the SDK.
318+
// was generated through callbacks, willed by the SDK. In
319+
// ASYNCHRONOUS measurements, TimeUnixNano results deliberately
320+
// from the SDK, not from the application.
321+
//
322+
// When ASYNCHRONOUS is not set, it implies the event originated
323+
// from the application calling the SDK.
305324
ASYNCHRONOUS = 0x40;
306325
}
307326

@@ -318,90 +337,144 @@ message MetricDescriptor {
318337
// - 3 possibilities for Temporality
319338
// - 3 possibilities for Structure/Monotonicity: Adding Monotonic,
320339
// Adding Non-Monotonic, and Grouping
321-
// - 2 possibilities of being Asynchronous
340+
// - 2 possibilities of being Asynchronous or not.
322341
//
323-
// This makes 18 valid values.
342+
// Exclusing the asynchronous instantaneous combinations, this makes
343+
// 15 valid values.
324344
enum Kind {
325345
// INVALID_KIND is the default Kind, it MUST not be used.
326346
INVALID_KIND = 0;
327347

328-
// The following codes are generated by a program.
329-
330-
ADDING_MONOTONIC_INSTANTANEOUS = 0x29; // ADDING|INSTANTANEOUS|MONOTONIC
331-
ADDING_MONOTONIC_INSTANTANEOUS_ASYNCHRONOUS = 0x69; // ADDING|INSTANTANEOUS|MONOTONIC|ASYNCHRONOUS
332-
ADDING_MONOTONIC_CUMULATIVE = 0x2c; // ADDING|CUMULATIVE|MONOTONIC
333-
ADDING_MONOTONIC_CUMULATIVE_ASYNCHRONOUS = 0x6c; // ADDING|CUMULATIVE|MONOTONIC|ASYNCHRONOUS
334-
ADDING_MONOTONIC_DELTA = 0x2a; // ADDING|DELTA|MONOTONIC
348+
// The following hex values are generated by gen.go in this source
349+
// directory.
350+
351+
// ADDING_MONOTONIC_INSTANTANEOUS kind describes the change in a
352+
// sum as measured at an instant (TimeUnixNano). The value MUST
353+
// be non-negative. Generally this is the value of an
354+
// OpenTelemetry Counter instrument without aggregation.
355+
// Typically expressed as a scalar (TODO(#159): or raw) value.
356+
ADDING_MONOTONIC_INSTANTANEOUS = 0x29; // ADDING|INSTANTANEOUS|MONOTONIC
357+
358+
// ADDING_MONOTONIC_DELTA describes the change in a sum
359+
// accumulated since the metric was last collected
360+
// (StartTimeUnixNano) through the measured time (TimeUnixNano).
361+
// The value MUST be non-negative. Generally this is the result
362+
// of aggregating an OpenTelemetry Counter instrument since the
363+
// last collection. Typically expressed as a scalar or histogram
364+
// value.
365+
ADDING_MONOTONIC_DELTA = 0x2a; // ADDING|DELTA|MONOTONIC
366+
367+
// ADDING_MONOTONIC_DELTA_ASYNCHRONOUS is ADDING_MONOTONIC_DELTA
368+
// with asynchronous semantics specified by the OpenTelemetry API,
369+
// indicating the value was collected through a callback.
370+
// Generally this is the temporal difference between values of an
371+
// OpenTelemetry SumObserver instrument. Typically expressed as a
372+
// scalar or histogram value.
335373
ADDING_MONOTONIC_DELTA_ASYNCHRONOUS = 0x6a; // ADDING|DELTA|MONOTONIC|ASYNCHRONOUS
336374

337-
ADDING_INSTANTANEOUS = 0x9 ; // ADDING|INSTANTANEOUS
338-
ADDING_INSTANTANEOUS_ASYNCHRONOUS = 0x49; // ADDING|INSTANTANEOUS|ASYNCHRONOUS
339-
ADDING_CUMULATIVE = 0xc ; // ADDING|CUMULATIVE
340-
ADDING_CUMULATIVE_ASYNCHRONOUS = 0x4c; // ADDING|CUMULATIVE|ASYNCHRONOUS
341-
ADDING_DELTA = 0xa ; // ADDING|DELTA
342-
ADDING_DELTA_ASYNCHRONOUS = 0x4a; // ADDING|DELTA|ASYNCHRONOUS
343-
344-
GROUPING_INSTANTANEOUS = 0x11; // GROUPING|INSTANTANEOUS
345-
GROUPING_INSTANTANEOUS_ASYNCHRONOUS = 0x51; // GROUPING|INSTANTANEOUS|ASYNCHRONOUS
346-
GROUPING_CUMULATIVE = 0x14; // GROUPING|CUMULATIVE
347-
GROUPING_CUMULATIVE_ASYNCHRONOUS = 0x54; // GROUPING|CUMULATIVE|ASYNCHRONOUS
348-
GROUPING_DELTA = 0x12; // GROUPING|DELTA
349-
GROUPING_DELTA_ASYNCHRONOUS = 0x52; // GROUPING|DELTA|ASYNCHRONOUS
375+
// ADDING_MONOTONIC_CUMULATIVE describes the current value of a
376+
// sum accumulated from the reset time (StartTimeUnixNano) through
377+
// the measured time (TimeUnixNano). The value must be
378+
// non-negative and not less than the previously reported value of
379+
// the same metric. Generally this is the result of aggregating an
380+
// OpenTelemetry Counter instrument since the last reset time.
381+
// Typically expressed as a scalar or histogram value.
382+
ADDING_MONOTONIC_CUMULATIVE = 0x2c; // ADDING|CUMULATIVE|MONOTONIC
383+
384+
// ADDING_MONOTONIC_CUMULATIVE_ASYNCHRONOUS is
385+
// ADDING_MONOTONIC_CUMULATIVE with asynchronous semantics
386+
// specified by the OpenTelemetry API, indicating the value was
387+
// collected through a callback. Generally this is the sum of
388+
// measurements of an OpenTelemetry SumObserver instrument.
389+
// Typically expressed as a scalar or histogram value.
390+
ADDING_MONOTONIC_CUMULATIVE_ASYNCHRONOUS = 0x6c; // ADDING|CUMULATIVE|MONOTONIC|ASYNCHRONOUS
391+
392+
// TODO(jmacd): The following five values have nearly-identical
393+
// comments as the above, with the "non-negative" sentence changed
394+
// to and the Counter instrument replaced by the UpDownCounter
395+
// instrument. Update comments following review of the above.
396+
397+
ADDING_INSTANTANEOUS = 0x9; // ADDING|INSTANTANEOUS
398+
ADDING_DELTA = 0xa; // ADDING|DELTA
399+
ADDING_DELTA_ASYNCHRONOUS = 0x4a; // ADDING|DELTA|ASYNCHRONOUS
400+
ADDING_CUMULATIVE = 0xc; // ADDING|CUMULATIVE
401+
ADDING_CUMULATIVE_ASYNCHRONOUS = 0x4c; // ADDING|CUMULATIVE|ASYNCHRONOUS
402+
403+
// GROUPING_INSTANTANEOUS kind describes an individual value
404+
// measured at an instant (TimeUnixNano). Generally this is the value of an
405+
// OpenTelemetry ValueRecorder instrument without aggregation.
406+
// Typically expressed as a scalar (TODO(#159): or raw) value.
407+
GROUPING_INSTANTANEOUS = 0x11; // GROUPING|INSTANTANEOUS
408+
409+
// GROUPING_DELTA kind describes a set of individual values
410+
// measured from the most recent collection (StartTimeUnixNano)
411+
// through the measured time (TimeUnixNano). Generally this is
412+
// the aggregated value of an OpenTelemetry ValueRecorder
413+
// instrument. Typically expressed as a scalar, histogram, or
414+
// summary value. When expressed as a scalar value, this is
415+
// specified to mean the most recent (i.e., "last") value to occur
416+
// within the collection interval.
417+
GROUPING_DELTA = 0x12; // GROUPING|DELTA
418+
419+
// GROUPING_DELTA_ASYNCHRONOUS is GROUPING_DELTA with asynchronous
420+
// semantics specified by the OpenTelemetry API, indicating the
421+
// value was collected through a callback. Generally this is the
422+
// aggregated value of an OpenTelemetry ValueObserver instrument.
423+
// Typically expressed as a scalar, histogram, or summary value.
424+
GROUPING_DELTA_ASYNCHRONOUS = 0x52; // GROUPING|DELTA|ASYNCHRONOUS
425+
426+
// GROUPING_CUMULATIVE kind describes a set of individual values
427+
// measured from the last reset time (StartTimeUnixNano) through
428+
// the measured time (TimeUnixNano). Generally this is the
429+
// aggregated value of an OpenTelemetry ValueRecorder instrument.
430+
// Typically expressed as a scalar or histogram value. When
431+
// expressed as a scalar value, this is specified to mean the most
432+
// recent (i.e., "last") value to occur since the reset time,
433+
// which may have occurred prior to the most recent collection
434+
// interval.
435+
GROUPING_CUMULATIVE = 0x14; // GROUPING|CUMULATIVE
436+
437+
// GROUPING_CUMULATIVE_ASYNCHRONOUS is GROUPING_CUMULATIVE with
438+
// asynchronous semantics specified by the OpenTelemetry API,
439+
// indicating the value was collected through a callback.
440+
// Generally this is the aggregated value of an OpenTelemetry
441+
// ValueObserver instrument. Typically expressed as a scalar or
442+
// histogram value.
443+
GROUPING_CUMULATIVE_ASYNCHRONOUS = 0x54; // GROUPING|CUMULATIVE|ASYNCHRONOUS
350444
}
351445

352446
// Kind describes properties of the Metric that are necessary to
353447
// interpret the data and/or describe how it was produced.
354448
Kind kind = 5;
355449
}
356450

357-
// Int64DataPoint is a single data point in a timeseries that describes the time-varying
358-
// values of a SCALAR_INT64 metric.
359-
message Int64DataPoint {
451+
// ScalarDataPoint is a single data point in a timeseries that
452+
// describes the time-varying values of a SCALAR_INT64 or
453+
// SCALAR_DOUBLE metric.
454+
message ScalarDataPoint {
360455
// The set of labels that uniquely identify this timeseries.
361456
repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1;
362457

363-
// start_time_unix_nano is the time when the cumulative value was reset to zero.
364-
// This is used for Counter type only. For Gauge the value is not specified and
365-
// defaults to 0.
366-
//
367-
// The cumulative value is over the time interval (start_time_unix_nano, time_unix_nano].
368-
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
458+
// start_time_unix_nano is the time when the value was reset to zero
459+
// for CUMULATIVE or DELTA metrics.
369460
//
370-
// Value of 0 indicates that the timestamp is unspecified. In that case the timestamp
371-
// may be decided by the backend.
461+
// The value is measured over the time interval
462+
// (start_time_unix_nano, time_unix_nano]. Value is UNIX Epoch time
463+
// in nanoseconds since 00:00:00 UTC on 1 January 1970. The value
464+
// MUST be set when the instrument descriptor Kind includes either
465+
// CUMULATIVE or DELTA and MUST NOT be set when Kind includes
466+
// INSTANTANOUS.
372467
fixed64 start_time_unix_nano = 2;
373468

374469
// time_unix_nano is the moment when this value was recorded.
375470
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
376471
fixed64 time_unix_nano = 3;
377472

378-
// value itself.
379-
int64 value = 4;
380-
}
381-
382-
// DoubleDataPoint is a single data point in a timeseries that describes the time-varying
383-
// value of a SCALAR_DOUBLE metric.
384-
message DoubleDataPoint {
385-
// The set of labels that uniquely identify this timeseries.
386-
repeated opentelemetry.proto.common.v1.StringKeyValue labels = 1;
387-
388-
// start_time_unix_nano is the time when the cumulative value was reset to zero.
389-
// This is used for Counter type only. For Gauge the value is not specified and
390-
// defaults to 0.
391-
//
392-
// The cumulative value is over the time interval (start_time_unix_nano, time_unix_nano].
393-
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
394-
//
395-
// Value of 0 indicates that the timestamp is unspecified. In that case the timestamp
396-
// may be decided by the backend.
397-
fixed64 start_time_unix_nano = 2;
398-
399-
// time_unix_nano is the moment when this value was recorded.
400-
// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
401-
fixed64 time_unix_nano = 3;
473+
// value itself, if SCALAR_INT64.
474+
int64 value_int64 = 4;
402475

403-
// value itself.
404-
double value = 4;
476+
// value itself, if SCALAR_DOUBLE.
477+
double value_double = 4;
405478
}
406479

407480
// HistogramDataPoint is a single data point in a timeseries that describes the time-varying

0 commit comments

Comments
 (0)