File tree Expand file tree Collapse file tree 3 files changed +27
-7
lines changed
plugins/node/instrumentation-runtime-node Expand file tree Collapse file tree 3 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 3939 "access" : " public"
4040 },
4141 "dependencies" : {
42- "@opentelemetry/instrumentation" : " ^0.53.0"
42+ "@opentelemetry/instrumentation" : " ^0.53.0" ,
4343 },
4444 "devDependencies" : {
4545 "@opentelemetry/api" : " ^1.3.0" ,
4646 "@opentelemetry/sdk-metrics" : " ^1.20.0" ,
4747 "@types/mocha" : " ^10.0.6" ,
48- "@types/node" : " ^22.1.0 " ,
48+ "@types/node" : " ^18.18.14 " ,
4949 "mocha" : " 7.2.0" ,
5050 "nyc" : " ^15.1.0" ,
5151 "rimraf" : " 5.0.10" ,
Original file line number Diff line number Diff line change 1+ import { Histogram } from "perf_hooks" ;
2+
3+ declare module 'node:perf_hooks' {
4+ interface IntervalHistogram extends Histogram {
5+ /**
6+ * Enables the update interval timer. Returns `true` if the timer was
7+ * started, `false` if it was already started.
8+ * @since v11.10.0
9+ */
10+ enable ( ) : boolean ;
11+
12+ /**
13+ * Disables the update interval timer. Returns `true` if the timer was
14+ * stopped, `false` if it was already stopped.
15+ * @since v11.10.0
16+ */
17+ disable ( ) : boolean ;
18+
19+ count : number ;
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ const { eventLoopUtilization: eventLoopUtilizationCollector } = performance;
2323export const NODEJS_EVENT_LOOP_UTILIZATION = 'eventloop.utilization' ;
2424
2525export class EventLoopUtilizationCollector extends BaseCollector {
26+ private _lastValue ?: EventLoopUtilization ;
27+
2628 constructor (
2729 config : RuntimeNodeInstrumentationConfig = { } ,
2830 namePrefix : string
@@ -42,16 +44,13 @@ export class EventLoopUtilizationCollector extends BaseCollector {
4244 . addCallback ( async observableResult => {
4345 if ( ! this . _config . enabled ) return ;
4446
45- const elu = eventLoopUtilizationCollector ( this . scrape ( ) ) ;
47+ const elu = eventLoopUtilizationCollector ( this . _lastValue ) ;
4648 observableResult . observe ( elu . utilization ) ;
49+ this . _lastValue = elu ;
4750 } ) ;
4851 }
4952
5053 protected internalDisable ( ) : void { }
5154
5255 protected internalEnable ( ) : void { }
53-
54- private scrape ( ) : EventLoopUtilization {
55- return eventLoopUtilizationCollector ( ) ;
56- }
5756}
You can’t perform that action at this time.
0 commit comments