|
| 1 | +-type oc_string() :: iodata(). |
| 2 | +-type oc_float() :: float() | integer() | infinity | '-infinity' | nan. |
| 3 | +-type oc_double() :: float() | integer() | infinity | '-infinity' | nan. |
| 4 | +-type oc_int64() :: integer(). |
| 5 | +-type oc_uint64() :: non_neg_integer(). |
| 6 | +-type oc_int32() :: integer(). |
| 7 | +-type oc_uint32() :: integer(). |
| 8 | + |
| 9 | +-type registry() :: atom(). |
| 10 | + |
| 11 | +%% Defines a label key associated with a metric descriptor. |
| 12 | +-record(oc_label_key, |
| 13 | + {key = <<>> :: oc_string(), |
| 14 | + description = <<>> :: oc_string() |
| 15 | + }). |
| 16 | + |
| 17 | +-type oc_label_key() :: #oc_label_key{}. |
| 18 | + |
| 19 | +%% Represents the value of label |
| 20 | +%% @type oc_label_value(v) = #oc_label_value{value = binary() | iolist(), |
| 21 | +%% present = boolean()} |
| 22 | +-record(oc_label_value, |
| 23 | + {value :: oc_string() | undefined, %% the value of the label |
| 24 | + present :: boolean() %% if false the value field is ignored and considered not set; |
| 25 | + %% This is used to differentiate a missing label from an empty string. |
| 26 | + }). |
| 27 | + |
| 28 | +-type oc_label_value() :: #oc_label_value{}. |
| 29 | + |
| 30 | +-record(oc_explicit_bucket_options, |
| 31 | + {bounds = [] :: [oc_double()] |
| 32 | + }). |
| 33 | + |
| 34 | +-type oc_explicit_bucket_options() :: #oc_explicit_bucket_options{}. |
| 35 | + |
| 36 | +-record(exemplar, |
| 37 | + {value = 0.0 :: oc_double(), |
| 38 | + timestamp = undefined :: wts:timestamp() | undefined, |
| 39 | + attachments = #{} :: #{oc_string() := oc_string()} |
| 40 | + }). |
| 41 | + |
| 42 | +-type exemplar() :: #exemplar{}. |
| 43 | + |
| 44 | +-record(oc_bucket, |
| 45 | + {count = 0 :: oc_int64(), |
| 46 | + exemplar = undefined :: oc_metrics:exemplar() | undefined |
| 47 | + }). |
| 48 | + |
| 49 | +-type oc_bucket() :: #oc_bucket{}. |
| 50 | + |
| 51 | +-record(oc_distribution, |
| 52 | + {count = 0 :: oc_int32(), |
| 53 | + sum = 0.0 :: oc_double(), |
| 54 | + sum_of_squared_deviation = 0.0 :: oc_double(), |
| 55 | + bucket_options = undefined :: oc_explicit_bucket_options() | undefined, |
| 56 | + buckets = undefined :: [oc_bucket()] | undefined |
| 57 | + }). |
| 58 | + |
| 59 | +-type oc_distribution() :: #oc_distribution{}. |
| 60 | + |
| 61 | +-record(oc_value_at_percentile, |
| 62 | + {percentile = 0.0 :: oc_double(), |
| 63 | + value = 0.0 :: oc_double() |
| 64 | + }). |
| 65 | + |
| 66 | +-type oc_value_at_percentile() :: #oc_value_at_percentile{}. |
| 67 | + |
| 68 | +-record(oc_snapshot, |
| 69 | + {count = undefined :: oc_int64() | undefined, |
| 70 | + sum = undefined :: oc_double() | undefined, |
| 71 | + percentile_values = [] :: [oc_value_at_percentile()] | undefined |
| 72 | + }). |
| 73 | + |
| 74 | +-type oc_snapshot() :: #oc_snapshot{}. |
| 75 | + |
| 76 | +-record(oc_summary, |
| 77 | + {count = 0 :: oc_int64(), |
| 78 | + sum = 0.0 :: oc_double(), |
| 79 | + snapshot = undefined :: oc_snapshot() | undefined |
| 80 | + }). |
| 81 | + |
| 82 | +-type oc_summary() :: #oc_summary{}. |
| 83 | + |
| 84 | +-record(oc_point, |
| 85 | + {timestamp = undefined :: wts:timestamp() | undefined, |
| 86 | + value :: oc_int64() | oc_double() | |
| 87 | + oc_distribution() | oc_summary() |
| 88 | + }). |
| 89 | + |
| 90 | +-type oc_point() :: #oc_point{}. |
| 91 | + |
| 92 | +-record(oc_time_series, |
| 93 | + {start_timestamp = undefined :: wts:timestamp() | undefined, |
| 94 | + label_values = [] :: [oc_label_value()], |
| 95 | + points = [] :: [oc_point()] |
| 96 | + }). |
| 97 | + |
| 98 | +-type oc_time_series() :: #oc_time_series{}. |
| 99 | +-record(oc_metric_descriptor, |
| 100 | + {name = <<>> :: oc_string(), |
| 101 | + description = <<>> :: oc_string(), |
| 102 | + unit = <<"1">> :: oc_string(), |
| 103 | + type = 'UNSPECIFIED' :: 'UNSPECIFIED' | |
| 104 | + 'GAUGE_INT64' | |
| 105 | + 'GAUGE_DOUBLE' | |
| 106 | + 'GAUGE_DISTRIBUTION' | |
| 107 | + 'CUMULATIVE_INT64' | |
| 108 | + 'CUMULATIVE_DOUBLE' | |
| 109 | + 'CUMULATIVE_DISTRIBUTION' | |
| 110 | + 'SUMMARY', |
| 111 | + label_keys = [] :: [oc_label_key()] %% The label keys associated with the metric descriptor. |
| 112 | + }). |
| 113 | + |
| 114 | +-type oc_metric_descriptor() :: #oc_metric_descriptor{}. |
| 115 | + |
| 116 | +-record(oc_resource, |
| 117 | + {type = <<>> :: oc_string(), |
| 118 | + labels = #{} :: #{oc_string() := oc_string()} |
| 119 | + }). |
| 120 | + |
| 121 | +-type oc_resource() :: #oc_resource{}. |
| 122 | + |
| 123 | +-record(oc_metric, |
| 124 | + {descriptor :: oc_metric_descriptor() | oc_string(), |
| 125 | + timeseries = [] :: [oc_time_series()], |
| 126 | + resource = undefined :: oc_resource() | undefined |
| 127 | + }). |
| 128 | + |
| 129 | +-type oc_metric() :: #oc_metric{}. |
| 130 | + |
| 131 | +-type metric_callback() :: |
| 132 | + fun((oc_producer_registry:registry(), oc_metric()) -> any()). |
0 commit comments