@effect/opentelemetry 0.61.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/LICENSE +1 -1
  2. package/dist/{dts/Logger.d.ts → Logger.d.ts} +19 -13
  3. package/dist/Logger.d.ts.map +1 -0
  4. package/dist/Logger.js +76 -0
  5. package/dist/Logger.js.map +1 -0
  6. package/dist/Metrics.d.ts +76 -0
  7. package/dist/Metrics.d.ts.map +1 -0
  8. package/dist/Metrics.js +59 -0
  9. package/dist/Metrics.js.map +1 -0
  10. package/dist/{dts/NodeSdk.d.ts → NodeSdk.d.ts} +12 -9
  11. package/dist/NodeSdk.d.ts.map +1 -0
  12. package/dist/{esm/NodeSdk.js → NodeSdk.js} +23 -14
  13. package/dist/NodeSdk.js.map +1 -0
  14. package/dist/{dts/Resource.d.ts → Resource.d.ts} +10 -13
  15. package/dist/Resource.d.ts.map +1 -0
  16. package/dist/{esm/Resource.js → Resource.js} +12 -13
  17. package/dist/Resource.js.map +1 -0
  18. package/dist/Tracer.d.ts +129 -0
  19. package/dist/Tracer.d.ts.map +1 -0
  20. package/dist/Tracer.js +391 -0
  21. package/dist/Tracer.js.map +1 -0
  22. package/dist/{dts/WebSdk.d.ts → WebSdk.d.ts} +12 -9
  23. package/dist/WebSdk.d.ts.map +1 -0
  24. package/dist/WebSdk.js +41 -0
  25. package/dist/WebSdk.js.map +1 -0
  26. package/dist/index.d.ts +28 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +29 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/internal/attributes.d.ts +2 -0
  31. package/dist/internal/attributes.d.ts.map +1 -0
  32. package/dist/internal/attributes.js +19 -0
  33. package/dist/internal/attributes.js.map +1 -0
  34. package/dist/{dts/internal → internal}/metrics.d.ts.map +1 -1
  35. package/dist/internal/metrics.js +406 -0
  36. package/dist/internal/metrics.js.map +1 -0
  37. package/dist/internal/utilities.d.ts +2 -0
  38. package/dist/internal/utilities.d.ts.map +1 -0
  39. package/dist/internal/utilities.js +3 -0
  40. package/dist/internal/utilities.js.map +1 -0
  41. package/package.json +86 -119
  42. package/src/Logger.ts +52 -55
  43. package/src/Metrics.ts +92 -18
  44. package/src/NodeSdk.ts +67 -64
  45. package/src/Resource.ts +16 -24
  46. package/src/Tracer.ts +469 -78
  47. package/src/WebSdk.ts +59 -51
  48. package/src/index.ts +7 -36
  49. package/src/internal/attributes.ts +21 -0
  50. package/src/internal/metrics.ts +381 -250
  51. package/src/internal/utilities.ts +5 -0
  52. package/Logger/package.json +0 -6
  53. package/Metrics/package.json +0 -6
  54. package/NodeSdk/package.json +0 -6
  55. package/Otlp/package.json +0 -6
  56. package/OtlpLogger/package.json +0 -6
  57. package/OtlpMetrics/package.json +0 -6
  58. package/OtlpResource/package.json +0 -6
  59. package/OtlpSerialization/package.json +0 -6
  60. package/OtlpTracer/package.json +0 -6
  61. package/Resource/package.json +0 -6
  62. package/Tracer/package.json +0 -6
  63. package/WebSdk/package.json +0 -6
  64. package/dist/cjs/Logger.js +0 -85
  65. package/dist/cjs/Logger.js.map +0 -1
  66. package/dist/cjs/Metrics.js +0 -24
  67. package/dist/cjs/Metrics.js.map +0 -1
  68. package/dist/cjs/NodeSdk.js +0 -53
  69. package/dist/cjs/NodeSdk.js.map +0 -1
  70. package/dist/cjs/Otlp.js +0 -64
  71. package/dist/cjs/Otlp.js.map +0 -1
  72. package/dist/cjs/OtlpLogger.js +0 -163
  73. package/dist/cjs/OtlpLogger.js.map +0 -1
  74. package/dist/cjs/OtlpMetrics.js +0 -357
  75. package/dist/cjs/OtlpMetrics.js.map +0 -1
  76. package/dist/cjs/OtlpResource.js +0 -136
  77. package/dist/cjs/OtlpResource.js.map +0 -1
  78. package/dist/cjs/OtlpSerialization.js +0 -55
  79. package/dist/cjs/OtlpSerialization.js.map +0 -1
  80. package/dist/cjs/OtlpTracer.js +0 -231
  81. package/dist/cjs/OtlpTracer.js.map +0 -1
  82. package/dist/cjs/Resource.js +0 -75
  83. package/dist/cjs/Resource.js.map +0 -1
  84. package/dist/cjs/Tracer.js +0 -87
  85. package/dist/cjs/Tracer.js.map +0 -1
  86. package/dist/cjs/WebSdk.js +0 -42
  87. package/dist/cjs/WebSdk.js.map +0 -1
  88. package/dist/cjs/index.js +0 -32
  89. package/dist/cjs/index.js.map +0 -1
  90. package/dist/cjs/internal/metrics.js +0 -288
  91. package/dist/cjs/internal/metrics.js.map +0 -1
  92. package/dist/cjs/internal/otlpExporter.js +0 -83
  93. package/dist/cjs/internal/otlpExporter.js.map +0 -1
  94. package/dist/cjs/internal/otlpProtobuf.js +0 -430
  95. package/dist/cjs/internal/otlpProtobuf.js.map +0 -1
  96. package/dist/cjs/internal/protobuf.js +0 -183
  97. package/dist/cjs/internal/protobuf.js.map +0 -1
  98. package/dist/cjs/internal/tracer.js +0 -306
  99. package/dist/cjs/internal/tracer.js.map +0 -1
  100. package/dist/cjs/internal/utils.js +0 -34
  101. package/dist/cjs/internal/utils.js.map +0 -1
  102. package/dist/dts/Logger.d.ts.map +0 -1
  103. package/dist/dts/Metrics.d.ts +0 -29
  104. package/dist/dts/Metrics.d.ts.map +0 -1
  105. package/dist/dts/NodeSdk.d.ts.map +0 -1
  106. package/dist/dts/Otlp.d.ts +0 -80
  107. package/dist/dts/Otlp.d.ts.map +0 -1
  108. package/dist/dts/OtlpLogger.d.ts +0 -47
  109. package/dist/dts/OtlpLogger.d.ts.map +0 -1
  110. package/dist/dts/OtlpMetrics.d.ts +0 -41
  111. package/dist/dts/OtlpMetrics.d.ts.map +0 -1
  112. package/dist/dts/OtlpResource.d.ts +0 -104
  113. package/dist/dts/OtlpResource.d.ts.map +0 -1
  114. package/dist/dts/OtlpSerialization.d.ts +0 -53
  115. package/dist/dts/OtlpSerialization.d.ts.map +0 -1
  116. package/dist/dts/OtlpTracer.d.ts +0 -50
  117. package/dist/dts/OtlpTracer.d.ts.map +0 -1
  118. package/dist/dts/Resource.d.ts.map +0 -1
  119. package/dist/dts/Tracer.d.ts +0 -143
  120. package/dist/dts/Tracer.d.ts.map +0 -1
  121. package/dist/dts/WebSdk.d.ts.map +0 -1
  122. package/dist/dts/index.d.ts +0 -54
  123. package/dist/dts/index.d.ts.map +0 -1
  124. package/dist/dts/internal/otlpExporter.d.ts +0 -2
  125. package/dist/dts/internal/otlpExporter.d.ts.map +0 -1
  126. package/dist/dts/internal/otlpProtobuf.d.ts +0 -501
  127. package/dist/dts/internal/otlpProtobuf.d.ts.map +0 -1
  128. package/dist/dts/internal/protobuf.d.ts +0 -100
  129. package/dist/dts/internal/protobuf.d.ts.map +0 -1
  130. package/dist/dts/internal/tracer.d.ts +0 -2
  131. package/dist/dts/internal/tracer.d.ts.map +0 -1
  132. package/dist/dts/internal/utils.d.ts +0 -2
  133. package/dist/dts/internal/utils.d.ts.map +0 -1
  134. package/dist/esm/Logger.js +0 -75
  135. package/dist/esm/Logger.js.map +0 -1
  136. package/dist/esm/Metrics.js +0 -17
  137. package/dist/esm/Metrics.js.map +0 -1
  138. package/dist/esm/NodeSdk.js.map +0 -1
  139. package/dist/esm/Otlp.js +0 -56
  140. package/dist/esm/Otlp.js.map +0 -1
  141. package/dist/esm/OtlpLogger.js +0 -155
  142. package/dist/esm/OtlpLogger.js.map +0 -1
  143. package/dist/esm/OtlpMetrics.js +0 -349
  144. package/dist/esm/OtlpMetrics.js.map +0 -1
  145. package/dist/esm/OtlpResource.js +0 -124
  146. package/dist/esm/OtlpResource.js.map +0 -1
  147. package/dist/esm/OtlpSerialization.js +0 -46
  148. package/dist/esm/OtlpSerialization.js.map +0 -1
  149. package/dist/esm/OtlpTracer.js +0 -223
  150. package/dist/esm/OtlpTracer.js.map +0 -1
  151. package/dist/esm/Resource.js.map +0 -1
  152. package/dist/esm/Tracer.js +0 -80
  153. package/dist/esm/Tracer.js.map +0 -1
  154. package/dist/esm/WebSdk.js +0 -33
  155. package/dist/esm/WebSdk.js.map +0 -1
  156. package/dist/esm/index.js +0 -54
  157. package/dist/esm/index.js.map +0 -1
  158. package/dist/esm/internal/metrics.js +0 -278
  159. package/dist/esm/internal/metrics.js.map +0 -1
  160. package/dist/esm/internal/otlpExporter.js +0 -76
  161. package/dist/esm/internal/otlpExporter.js.map +0 -1
  162. package/dist/esm/internal/otlpProtobuf.js +0 -396
  163. package/dist/esm/internal/otlpProtobuf.js.map +0 -1
  164. package/dist/esm/internal/protobuf.js +0 -155
  165. package/dist/esm/internal/protobuf.js.map +0 -1
  166. package/dist/esm/internal/tracer.js +0 -297
  167. package/dist/esm/internal/tracer.js.map +0 -1
  168. package/dist/esm/internal/utils.js +0 -23
  169. package/dist/esm/internal/utils.js.map +0 -1
  170. package/dist/esm/package.json +0 -4
  171. package/index/package.json +0 -6
  172. package/src/Otlp.ts +0 -118
  173. package/src/OtlpLogger.ts +0 -263
  174. package/src/OtlpMetrics.ts +0 -575
  175. package/src/OtlpResource.ts +0 -232
  176. package/src/OtlpSerialization.ts +0 -64
  177. package/src/OtlpTracer.ts +0 -352
  178. package/src/internal/otlpExporter.ts +0 -126
  179. package/src/internal/otlpProtobuf.ts +0 -729
  180. package/src/internal/protobuf.ts +0 -219
  181. package/src/internal/tracer.ts +0 -448
  182. package/src/internal/utils.ts +0 -31
  183. /package/dist/{dts/internal → internal}/metrics.d.ts +0 -0
