generated_metrics_test.go 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. // Code generated by mdatagen. DO NOT EDIT.
  2. package metadata
  3. import (
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "go.opentelemetry.io/collector/pdata/pcommon"
  7. "go.opentelemetry.io/collector/pdata/pmetric"
  8. "go.opentelemetry.io/collector/receiver/receivertest"
  9. "go.uber.org/zap"
  10. "go.uber.org/zap/zaptest/observer"
  11. )
  12. type testConfigCollection int
  13. const (
  14. testSetDefault testConfigCollection = iota
  15. testSetAll
  16. testSetNone
  17. )
  18. func TestMetricsBuilder(t *testing.T) {
  19. tests := []struct {
  20. name string
  21. configSet testConfigCollection
  22. }{
  23. {
  24. name: "default",
  25. configSet: testSetDefault,
  26. },
  27. {
  28. name: "all_set",
  29. configSet: testSetAll,
  30. },
  31. {
  32. name: "none_set",
  33. configSet: testSetNone,
  34. },
  35. }
  36. for _, test := range tests {
  37. t.Run(test.name, func(t *testing.T) {
  38. start := pcommon.Timestamp(1_000_000_000)
  39. ts := pcommon.Timestamp(1_000_001_000)
  40. observedZapCore, observedLogs := observer.New(zap.WarnLevel)
  41. settings := receivertest.NewNopCreateSettings()
  42. settings.Logger = zap.New(observedZapCore)
  43. mb := NewMetricsBuilder(loadMetricsBuilderConfig(t, test.name), settings, WithStartTime(start))
  44. expectedWarnings := 0
  45. assert.Equal(t, expectedWarnings, observedLogs.Len())
  46. defaultMetricsCount := 0
  47. allMetricsCount := 0
  48. allMetricsCount++
  49. mb.RecordOracledbConsistentGetsDataPoint(ts, "1")
  50. defaultMetricsCount++
  51. allMetricsCount++
  52. mb.RecordOracledbCPUTimeDataPoint(ts, 1)
  53. allMetricsCount++
  54. mb.RecordOracledbDbBlockGetsDataPoint(ts, "1")
  55. defaultMetricsCount++
  56. allMetricsCount++
  57. mb.RecordOracledbDmlLocksLimitDataPoint(ts, "1")
  58. defaultMetricsCount++
  59. allMetricsCount++
  60. mb.RecordOracledbDmlLocksUsageDataPoint(ts, "1")
  61. defaultMetricsCount++
  62. allMetricsCount++
  63. mb.RecordOracledbEnqueueDeadlocksDataPoint(ts, "1")
  64. defaultMetricsCount++
  65. allMetricsCount++
  66. mb.RecordOracledbEnqueueLocksLimitDataPoint(ts, "1")
  67. defaultMetricsCount++
  68. allMetricsCount++
  69. mb.RecordOracledbEnqueueLocksUsageDataPoint(ts, "1")
  70. defaultMetricsCount++
  71. allMetricsCount++
  72. mb.RecordOracledbEnqueueResourcesLimitDataPoint(ts, "1")
  73. defaultMetricsCount++
  74. allMetricsCount++
  75. mb.RecordOracledbEnqueueResourcesUsageDataPoint(ts, "1")
  76. defaultMetricsCount++
  77. allMetricsCount++
  78. mb.RecordOracledbExchangeDeadlocksDataPoint(ts, "1")
  79. defaultMetricsCount++
  80. allMetricsCount++
  81. mb.RecordOracledbExecutionsDataPoint(ts, "1")
  82. defaultMetricsCount++
  83. allMetricsCount++
  84. mb.RecordOracledbHardParsesDataPoint(ts, "1")
  85. defaultMetricsCount++
  86. allMetricsCount++
  87. mb.RecordOracledbLogicalReadsDataPoint(ts, "1")
  88. defaultMetricsCount++
  89. allMetricsCount++
  90. mb.RecordOracledbParseCallsDataPoint(ts, "1")
  91. defaultMetricsCount++
  92. allMetricsCount++
  93. mb.RecordOracledbPgaMemoryDataPoint(ts, "1")
  94. defaultMetricsCount++
  95. allMetricsCount++
  96. mb.RecordOracledbPhysicalReadsDataPoint(ts, "1")
  97. defaultMetricsCount++
  98. allMetricsCount++
  99. mb.RecordOracledbProcessesLimitDataPoint(ts, "1")
  100. defaultMetricsCount++
  101. allMetricsCount++
  102. mb.RecordOracledbProcessesUsageDataPoint(ts, "1")
  103. defaultMetricsCount++
  104. allMetricsCount++
  105. mb.RecordOracledbSessionsLimitDataPoint(ts, "1")
  106. defaultMetricsCount++
  107. allMetricsCount++
  108. mb.RecordOracledbSessionsUsageDataPoint(ts, "1", "session_type-val", "session_status-val")
  109. defaultMetricsCount++
  110. allMetricsCount++
  111. mb.RecordOracledbTablespaceSizeLimitDataPoint(ts, 1, "tablespace_name-val")
  112. defaultMetricsCount++
  113. allMetricsCount++
  114. mb.RecordOracledbTablespaceSizeUsageDataPoint(ts, "1", "tablespace_name-val")
  115. defaultMetricsCount++
  116. allMetricsCount++
  117. mb.RecordOracledbTransactionsLimitDataPoint(ts, "1")
  118. defaultMetricsCount++
  119. allMetricsCount++
  120. mb.RecordOracledbTransactionsUsageDataPoint(ts, "1")
  121. defaultMetricsCount++
  122. allMetricsCount++
  123. mb.RecordOracledbUserCommitsDataPoint(ts, "1")
  124. defaultMetricsCount++
  125. allMetricsCount++
  126. mb.RecordOracledbUserRollbacksDataPoint(ts, "1")
  127. rb := mb.NewResourceBuilder()
  128. rb.SetOracledbInstanceName("oracledb.instance.name-val")
  129. res := rb.Emit()
  130. metrics := mb.Emit(WithResource(res))
  131. if test.configSet == testSetNone {
  132. assert.Equal(t, 0, metrics.ResourceMetrics().Len())
  133. return
  134. }
  135. assert.Equal(t, 1, metrics.ResourceMetrics().Len())
  136. rm := metrics.ResourceMetrics().At(0)
  137. assert.Equal(t, res, rm.Resource())
  138. assert.Equal(t, 1, rm.ScopeMetrics().Len())
  139. ms := rm.ScopeMetrics().At(0).Metrics()
  140. if test.configSet == testSetDefault {
  141. assert.Equal(t, defaultMetricsCount, ms.Len())
  142. }
  143. if test.configSet == testSetAll {
  144. assert.Equal(t, allMetricsCount, ms.Len())
  145. }
  146. validatedMetrics := make(map[string]bool)
  147. for i := 0; i < ms.Len(); i++ {
  148. switch ms.At(i).Name() {
  149. case "oracledb.consistent_gets":
  150. assert.False(t, validatedMetrics["oracledb.consistent_gets"], "Found a duplicate in the metrics slice: oracledb.consistent_gets")
  151. validatedMetrics["oracledb.consistent_gets"] = true
  152. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  153. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  154. assert.Equal(t, "Number of times a consistent read was requested for a block from the buffer cache.", ms.At(i).Description())
  155. assert.Equal(t, "{gets}", ms.At(i).Unit())
  156. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  157. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  158. dp := ms.At(i).Sum().DataPoints().At(0)
  159. assert.Equal(t, start, dp.StartTimestamp())
  160. assert.Equal(t, ts, dp.Timestamp())
  161. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  162. assert.Equal(t, int64(1), dp.IntValue())
  163. case "oracledb.cpu_time":
  164. assert.False(t, validatedMetrics["oracledb.cpu_time"], "Found a duplicate in the metrics slice: oracledb.cpu_time")
  165. validatedMetrics["oracledb.cpu_time"] = true
  166. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  167. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  168. assert.Equal(t, "Cumulative CPU time, in seconds", ms.At(i).Description())
  169. assert.Equal(t, "s", ms.At(i).Unit())
  170. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  171. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  172. dp := ms.At(i).Sum().DataPoints().At(0)
  173. assert.Equal(t, start, dp.StartTimestamp())
  174. assert.Equal(t, ts, dp.Timestamp())
  175. assert.Equal(t, pmetric.NumberDataPointValueTypeDouble, dp.ValueType())
  176. assert.Equal(t, float64(1), dp.DoubleValue())
  177. case "oracledb.db_block_gets":
  178. assert.False(t, validatedMetrics["oracledb.db_block_gets"], "Found a duplicate in the metrics slice: oracledb.db_block_gets")
  179. validatedMetrics["oracledb.db_block_gets"] = true
  180. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  181. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  182. assert.Equal(t, "Number of times a current block was requested from the buffer cache.", ms.At(i).Description())
  183. assert.Equal(t, "{gets}", ms.At(i).Unit())
  184. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  185. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  186. dp := ms.At(i).Sum().DataPoints().At(0)
  187. assert.Equal(t, start, dp.StartTimestamp())
  188. assert.Equal(t, ts, dp.Timestamp())
  189. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  190. assert.Equal(t, int64(1), dp.IntValue())
  191. case "oracledb.dml_locks.limit":
  192. assert.False(t, validatedMetrics["oracledb.dml_locks.limit"], "Found a duplicate in the metrics slice: oracledb.dml_locks.limit")
  193. validatedMetrics["oracledb.dml_locks.limit"] = true
  194. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  195. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  196. assert.Equal(t, "Maximum limit of active DML (Data Manipulation Language) locks, -1 if unlimited.", ms.At(i).Description())
  197. assert.Equal(t, "{locks}", ms.At(i).Unit())
  198. dp := ms.At(i).Gauge().DataPoints().At(0)
  199. assert.Equal(t, start, dp.StartTimestamp())
  200. assert.Equal(t, ts, dp.Timestamp())
  201. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  202. assert.Equal(t, int64(1), dp.IntValue())
  203. case "oracledb.dml_locks.usage":
  204. assert.False(t, validatedMetrics["oracledb.dml_locks.usage"], "Found a duplicate in the metrics slice: oracledb.dml_locks.usage")
  205. validatedMetrics["oracledb.dml_locks.usage"] = true
  206. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  207. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  208. assert.Equal(t, "Current count of active DML (Data Manipulation Language) locks.", ms.At(i).Description())
  209. assert.Equal(t, "{locks}", ms.At(i).Unit())
  210. dp := ms.At(i).Gauge().DataPoints().At(0)
  211. assert.Equal(t, start, dp.StartTimestamp())
  212. assert.Equal(t, ts, dp.Timestamp())
  213. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  214. assert.Equal(t, int64(1), dp.IntValue())
  215. case "oracledb.enqueue_deadlocks":
  216. assert.False(t, validatedMetrics["oracledb.enqueue_deadlocks"], "Found a duplicate in the metrics slice: oracledb.enqueue_deadlocks")
  217. validatedMetrics["oracledb.enqueue_deadlocks"] = true
  218. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  219. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  220. assert.Equal(t, "Total number of deadlocks between table or row locks in different sessions.", ms.At(i).Description())
  221. assert.Equal(t, "{deadlocks}", ms.At(i).Unit())
  222. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  223. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  224. dp := ms.At(i).Sum().DataPoints().At(0)
  225. assert.Equal(t, start, dp.StartTimestamp())
  226. assert.Equal(t, ts, dp.Timestamp())
  227. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  228. assert.Equal(t, int64(1), dp.IntValue())
  229. case "oracledb.enqueue_locks.limit":
  230. assert.False(t, validatedMetrics["oracledb.enqueue_locks.limit"], "Found a duplicate in the metrics slice: oracledb.enqueue_locks.limit")
  231. validatedMetrics["oracledb.enqueue_locks.limit"] = true
  232. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  233. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  234. assert.Equal(t, "Maximum limit of active enqueue locks, -1 if unlimited.", ms.At(i).Description())
  235. assert.Equal(t, "{locks}", ms.At(i).Unit())
  236. dp := ms.At(i).Gauge().DataPoints().At(0)
  237. assert.Equal(t, start, dp.StartTimestamp())
  238. assert.Equal(t, ts, dp.Timestamp())
  239. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  240. assert.Equal(t, int64(1), dp.IntValue())
  241. case "oracledb.enqueue_locks.usage":
  242. assert.False(t, validatedMetrics["oracledb.enqueue_locks.usage"], "Found a duplicate in the metrics slice: oracledb.enqueue_locks.usage")
  243. validatedMetrics["oracledb.enqueue_locks.usage"] = true
  244. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  245. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  246. assert.Equal(t, "Current count of active enqueue locks.", ms.At(i).Description())
  247. assert.Equal(t, "{locks}", ms.At(i).Unit())
  248. dp := ms.At(i).Gauge().DataPoints().At(0)
  249. assert.Equal(t, start, dp.StartTimestamp())
  250. assert.Equal(t, ts, dp.Timestamp())
  251. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  252. assert.Equal(t, int64(1), dp.IntValue())
  253. case "oracledb.enqueue_resources.limit":
  254. assert.False(t, validatedMetrics["oracledb.enqueue_resources.limit"], "Found a duplicate in the metrics slice: oracledb.enqueue_resources.limit")
  255. validatedMetrics["oracledb.enqueue_resources.limit"] = true
  256. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  257. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  258. assert.Equal(t, "Maximum limit of active enqueue resources, -1 if unlimited.", ms.At(i).Description())
  259. assert.Equal(t, "{resources}", ms.At(i).Unit())
  260. dp := ms.At(i).Gauge().DataPoints().At(0)
  261. assert.Equal(t, start, dp.StartTimestamp())
  262. assert.Equal(t, ts, dp.Timestamp())
  263. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  264. assert.Equal(t, int64(1), dp.IntValue())
  265. case "oracledb.enqueue_resources.usage":
  266. assert.False(t, validatedMetrics["oracledb.enqueue_resources.usage"], "Found a duplicate in the metrics slice: oracledb.enqueue_resources.usage")
  267. validatedMetrics["oracledb.enqueue_resources.usage"] = true
  268. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  269. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  270. assert.Equal(t, "Current count of active enqueue resources.", ms.At(i).Description())
  271. assert.Equal(t, "{resources}", ms.At(i).Unit())
  272. dp := ms.At(i).Gauge().DataPoints().At(0)
  273. assert.Equal(t, start, dp.StartTimestamp())
  274. assert.Equal(t, ts, dp.Timestamp())
  275. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  276. assert.Equal(t, int64(1), dp.IntValue())
  277. case "oracledb.exchange_deadlocks":
  278. assert.False(t, validatedMetrics["oracledb.exchange_deadlocks"], "Found a duplicate in the metrics slice: oracledb.exchange_deadlocks")
  279. validatedMetrics["oracledb.exchange_deadlocks"] = true
  280. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  281. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  282. assert.Equal(t, "Number of times that a process detected a potential deadlock when exchanging two buffers and raised an internal, restartable error. Index scans are the only operations that perform exchanges.", ms.At(i).Description())
  283. assert.Equal(t, "{deadlocks}", ms.At(i).Unit())
  284. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  285. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  286. dp := ms.At(i).Sum().DataPoints().At(0)
  287. assert.Equal(t, start, dp.StartTimestamp())
  288. assert.Equal(t, ts, dp.Timestamp())
  289. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  290. assert.Equal(t, int64(1), dp.IntValue())
  291. case "oracledb.executions":
  292. assert.False(t, validatedMetrics["oracledb.executions"], "Found a duplicate in the metrics slice: oracledb.executions")
  293. validatedMetrics["oracledb.executions"] = true
  294. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  295. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  296. assert.Equal(t, "Total number of calls (user and recursive) that executed SQL statements", ms.At(i).Description())
  297. assert.Equal(t, "{executions}", ms.At(i).Unit())
  298. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  299. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  300. dp := ms.At(i).Sum().DataPoints().At(0)
  301. assert.Equal(t, start, dp.StartTimestamp())
  302. assert.Equal(t, ts, dp.Timestamp())
  303. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  304. assert.Equal(t, int64(1), dp.IntValue())
  305. case "oracledb.hard_parses":
  306. assert.False(t, validatedMetrics["oracledb.hard_parses"], "Found a duplicate in the metrics slice: oracledb.hard_parses")
  307. validatedMetrics["oracledb.hard_parses"] = true
  308. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  309. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  310. assert.Equal(t, "Number of hard parses", ms.At(i).Description())
  311. assert.Equal(t, "{parses}", ms.At(i).Unit())
  312. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  313. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  314. dp := ms.At(i).Sum().DataPoints().At(0)
  315. assert.Equal(t, start, dp.StartTimestamp())
  316. assert.Equal(t, ts, dp.Timestamp())
  317. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  318. assert.Equal(t, int64(1), dp.IntValue())
  319. case "oracledb.logical_reads":
  320. assert.False(t, validatedMetrics["oracledb.logical_reads"], "Found a duplicate in the metrics slice: oracledb.logical_reads")
  321. validatedMetrics["oracledb.logical_reads"] = true
  322. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  323. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  324. assert.Equal(t, "Number of logical reads", ms.At(i).Description())
  325. assert.Equal(t, "{reads}", ms.At(i).Unit())
  326. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  327. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  328. dp := ms.At(i).Sum().DataPoints().At(0)
  329. assert.Equal(t, start, dp.StartTimestamp())
  330. assert.Equal(t, ts, dp.Timestamp())
  331. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  332. assert.Equal(t, int64(1), dp.IntValue())
  333. case "oracledb.parse_calls":
  334. assert.False(t, validatedMetrics["oracledb.parse_calls"], "Found a duplicate in the metrics slice: oracledb.parse_calls")
  335. validatedMetrics["oracledb.parse_calls"] = true
  336. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  337. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  338. assert.Equal(t, "Total number of parse calls.", ms.At(i).Description())
  339. assert.Equal(t, "{parses}", ms.At(i).Unit())
  340. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  341. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  342. dp := ms.At(i).Sum().DataPoints().At(0)
  343. assert.Equal(t, start, dp.StartTimestamp())
  344. assert.Equal(t, ts, dp.Timestamp())
  345. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  346. assert.Equal(t, int64(1), dp.IntValue())
  347. case "oracledb.pga_memory":
  348. assert.False(t, validatedMetrics["oracledb.pga_memory"], "Found a duplicate in the metrics slice: oracledb.pga_memory")
  349. validatedMetrics["oracledb.pga_memory"] = true
  350. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  351. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  352. assert.Equal(t, "Session PGA (Program Global Area) memory", ms.At(i).Description())
  353. assert.Equal(t, "By", ms.At(i).Unit())
  354. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  355. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  356. dp := ms.At(i).Sum().DataPoints().At(0)
  357. assert.Equal(t, start, dp.StartTimestamp())
  358. assert.Equal(t, ts, dp.Timestamp())
  359. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  360. assert.Equal(t, int64(1), dp.IntValue())
  361. case "oracledb.physical_reads":
  362. assert.False(t, validatedMetrics["oracledb.physical_reads"], "Found a duplicate in the metrics slice: oracledb.physical_reads")
  363. validatedMetrics["oracledb.physical_reads"] = true
  364. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  365. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  366. assert.Equal(t, "Number of physical reads", ms.At(i).Description())
  367. assert.Equal(t, "{reads}", ms.At(i).Unit())
  368. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  369. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  370. dp := ms.At(i).Sum().DataPoints().At(0)
  371. assert.Equal(t, start, dp.StartTimestamp())
  372. assert.Equal(t, ts, dp.Timestamp())
  373. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  374. assert.Equal(t, int64(1), dp.IntValue())
  375. case "oracledb.processes.limit":
  376. assert.False(t, validatedMetrics["oracledb.processes.limit"], "Found a duplicate in the metrics slice: oracledb.processes.limit")
  377. validatedMetrics["oracledb.processes.limit"] = true
  378. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  379. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  380. assert.Equal(t, "Maximum limit of active processes, -1 if unlimited.", ms.At(i).Description())
  381. assert.Equal(t, "{processes}", ms.At(i).Unit())
  382. dp := ms.At(i).Gauge().DataPoints().At(0)
  383. assert.Equal(t, start, dp.StartTimestamp())
  384. assert.Equal(t, ts, dp.Timestamp())
  385. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  386. assert.Equal(t, int64(1), dp.IntValue())
  387. case "oracledb.processes.usage":
  388. assert.False(t, validatedMetrics["oracledb.processes.usage"], "Found a duplicate in the metrics slice: oracledb.processes.usage")
  389. validatedMetrics["oracledb.processes.usage"] = true
  390. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  391. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  392. assert.Equal(t, "Current count of active processes.", ms.At(i).Description())
  393. assert.Equal(t, "{processes}", ms.At(i).Unit())
  394. dp := ms.At(i).Gauge().DataPoints().At(0)
  395. assert.Equal(t, start, dp.StartTimestamp())
  396. assert.Equal(t, ts, dp.Timestamp())
  397. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  398. assert.Equal(t, int64(1), dp.IntValue())
  399. case "oracledb.sessions.limit":
  400. assert.False(t, validatedMetrics["oracledb.sessions.limit"], "Found a duplicate in the metrics slice: oracledb.sessions.limit")
  401. validatedMetrics["oracledb.sessions.limit"] = true
  402. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  403. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  404. assert.Equal(t, "Maximum limit of active sessions, -1 if unlimited.", ms.At(i).Description())
  405. assert.Equal(t, "{sessions}", ms.At(i).Unit())
  406. dp := ms.At(i).Gauge().DataPoints().At(0)
  407. assert.Equal(t, start, dp.StartTimestamp())
  408. assert.Equal(t, ts, dp.Timestamp())
  409. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  410. assert.Equal(t, int64(1), dp.IntValue())
  411. case "oracledb.sessions.usage":
  412. assert.False(t, validatedMetrics["oracledb.sessions.usage"], "Found a duplicate in the metrics slice: oracledb.sessions.usage")
  413. validatedMetrics["oracledb.sessions.usage"] = true
  414. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  415. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  416. assert.Equal(t, "Count of active sessions.", ms.At(i).Description())
  417. assert.Equal(t, "{sessions}", ms.At(i).Unit())
  418. dp := ms.At(i).Gauge().DataPoints().At(0)
  419. assert.Equal(t, start, dp.StartTimestamp())
  420. assert.Equal(t, ts, dp.Timestamp())
  421. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  422. assert.Equal(t, int64(1), dp.IntValue())
  423. attrVal, ok := dp.Attributes().Get("session_type")
  424. assert.True(t, ok)
  425. assert.EqualValues(t, "session_type-val", attrVal.Str())
  426. attrVal, ok = dp.Attributes().Get("session_status")
  427. assert.True(t, ok)
  428. assert.EqualValues(t, "session_status-val", attrVal.Str())
  429. case "oracledb.tablespace_size.limit":
  430. assert.False(t, validatedMetrics["oracledb.tablespace_size.limit"], "Found a duplicate in the metrics slice: oracledb.tablespace_size.limit")
  431. validatedMetrics["oracledb.tablespace_size.limit"] = true
  432. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  433. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  434. assert.Equal(t, "Maximum size of tablespace in bytes, -1 if unlimited.", ms.At(i).Description())
  435. assert.Equal(t, "By", ms.At(i).Unit())
  436. dp := ms.At(i).Gauge().DataPoints().At(0)
  437. assert.Equal(t, start, dp.StartTimestamp())
  438. assert.Equal(t, ts, dp.Timestamp())
  439. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  440. assert.Equal(t, int64(1), dp.IntValue())
  441. attrVal, ok := dp.Attributes().Get("tablespace_name")
  442. assert.True(t, ok)
  443. assert.EqualValues(t, "tablespace_name-val", attrVal.Str())
  444. case "oracledb.tablespace_size.usage":
  445. assert.False(t, validatedMetrics["oracledb.tablespace_size.usage"], "Found a duplicate in the metrics slice: oracledb.tablespace_size.usage")
  446. validatedMetrics["oracledb.tablespace_size.usage"] = true
  447. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  448. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  449. assert.Equal(t, "Used tablespace in bytes.", ms.At(i).Description())
  450. assert.Equal(t, "By", ms.At(i).Unit())
  451. dp := ms.At(i).Gauge().DataPoints().At(0)
  452. assert.Equal(t, start, dp.StartTimestamp())
  453. assert.Equal(t, ts, dp.Timestamp())
  454. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  455. assert.Equal(t, int64(1), dp.IntValue())
  456. attrVal, ok := dp.Attributes().Get("tablespace_name")
  457. assert.True(t, ok)
  458. assert.EqualValues(t, "tablespace_name-val", attrVal.Str())
  459. case "oracledb.transactions.limit":
  460. assert.False(t, validatedMetrics["oracledb.transactions.limit"], "Found a duplicate in the metrics slice: oracledb.transactions.limit")
  461. validatedMetrics["oracledb.transactions.limit"] = true
  462. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  463. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  464. assert.Equal(t, "Maximum limit of active transactions, -1 if unlimited.", ms.At(i).Description())
  465. assert.Equal(t, "{transactions}", ms.At(i).Unit())
  466. dp := ms.At(i).Gauge().DataPoints().At(0)
  467. assert.Equal(t, start, dp.StartTimestamp())
  468. assert.Equal(t, ts, dp.Timestamp())
  469. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  470. assert.Equal(t, int64(1), dp.IntValue())
  471. case "oracledb.transactions.usage":
  472. assert.False(t, validatedMetrics["oracledb.transactions.usage"], "Found a duplicate in the metrics slice: oracledb.transactions.usage")
  473. validatedMetrics["oracledb.transactions.usage"] = true
  474. assert.Equal(t, pmetric.MetricTypeGauge, ms.At(i).Type())
  475. assert.Equal(t, 1, ms.At(i).Gauge().DataPoints().Len())
  476. assert.Equal(t, "Current count of active transactions.", ms.At(i).Description())
  477. assert.Equal(t, "{transactions}", ms.At(i).Unit())
  478. dp := ms.At(i).Gauge().DataPoints().At(0)
  479. assert.Equal(t, start, dp.StartTimestamp())
  480. assert.Equal(t, ts, dp.Timestamp())
  481. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  482. assert.Equal(t, int64(1), dp.IntValue())
  483. case "oracledb.user_commits":
  484. assert.False(t, validatedMetrics["oracledb.user_commits"], "Found a duplicate in the metrics slice: oracledb.user_commits")
  485. validatedMetrics["oracledb.user_commits"] = true
  486. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  487. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  488. assert.Equal(t, "Number of user commits. When a user commits a transaction, the redo generated that reflects the changes made to database blocks must be written to disk. Commits often represent the closest thing to a user transaction rate.", ms.At(i).Description())
  489. assert.Equal(t, "{commits}", ms.At(i).Unit())
  490. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  491. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  492. dp := ms.At(i).Sum().DataPoints().At(0)
  493. assert.Equal(t, start, dp.StartTimestamp())
  494. assert.Equal(t, ts, dp.Timestamp())
  495. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  496. assert.Equal(t, int64(1), dp.IntValue())
  497. case "oracledb.user_rollbacks":
  498. assert.False(t, validatedMetrics["oracledb.user_rollbacks"], "Found a duplicate in the metrics slice: oracledb.user_rollbacks")
  499. validatedMetrics["oracledb.user_rollbacks"] = true
  500. assert.Equal(t, pmetric.MetricTypeSum, ms.At(i).Type())
  501. assert.Equal(t, 1, ms.At(i).Sum().DataPoints().Len())
  502. assert.Equal(t, "Number of times users manually issue the ROLLBACK statement or an error occurs during a user's transactions", ms.At(i).Description())
  503. assert.Equal(t, "1", ms.At(i).Unit())
  504. assert.Equal(t, true, ms.At(i).Sum().IsMonotonic())
  505. assert.Equal(t, pmetric.AggregationTemporalityCumulative, ms.At(i).Sum().AggregationTemporality())
  506. dp := ms.At(i).Sum().DataPoints().At(0)
  507. assert.Equal(t, start, dp.StartTimestamp())
  508. assert.Equal(t, ts, dp.Timestamp())
  509. assert.Equal(t, pmetric.NumberDataPointValueTypeInt, dp.ValueType())
  510. assert.Equal(t, int64(1), dp.IntValue())
  511. }
  512. }
  513. })
  514. }
  515. }