-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(instrumentation-runtime-node): fix tests
- Loading branch information
1 parent
3cba596
commit 54858de
Showing
9 changed files
with
246 additions
and
303 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
plugins/node/instrumentation-runtime-node/test/event_loop_delay.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { MeterProvider, DataPointType } from '@opentelemetry/sdk-metrics'; | ||
|
||
import { RuntimeNodeInstrumentation } from '../src'; | ||
import * as assert from 'assert'; | ||
import { TestMetricReader } from './testMetricsReader'; | ||
import { metricNames } from '../src/metrics/eventLoopDelayCollector'; | ||
import {ConventionalNamePrefix} from "../src/types/ConventionalNamePrefix"; | ||
|
||
const MEASUREMENT_INTERVAL = 10; | ||
|
||
describe(`${ConventionalNamePrefix.NodeJsRuntime}.eventloop`, function () { | ||
let metricReader: TestMetricReader; | ||
let meterProvider: MeterProvider; | ||
|
||
beforeEach(() => { | ||
metricReader = new TestMetricReader(); | ||
meterProvider = new MeterProvider(); | ||
meterProvider.addMetricReader(metricReader); | ||
}); | ||
|
||
for (const metricName in metricNames) { | ||
it(`should write ${ConventionalNamePrefix.NodeJsRuntime}.${metricName} after monitoringPrecision`, async function () { | ||
// arrange | ||
const instrumentation = new RuntimeNodeInstrumentation({ | ||
monitoringPrecision: MEASUREMENT_INTERVAL, | ||
}); | ||
instrumentation.setMeterProvider(meterProvider); | ||
|
||
// act | ||
await new Promise(resolve => | ||
setTimeout(resolve, MEASUREMENT_INTERVAL * 5) | ||
); | ||
const { resourceMetrics, errors } = await metricReader.collect(); | ||
|
||
// assert | ||
assert.deepEqual( | ||
errors, | ||
[], | ||
'expected no errors from the callback during collection' | ||
); | ||
const scopeMetrics = resourceMetrics.scopeMetrics; | ||
const metric = scopeMetrics[0].metrics.find( | ||
x => x.descriptor.name === `${ConventionalNamePrefix.NodeJsRuntime}.${ metricName}` | ||
); | ||
|
||
assert.notEqual(metric, undefined, `${ConventionalNamePrefix.NodeJsRuntime}.${metricName} not found`); | ||
|
||
assert.strictEqual( | ||
metric!.dataPointType, | ||
DataPointType.GAUGE, | ||
'expected gauge' | ||
); | ||
|
||
assert.strictEqual( | ||
metric!.descriptor.name, | ||
`${ConventionalNamePrefix.NodeJsRuntime}.${ metricName}`, | ||
'descriptor.name' | ||
); | ||
}); | ||
} | ||
}); |
104 changes: 0 additions & 104 deletions
104
plugins/node/instrumentation-runtime-node/test/event_loop_lag.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.