@effect/opentelemetry 0.60.0 → 4.0.0-beta.0

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