@@ -1,575 +0,0 @@
1
- /**
2
- * @since 1.0.0
3
- */
4
- import type * as Headers from "@effect/platform/Headers"
5
- import type * as HttpClient from "@effect/platform/HttpClient"
6
- import * as Arr from "effect/Array"
7
- import * as Duration from "effect/Duration"
8
- import * as Effect from "effect/Effect"
9
- import * as Layer from "effect/Layer"
10
- import * as Metric from "effect/Metric"
11
- import type * as MetricKey from "effect/MetricKey"
12
- import * as MetricState from "effect/MetricState"
13
- import * as Option from "effect/Option"
14
- import type * as Scope from "effect/Scope"
15
- import * as Exporter from "./internal/otlpExporter.js"
16
- import type { Fixed64, KeyValue } from "./OtlpResource.js"
17
- import * as OtlpResource from "./OtlpResource.js"
18
- import { OtlpSerialization } from "./OtlpSerialization.js"
19
-
20
- /**
21
- * @since 1.0.0
22
- * @category Constructors
23
- */
24
- export const make: (options: {
25
- readonly url: string
26
- readonly resource?: {
27
- readonly serviceName?: string | undefined
28
- readonly serviceVersion?: string | undefined
29
- readonly attributes?: Record<string, unknown>
30
- } | undefined
31
- readonly headers?: Headers.Input | undefined
32
- readonly exportInterval?: Duration.DurationInput | undefined
33
- readonly shutdownTimeout?: Duration.DurationInput | undefined
34
- }) => Effect.Effect<
35
- void,
36
- never,
37
- HttpClient.HttpClient | OtlpSerialization | Scope.Scope
38
- > = Effect.fnUntraced(function*(options) {
39
- const clock = yield* Effect.clock
40
- const startTime = String(clock.unsafeCurrentTimeNanos())
41
-
42
- const resource = yield* OtlpResource.fromConfig(options.resource)
43
- const metricsScope: IInstrumentationScope = {
44
- name: OtlpResource.unsafeServiceName(resource)
45
- }
46
- const serialization = yield* OtlpSerialization
47
-
48
- const snapshot = () => {
49
- const snapshot = Metric.unsafeSnapshot()
50
- const nowNanos = clock.unsafeCurrentTimeNanos()
51
- const nowTime = String(nowNanos)
52
- const metricData: Array<IMetric> = []
53
- const metricDataByName = new Map<string, IMetric>()
54
- const addMetricData = (data: IMetric) => {
55
- metricData.push(data)
56
- metricDataByName.set(data.name, data)
57
- }
58
-
59
- for (let i = 0, len = snapshot.length; i < len; i++) {
60
- const { metricKey, metricState } = snapshot[i]
61
- let unit = "1"
62
- const attributes = Arr.reduce(metricKey.tags, [], (acc: Array<KeyValue>, label) => {
63
- if (label.key === "unit" || label.key === "time_unit") {
64
- unit = label.value
65
- }
66
- acc.push({ key: label.key, value: { stringValue: label.value } })
67
- return acc
68
- })
69
-
70
- if (MetricState.isCounterState(metricState)) {
71
- const dataPoint: INumberDataPoint = {
72
- attributes,
73
- startTimeUnixNano: startTime,
74
- timeUnixNano: nowTime
75
- }
76
- if (typeof metricState.count === "bigint") {
77
- dataPoint.asInt = Number(metricState.count)
78
- } else {
79
- dataPoint.asDouble = metricState.count
80
- }
81
- if (metricDataByName.has(metricKey.name)) {
82
- metricDataByName.get(metricKey.name)!.sum!.dataPoints.push(dataPoint)
83
- } else {
84
- const key = metricKey as MetricKey.MetricKey.Counter<any>
85
- addMetricData({
86
- name: metricKey.name,
87
- description: getOrEmpty(key.description),
88
- unit,
89
- sum: {
90
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
91
- isMonotonic: key.keyType.incremental,
92
- dataPoints: [dataPoint]
93
- }
94
- })
95
- }
96
- } else if (MetricState.isGaugeState(metricState)) {
97
- const dataPoint: INumberDataPoint = {
98
- attributes,
99
- startTimeUnixNano: startTime,
100
- timeUnixNano: nowTime
101
- }
102
- if (typeof metricState.value === "bigint") {
103
- dataPoint.asInt = Number(metricState.value)
104
- } else {
105
- dataPoint.asDouble = metricState.value
106
- }
107
- if (metricDataByName.has(metricKey.name)) {
108
- metricDataByName.get(metricKey.name)!.gauge!.dataPoints.push(dataPoint)
109
- } else {
110
- addMetricData({
111
- name: metricKey.name,
112
- description: getOrEmpty(metricKey.description),
113
- unit,
114
- gauge: {
115
- dataPoints: [dataPoint]
116
- }
117
- })
118
- }
119
- } else if (MetricState.isHistogramState(metricState)) {
120
- const size = metricState.buckets.length
121
- const buckets = {
122
- boundaries: Arr.allocate(size - 1) as Array<number>,
123
- counts: Arr.allocate(size) as Array<number>
124
- }
125
- let i = 0
126
- let prev = 0
127
- for (const [boundary, value] of metricState.buckets) {
128
- if (i < size - 1) {
129
- buckets.boundaries[i] = boundary
130
- }
131
- buckets.counts[i] = value - prev
132
- prev = value
133
- i++
134
- }
135
- const dataPoint: IHistogramDataPoint = {
136
- attributes,
137
- startTimeUnixNano: startTime,
138
- timeUnixNano: nowTime,
139
- count: metricState.count,
140
- min: metricState.min,
141
- max: metricState.max,
142
- sum: metricState.sum,
143
- bucketCounts: buckets.counts,
144
- explicitBounds: buckets.boundaries
145
- }
146
-
147
- if (metricDataByName.has(metricKey.name)) {
148
- metricDataByName.get(metricKey.name)!.histogram!.dataPoints.push(dataPoint)
149
- } else {
150
- addMetricData({
151
- name: metricKey.name,
152
- description: getOrEmpty(metricKey.description),
153
- unit,
154
- histogram: {
155
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
156
- dataPoints: [dataPoint]
157
- }
158
- })
159
- }
160
- } else if (MetricState.isFrequencyState(metricState)) {
161
- const dataPoints: Array<INumberDataPoint> = []
162
- for (const [freqKey, value] of metricState.occurrences) {
163
- dataPoints.push({
164
- attributes: [...attributes, { key: "key", value: { stringValue: freqKey } }],
165
- startTimeUnixNano: startTime,
166
- timeUnixNano: nowTime,
167
- asInt: value
168
- })
169
- }
170
- if (metricDataByName.has(metricKey.name)) {
171
- // eslint-disable-next-line no-restricted-syntax
172
- metricDataByName.get(metricKey.name)!.sum!.dataPoints.push(...dataPoints)
173
- } else {
174
- addMetricData({
175
- name: metricKey.name,
176
- description: getOrEmpty(metricKey.description),
177
- unit,
178
- sum: {
179
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
180
- isMonotonic: true,
181
- dataPoints
182
- }
183
- })
184
- }
185
- } else if (MetricState.isSummaryState(metricState)) {
186
- const dataPoints: Array<INumberDataPoint> = [{
187
- attributes: [...attributes, { key: "quantile", value: { stringValue: "min" } }],
188
- startTimeUnixNano: startTime,
189
- timeUnixNano: nowTime,
190
- asDouble: metricState.min
191
- }]
192
- for (const [quantile, value] of metricState.quantiles) {
193
- dataPoints.push({
194
- attributes: [...attributes, { key: "quantile", value: { stringValue: quantile.toString() } }],
195
- startTimeUnixNano: startTime,
196
- timeUnixNano: nowTime,
197
- asDouble: value._tag === "Some" ? value.value : 0
198
- })
199
- }
200
- dataPoints.push({
201
- attributes: [...attributes, { key: "quantile", value: { stringValue: "max" } }],
202
- startTimeUnixNano: startTime,
203
- timeUnixNano: nowTime,
204
- asDouble: metricState.max
205
- })
206
- const countDataPoint: INumberDataPoint = {
207
- attributes,
208
- startTimeUnixNano: startTime,
209
- timeUnixNano: nowTime,
210
- asInt: metricState.count
211
- }
212
- const sumDataPoint: INumberDataPoint = {
213
- attributes,
214
- startTimeUnixNano: startTime,
215
- timeUnixNano: nowTime,
216
- asDouble: metricState.sum
217
- }
218
-
219
- if (metricDataByName.has(`${metricKey.name}_quantiles`)) {
220
- // eslint-disable-next-line no-restricted-syntax
221
- metricDataByName.get(`${metricKey.name}_quantiles`)!.sum!.dataPoints.push(...dataPoints)
222
- metricDataByName.get(`${metricKey.name}_count`)!.sum!.dataPoints.push(countDataPoint)
223
- metricDataByName.get(`${metricKey.name}_sum`)!.sum!.dataPoints.push(sumDataPoint)
224
- } else {
225
- addMetricData({
226
- name: `${metricKey.name}_quantiles`,
227
- description: getOrEmpty(metricKey.description),
228
- unit,
229
- sum: {
230
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
231
- isMonotonic: false,
232
- dataPoints
233
- }
234
- })
235
- addMetricData({
236
- name: `${metricKey.name}_count`,
237
- description: getOrEmpty(metricKey.description),
238
- unit: "1",
239
- sum: {
240
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
241
- isMonotonic: true,
242
- dataPoints: [countDataPoint]
243
- }
244
- })
245
- addMetricData({
246
- name: `${metricKey.name}_sum`,
247
- description: getOrEmpty(metricKey.description),
248
- unit: "1",
249
- sum: {
250
- aggregationTemporality: EAggregationTemporality.AGGREGATION_TEMPORALITY_CUMULATIVE,
251
- isMonotonic: true,
252
- dataPoints: [sumDataPoint]
253
- }
254
- })
255
- }
256
- }
257
- }
258
-
259
- const body: IExportMetricsServiceRequest = {
260
- resourceMetrics: [{
261
- resource,
262
- scopeMetrics: [{
263
- scope: metricsScope,
264
- metrics: metricData
265
- }]
266
- }]
267
- }
268
-
269
- return serialization.metrics(body)
270
- }
271
-
272
- yield* Exporter.make({
273
- label: "OtlpMetrics",
274
- url: options.url,
275
- headers: options.headers,
276
- maxBatchSize: "disabled",
277
- exportInterval: options.exportInterval ?? Duration.seconds(10),
278
- body: snapshot,
279
- shutdownTimeout: options.shutdownTimeout ?? Duration.seconds(3)
280
- })
281
- })
282
-
283
- /**
284
- * @since 1.0.0
285
- * @category Layers
286
- */
287
- export const layer = (options: {
288
- readonly url: string
289
- readonly resource?: {
290
- readonly serviceName?: string | undefined
291
- readonly serviceVersion?: string | undefined
292
- readonly attributes?: Record<string, unknown>
293
- } | undefined
294
- readonly headers?: Headers.Input | undefined
295
- readonly exportInterval?: Duration.DurationInput | undefined
296
- readonly shutdownTimeout?: Duration.DurationInput | undefined
297
- }): Layer.Layer<never, never, HttpClient.HttpClient | OtlpSerialization> => Layer.scopedDiscard(make(options))
298
-
299
- // internal
300
-
301
- const getOrEmpty = Option.getOrElse(() => "")
302
-
303
- /** Properties of an InstrumentationScope. */
304
- interface IInstrumentationScope {
305
- /** InstrumentationScope name */
306
- name: string
307
- /** InstrumentationScope version */
308
- version?: string
309
- /** InstrumentationScope attributes */
310
- attributes?: Array<KeyValue>
311
- /** InstrumentationScope droppedAttributesCount */
312
- droppedAttributesCount?: number
313
- }
314
-
315
- /** Properties of an ExportMetricsServiceRequest. */
316
- interface IExportMetricsServiceRequest {
317
- /** ExportMetricsServiceRequest resourceMetrics */
318
- resourceMetrics: Array<IResourceMetrics>
319
- }
320
- /** Properties of a ResourceMetrics. */
321
- interface IResourceMetrics {
322
- /** ResourceMetrics resource */
323
- resource?: OtlpResource.Resource
324
- /** ResourceMetrics scopeMetrics */
325
- scopeMetrics: Array<IScopeMetrics>
326
- /** ResourceMetrics schemaUrl */
327
- schemaUrl?: string
328
- }
329
- /** Properties of an IScopeMetrics. */
330
- interface IScopeMetrics {
331
- /** ScopeMetrics scope */
332
- scope?: IInstrumentationScope
333
- /** ScopeMetrics metrics */
334
- metrics: Array<IMetric>
335
- /** ScopeMetrics schemaUrl */
336
- schemaUrl?: string
337
- }
338
- /** Properties of a Metric. */
339
- interface IMetric {
340
- /** Metric name */
341
- name: string
342
- /** Metric description */
343
- description?: string
344
- /** Metric unit */
345
- unit?: string
346
- /** Metric gauge */
347
- gauge?: IGauge
348
- /** Metric sum */
349
- sum?: ISum
350
- /** Metric histogram */
351
- histogram?: IHistogram
352
- /** Metric exponentialHistogram */
353
- exponentialHistogram?: IExponentialHistogram
354
- /** Metric summary */
355
- summary?: ISummary
356
- }
357
- /** Properties of a Gauge. */
358
- interface IGauge {
359
- /** Gauge dataPoints */
360
- dataPoints: Array<INumberDataPoint>
361
- }
362
- /** Properties of a Sum. */
363
- interface ISum {
364
- /** Sum dataPoints */
365
- dataPoints: Array<INumberDataPoint>
366
- /** Sum aggregationTemporality */
367
- aggregationTemporality: EAggregationTemporality
368
- /** Sum isMonotonic */
369
- isMonotonic: boolean
370
- }
371
- /** Properties of a Histogram. */
372
- interface IHistogram {
373
- /** Histogram dataPoints */
374
- dataPoints: Array<IHistogramDataPoint>
375
- /** Histogram aggregationTemporality */
376
- aggregationTemporality?: EAggregationTemporality
377
- }
378
- /** Properties of an ExponentialHistogram. */
379
- interface IExponentialHistogram {
380
- /** ExponentialHistogram dataPoints */
381
- dataPoints: Array<IExponentialHistogramDataPoint>
382
- /** ExponentialHistogram aggregationTemporality */
383
- aggregationTemporality?: EAggregationTemporality
384
- }
385
- /** Properties of a Summary. */
386
- interface ISummary {
387
- /** Summary dataPoints */
388
- dataPoints: Array<ISummaryDataPoint>
389
- }
390
- /** Properties of a NumberDataPoint. */
391
- interface INumberDataPoint {
392
- /** NumberDataPoint attributes */
393
- attributes: Array<KeyValue>
394
- /** NumberDataPoint startTimeUnixNano */
395
- startTimeUnixNano?: Fixed64
396
- /** NumberDataPoint timeUnixNano */
397
- timeUnixNano?: Fixed64
398
- /** NumberDataPoint asDouble */
399
- asDouble?: number | null
400
- /** NumberDataPoint asInt */
401
- asInt?: number
402
- /** NumberDataPoint exemplars */
403
- exemplars?: Array<IExemplar>
404
- /** NumberDataPoint flags */
405
- flags?: number
406
- }
407
- /** Properties of a HistogramDataPoint. */
408
- interface IHistogramDataPoint {
409
- /** HistogramDataPoint attributes */
410
- attributes?: Array<KeyValue>
411
- /** HistogramDataPoint startTimeUnixNano */
412
- startTimeUnixNano?: Fixed64
413
- /** HistogramDataPoint timeUnixNano */
414
- timeUnixNano?: Fixed64
415
- /** HistogramDataPoint count */
416
- count?: number
417
- /** HistogramDataPoint sum */
418
- sum?: number
419
- /** HistogramDataPoint bucketCounts */
420
- bucketCounts?: Array<number>
421
- /** HistogramDataPoint explicitBounds */
422
- explicitBounds?: Array<number>
423
- /** HistogramDataPoint exemplars */
424
- exemplars?: Array<IExemplar>
425
- /** HistogramDataPoint flags */
426
- flags?: number
427
- /** HistogramDataPoint min */
428
- min?: number
429
- /** HistogramDataPoint max */
430
- max?: number
431
- }
432
- /** Properties of an ExponentialHistogramDataPoint. */
433
- interface IExponentialHistogramDataPoint {
434
- /** ExponentialHistogramDataPoint attributes */
435
- attributes?: Array<KeyValue>
436
- /** ExponentialHistogramDataPoint startTimeUnixNano */
437
- startTimeUnixNano?: Fixed64
438
- /** ExponentialHistogramDataPoint timeUnixNano */
439
- timeUnixNano?: Fixed64
440
- /** ExponentialHistogramDataPoint count */
441
- count?: number
442
- /** ExponentialHistogramDataPoint sum */
443
- sum?: number
444
- /** ExponentialHistogramDataPoint scale */
445
- scale?: number
446
- /** ExponentialHistogramDataPoint zeroCount */
447
- zeroCount?: number
448
- /** ExponentialHistogramDataPoint positive */
449
- positive?: IBuckets
450
- /** ExponentialHistogramDataPoint negative */
451
- negative?: IBuckets
452
- /** ExponentialHistogramDataPoint flags */
453
- flags?: number
454
- /** ExponentialHistogramDataPoint exemplars */
455
- exemplars?: Array<IExemplar>
456
- /** ExponentialHistogramDataPoint min */
457
- min?: number
458
- /** ExponentialHistogramDataPoint max */
459
- max?: number
460
- }
461
- /** Properties of a SummaryDataPoint. */
462
- interface ISummaryDataPoint {
463
- /** SummaryDataPoint attributes */
464
- attributes?: Array<KeyValue>
465
- /** SummaryDataPoint startTimeUnixNano */
466
- startTimeUnixNano?: number
467
- /** SummaryDataPoint timeUnixNano */
468
- timeUnixNano?: string
469
- /** SummaryDataPoint count */
470
- count?: number
471
- /** SummaryDataPoint sum */
472
- sum?: number
473
- /** SummaryDataPoint quantileValues */
474
- quantileValues?: Array<IValueAtQuantile>
475
- /** SummaryDataPoint flags */
476
- flags?: number
477
- }
478
- /** Properties of a ValueAtQuantile. */
479
- interface IValueAtQuantile {
480
- /** ValueAtQuantile quantile */
481
- quantile?: number
482
- /** ValueAtQuantile value */
483
- value?: number
484
- }
485
- /** Properties of a Buckets. */
486
- interface IBuckets {
487
- /** Buckets offset */
488
- offset?: number
489
- /** Buckets bucketCounts */
490
- bucketCounts?: Array<number>
491
- }
492
- /** Properties of an Exemplar. */
493
- interface IExemplar {
494
- /** Exemplar filteredAttributes */
495
- filteredAttributes?: Array<KeyValue>
496
- /** Exemplar timeUnixNano */
497
- timeUnixNano?: string
498
- /** Exemplar asDouble */
499
- asDouble?: number
500
- /** Exemplar asInt */
501
- asInt?: number
502
- /** Exemplar spanId */
503
- spanId?: string | Uint8Array
504
- /** Exemplar traceId */
505
- traceId?: string | Uint8Array
506
- }
507
- /**
508
- * AggregationTemporality defines how a metric aggregator reports aggregated
509
- * values. It describes how those values relate to the time interval over
510
- * which they are aggregated.
511
- */
512
- const enum EAggregationTemporality {
513
- AGGREGATION_TEMPORALITY_UNSPECIFIED = 0,
514
- /** DELTA is an AggregationTemporality for a metric aggregator which reports
515
- changes since last report time. Successive metrics contain aggregation of
516
- values from continuous and non-overlapping intervals.
517
-
518
- The values for a DELTA metric are based only on the time interval
519
- associated with one measurement cycle. There is no dependency on
520
- previous measurements like is the case for CUMULATIVE metrics.
521
-
522
- For example, consider a system measuring the number of requests that
523
- it receives and reports the sum of these requests every second as a
524
- DELTA metric:
525
-
526
- 1. The system starts receiving at time=t_0.
527
- 2. A request is received, the system measures 1 request.
528
- 3. A request is received, the system measures 1 request.
529
- 4. A request is received, the system measures 1 request.
530
- 5. The 1 second collection cycle ends. A metric is exported for the
531
- number of requests received over the interval of time t_0 to
532
- t_0+1 with a value of 3.
533
- 6. A request is received, the system measures 1 request.
534
- 7. A request is received, the system measures 1 request.
535
- 8. The 1 second collection cycle ends. A metric is exported for the
536
- number of requests received over the interval of time t_0+1 to
537
- t_0+2 with a value of 2. */
538
- AGGREGATION_TEMPORALITY_DELTA = 1,
539
- /** CUMULATIVE is an AggregationTemporality for a metric aggregator which
540
- reports changes since a fixed start time. This means that current values
541
- of a CUMULATIVE metric depend on all previous measurements since the
542
- start time. Because of this, the sender is required to retain this state
543
- in some form. If this state is lost or invalidated, the CUMULATIVE metric
544
- values MUST be reset and a new fixed start time following the last
545
- reported measurement time sent MUST be used.
546
-
547
- For example, consider a system measuring the number of requests that
548
- it receives and reports the sum of these requests every second as a
549
- CUMULATIVE metric:
550
-
551
- 1. The system starts receiving at time=t_0.
552
- 2. A request is received, the system measures 1 request.
553
- 3. A request is received, the system measures 1 request.
554
- 4. A request is received, the system measures 1 request.
555
- 5. The 1 second collection cycle ends. A metric is exported for the
556
- number of requests received over the interval of time t_0 to
557
- t_0+1 with a value of 3.
558
- 6. A request is received, the system measures 1 request.
559
- 7. A request is received, the system measures 1 request.
560
- 8. The 1 second collection cycle ends. A metric is exported for the
561
- number of requests received over the interval of time t_0 to
562
- t_0+2 with a value of 5.
563
- 9. The system experiences a fault and loses state.
564
- 10. The system recovers and resumes receiving at time=t_1.
565
- 11. A request is received, the system measures 1 request.
566
- 12. The 1 second collection cycle ends. A metric is exported for the
567
- number of requests received over the interval of time t_1 to
568
- t_0+1 with a value of 1.
569
-
570
- Note: Even though, when reporting changes since last report time, using
571
- CUMULATIVE is valid, it is not recommended. This may cause problems for
572
- systems that do not use start_time to determine when the aggregation
573
- value was reset (e.g. Prometheus). */
574
- AGGREGATION_TEMPORALITY_CUMULATIVE = 2
575
- }