Skip to content

Commit 3e6cee2

Browse files
committed
feat(instr-runtime-node): add configurable gcDurationBuckets option
Allow users to customize the histogram bucket boundaries for the v8js.gc.duration metric via the gcDurationBuckets configuration option, similar to how monitoringPrecision is configurable.
1 parent 64576c4 commit 3e6cee2

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/instrumentation-runtime-node/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ nodejs_performance_event_loop_utilization 0.010140079547955264
6060
6161
`RuntimeNodeInstrumentation`'s constructor accepts the following options:
6262
63-
| name | type | unit | default | description |
64-
|---------------------------------------------|-------|-------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
65-
| [`monitoringPrecision`](./src/types.ts#L25) | `int` | millisecond | `10` | The approximate number of milliseconds for which to calculate event loop utilization averages. A larger value will result in more accurate averages at the expense of less granular data. Should be set to below the scrape interval of your metrics collector to avoid duplicated data points. |
63+
| name | type | unit | default | description |
64+
|---------------------------------------------|------------|-------------|----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
65+
| [`monitoringPrecision`](./src/types.ts#L20) | `int` | millisecond | `10` | The approximate number of milliseconds for which to calculate event loop utilization averages. A larger value will result in more accurate averages at the expense of less granular data. Should be set to below the scrape interval of your metrics collector to avoid duplicated data points. |
66+
| [`gcDurationBuckets`](./src/types.ts#L21) | `number[]` | second | `[0.01, 0.1, 1, 10]` | The histogram bucket boundaries to use for the GC duration histogram (`v8js.gc.duration`). |
6667
6768
## Useful links
6869

packages/instrumentation-runtime-node/src/instrumentation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { PACKAGE_VERSION, PACKAGE_NAME } from './version';
2727

2828
const DEFAULT_CONFIG: RuntimeNodeInstrumentationConfig = {
2929
monitoringPrecision: 10,
30+
gcDurationBuckets: [0.01, 0.1, 1, 10],
3031
};
3132

3233
export class RuntimeNodeInstrumentation extends InstrumentationBase<RuntimeNodeInstrumentationConfig> {

packages/instrumentation-runtime-node/src/metrics/gcCollector.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import { Histogram, ValueType } from '@opentelemetry/api';
2222
import { BaseCollector } from './baseCollector';
2323
import { ATTR_V8JS_GC_TYPE, METRIC_V8JS_GC_DURATION } from '../semconv';
2424

25-
const DEFAULT_GC_DURATION_BUCKETS = [0.01, 0.1, 1, 10];
26-
2725
const kinds: string[] = [];
2826
kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_MAJOR] = 'major';
2927
kinds[perf_hooks.constants.NODE_PERFORMANCE_GC_MINOR] = 'minor';
@@ -61,7 +59,7 @@ export class GCCollector extends BaseCollector {
6159
unit: 's',
6260
valueType: ValueType.DOUBLE,
6361
advice: {
64-
explicitBucketBoundaries: DEFAULT_GC_DURATION_BUCKETS,
62+
explicitBucketBoundaries: this._config.gcDurationBuckets,
6563
},
6664
}
6765
);

packages/instrumentation-runtime-node/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
1818
export interface RuntimeNodeInstrumentationConfig
1919
extends InstrumentationConfig {
2020
monitoringPrecision?: number;
21+
gcDurationBuckets?: number[];
2122
}

0 commit comments

Comments
 (0)