|
1 | | -/* |
2 | | - * Copyright The OpenTelemetry Authors |
3 | | - * |
4 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | | - * you may not use this file except in compliance with the License. |
6 | | - * You may obtain a copy of the License at |
7 | | - * |
8 | | - * https://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
10 | | - * Unless required by applicable law or agreed to in writing, software |
11 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
12 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | | - * See the License for the specific language governing permissions and |
14 | | - * limitations under the License. |
15 | | - */ |
16 | | -import { MeterProvider, DataPointType } from '@opentelemetry/sdk-metrics'; |
17 | | - |
18 | | -import { RuntimeNodeInstrumentation } from '../src'; |
19 | | -import * as assert from 'assert'; |
20 | | -import { TestMetricReader } from './testMetricsReader'; |
21 | | -import { metricNames } from '../src/metrics/heapSizeAndUsedCollector'; |
22 | | - |
23 | | -const MEASUREMENT_INTERVAL = 10; |
24 | | - |
25 | | -describe('nodejs.heap_size', function () { |
26 | | - let metricReader: TestMetricReader; |
27 | | - let meterProvider: MeterProvider; |
28 | | - |
29 | | - beforeEach(() => { |
30 | | - metricReader = new TestMetricReader(); |
31 | | - meterProvider = new MeterProvider(); |
32 | | - meterProvider.addMetricReader(metricReader); |
33 | | - }); |
34 | | - |
35 | | - for (const metricName of metricNames) { |
36 | | - it(`should write nodejs.${metricName.name} after monitoringPrecision`, async function () { |
37 | | - // arrange |
38 | | - const instrumentation = new RuntimeNodeInstrumentation({ |
39 | | - monitoringPrecision: MEASUREMENT_INTERVAL, |
40 | | - }); |
41 | | - instrumentation.setMeterProvider(meterProvider); |
42 | | - |
43 | | - // act |
44 | | - await new Promise(resolve => |
45 | | - setTimeout(resolve, MEASUREMENT_INTERVAL * 5) |
46 | | - ); |
47 | | - const { resourceMetrics, errors } = await metricReader.collect(); |
48 | | - |
49 | | - // assert |
50 | | - assert.deepEqual( |
51 | | - errors, |
52 | | - [], |
53 | | - 'expected no errors from the callback during collection' |
54 | | - ); |
55 | | - const scopeMetrics = resourceMetrics.scopeMetrics; |
56 | | - const metric = scopeMetrics[0].metrics.find( |
57 | | - x => x.descriptor.name === 'nodejs.' + metricName.name |
58 | | - ); |
59 | | - |
60 | | - assert.notEqual(metric, undefined, `nodejs.${metricName.name} not found`); |
61 | | - |
62 | | - assert.strictEqual( |
63 | | - metric!.dataPointType, |
64 | | - DataPointType.GAUGE, |
65 | | - 'expected gauge' |
66 | | - ); |
67 | | - |
68 | | - assert.strictEqual( |
69 | | - metric!.descriptor.name, |
70 | | - 'nodejs.' + metricName.name, |
71 | | - 'descriptor.name' |
72 | | - ); |
73 | | - }); |
74 | | - } |
75 | | -}); |
| 1 | +// /* |
| 2 | +// * Copyright The OpenTelemetry Authors |
| 3 | +// * |
| 4 | +// * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// * you may not use this file except in compliance with the License. |
| 6 | +// * You may obtain a copy of the License at |
| 7 | +// * |
| 8 | +// * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// * |
| 10 | +// * Unless required by applicable law or agreed to in writing, software |
| 11 | +// * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// * See the License for the specific language governing permissions and |
| 14 | +// * limitations under the License. |
| 15 | +// */ |
| 16 | +// import { MeterProvider, DataPointType } from '@opentelemetry/sdk-metrics'; |
| 17 | +// |
| 18 | +// import { RuntimeNodeInstrumentation } from '../src'; |
| 19 | +// import * as assert from 'assert'; |
| 20 | +// import { TestMetricReader } from './testMetricsReader'; |
| 21 | +// import { metricNames } from '../src/metrics/heapSizeAndUsedCollector'; |
| 22 | +// |
| 23 | +// const MEASUREMENT_INTERVAL = 10; |
| 24 | +// |
| 25 | +// describe('nodejs.heap_size', function () { |
| 26 | +// let metricReader: TestMetricReader; |
| 27 | +// let meterProvider: MeterProvider; |
| 28 | +// |
| 29 | +// beforeEach(() => { |
| 30 | +// metricReader = new TestMetricReader(); |
| 31 | +// meterProvider = new MeterProvider(); |
| 32 | +// meterProvider.addMetricReader(metricReader); |
| 33 | +// }); |
| 34 | +// |
| 35 | +// for (const metricName of metricNames) { |
| 36 | +// it(`should write nodejs.${metricName.name} after monitoringPrecision`, async function () { |
| 37 | +// // arrange |
| 38 | +// const instrumentation = new RuntimeNodeInstrumentation({ |
| 39 | +// monitoringPrecision: MEASUREMENT_INTERVAL, |
| 40 | +// }); |
| 41 | +// instrumentation.setMeterProvider(meterProvider); |
| 42 | +// |
| 43 | +// // act |
| 44 | +// await new Promise(resolve => |
| 45 | +// setTimeout(resolve, MEASUREMENT_INTERVAL * 5) |
| 46 | +// ); |
| 47 | +// const { resourceMetrics, errors } = await metricReader.collect(); |
| 48 | +// |
| 49 | +// // assert |
| 50 | +// assert.deepEqual( |
| 51 | +// errors, |
| 52 | +// [], |
| 53 | +// 'expected no errors from the callback during collection' |
| 54 | +// ); |
| 55 | +// const scopeMetrics = resourceMetrics.scopeMetrics; |
| 56 | +// const metric = scopeMetrics[0].metrics.find( |
| 57 | +// x => x.descriptor.name === 'nodejs.' + metricName.name |
| 58 | +// ); |
| 59 | +// |
| 60 | +// assert.notEqual(metric, undefined, `nodejs.${metricName.name} not found`); |
| 61 | +// |
| 62 | +// assert.strictEqual( |
| 63 | +// metric!.dataPointType, |
| 64 | +// DataPointType.GAUGE, |
| 65 | +// 'expected gauge' |
| 66 | +// ); |
| 67 | +// |
| 68 | +// assert.strictEqual( |
| 69 | +// metric!.descriptor.name, |
| 70 | +// 'nodejs.' + metricName.name, |
| 71 | +// 'descriptor.name' |
| 72 | +// ); |
| 73 | +// }); |
| 74 | +// } |
| 75 | +// }); |
0 commit comments