mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `9.0`: - [chore(NA): replaces native-hdr-histogram with hdr-histogram-js (#216715)](https://github.com/elastic/kibana/pull/216715) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Tiago Costa","email":"tiago.costa@elastic.co"},"sourceCommit":{"committedDate":"2025-04-02T08:27:11Z","message":"chore(NA): replaces native-hdr-histogram with hdr-histogram-js (#216715)\n\n`native-hdr-histogram` is a native module and its prebuilds are failing\nthe bootstrap on macos machines during bootstrap since early today.\n\nIts usage its contained in a single dev package and therefore this PR\nattempts to port into `hdr-histogram-js`.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"420512a53a9343b96eb47d89bec7c2f5f9b5a993","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","ci:collect-apm","ci:all-cypress-suites","backport:prev-minor","backport:prev-major","ci:build-webpack-bundle-analyzer","Team:obs-ux-infra_services","ci:perf-check:start","v9.1.0"],"title":"chore(NA): replaces native-hdr-histogram with hdr-histogram-js","number":216715,"url":"https://github.com/elastic/kibana/pull/216715","mergeCommit":{"message":"chore(NA): replaces native-hdr-histogram with hdr-histogram-js (#216715)\n\n`native-hdr-histogram` is a native module and its prebuilds are failing\nthe bootstrap on macos machines during bootstrap since early today.\n\nIts usage its contained in a single dev package and therefore this PR\nattempts to port into `hdr-histogram-js`.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"420512a53a9343b96eb47d89bec7c2f5f9b5a993"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216715","number":216715,"mergeCommit":{"message":"chore(NA): replaces native-hdr-histogram with hdr-histogram-js (#216715)\n\n`native-hdr-histogram` is a native module and its prebuilds are failing\nthe bootstrap on macos machines during bootstrap since early today.\n\nIts usage its contained in a single dev package and therefore this PR\nattempts to port into `hdr-histogram-js`.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"420512a53a9343b96eb47d89bec7c2f5f9b5a993"}}]}] BACKPORT-->
This commit is contained in:
parent
d131250dc1
commit
20132c8c8c
5 changed files with 55 additions and 22 deletions
|
@ -1769,6 +1769,7 @@
|
|||
"gulp-postcss": "^9.0.1",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"has-ansi": "^3.0.0",
|
||||
"hdr-histogram-js": "^3.0.0",
|
||||
"html-loader": "^5.1.0",
|
||||
"http-proxy": "^1.18.1",
|
||||
"http2-proxy": "^5.0.53",
|
||||
|
@ -1807,7 +1808,6 @@
|
|||
"ms-chromium-edge-driver": "^0.5.1",
|
||||
"msw": "~2.7.3",
|
||||
"mutation-observer": "^1.0.3",
|
||||
"native-hdr-histogram": "^1.0.0",
|
||||
"nock": "12.0.3",
|
||||
"node-libs-browser": "^2.2.1",
|
||||
"nyc": "^17.1.0",
|
||||
|
|
|
@ -3707,9 +3707,9 @@
|
|||
"enabled": true
|
||||
},
|
||||
{
|
||||
"groupName": "native-hdr-histogram",
|
||||
"groupName": "hdr-histogram-js",
|
||||
"matchDepNames": [
|
||||
"native-hdr-histogram"
|
||||
"hdr-histogram-js"
|
||||
],
|
||||
"reviewers": [
|
||||
"team:obs-ux-infra_services-team"
|
||||
|
@ -4356,4 +4356,4 @@
|
|||
"datasourceTemplate": "docker"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -8,8 +8,7 @@
|
|||
*/
|
||||
|
||||
import { sortBy } from 'lodash';
|
||||
// @ts-expect-error
|
||||
import Histogram from 'native-hdr-histogram';
|
||||
import Histogram from 'hdr-histogram-js';
|
||||
|
||||
const ONE_HOUR_IN_MICRO_SECONDS = 1000 * 1000 * 60 * 60;
|
||||
|
||||
|
@ -41,19 +40,46 @@ class LosslessHistogram {
|
|||
return this.backingHistogram;
|
||||
}
|
||||
|
||||
const histogram = new Histogram(this.min, this.max);
|
||||
const histogram = Histogram.build({
|
||||
lowestDiscernibleValue: this.min,
|
||||
highestTrackableValue: this.max,
|
||||
useWebAssembly: false,
|
||||
});
|
||||
|
||||
this.backingHistogram = histogram;
|
||||
|
||||
if (this.trackedValues.size > 0) {
|
||||
this.trackedValues.forEach((count, value) => {
|
||||
histogram.record(value, count);
|
||||
histogram.recordValueWithCount(value, count);
|
||||
});
|
||||
}
|
||||
|
||||
return histogram;
|
||||
}
|
||||
|
||||
private linearCounts(valueUnitsPerBucket: number) {
|
||||
if (!this.backingHistogram) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const result = [];
|
||||
let value = valueUnitsPerBucket;
|
||||
|
||||
while (value <= this.backingHistogram.maxValue) {
|
||||
let count = 0;
|
||||
|
||||
// Sum counts within this bucket range
|
||||
for (let i = value - valueUnitsPerBucket + 1; i <= value; i++) {
|
||||
count += this.backingHistogram.getCountAtValue(i);
|
||||
}
|
||||
|
||||
result.push({ count, value });
|
||||
value += valueUnitsPerBucket;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
record(value: number) {
|
||||
const countForValue = this.trackedValues.get(value);
|
||||
if (
|
||||
|
@ -69,11 +95,12 @@ class LosslessHistogram {
|
|||
|
||||
serialize(): SerializedHistogram {
|
||||
if (this.backingHistogram) {
|
||||
const minRecordedValue = this.backingHistogram.min();
|
||||
const maxRecordedValue = this.backingHistogram.max();
|
||||
const minRecordedValue = this.backingHistogram.minNonZeroValue;
|
||||
const maxRecordedValue = this.backingHistogram.maxValue;
|
||||
|
||||
const distribution: Array<{ value: number; count: number }> =
|
||||
this.backingHistogram.linearcounts(Math.max(1, (maxRecordedValue - minRecordedValue) / 50));
|
||||
const distribution: Array<{ value: number; count: number }> = this.linearCounts(
|
||||
Math.max(1, (maxRecordedValue - minRecordedValue) / 50)
|
||||
);
|
||||
|
||||
const values: number[] = [];
|
||||
const counts: number[] = [];
|
||||
|
|
|
@ -111,7 +111,7 @@ module.exports = {
|
|||
transformIgnorePatterns: [
|
||||
// ignore all node_modules except monaco-editor, monaco-yaml which requires babel transforms to handle dynamic import()
|
||||
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
|
||||
'[/\\\\]node_modules(?)[/\\\\].+\\.js$',
|
||||
'[/\\\\]node_modules(?)[/\\\\].+\\.js$',
|
||||
'packages/kbn-pm/dist/index.js',
|
||||
'[/\\\\]node_modules(?)/dist/[/\\\\].+\\.js$',
|
||||
'[/\\\\]node_modules(?)/dist/util/[/\\\\].+\\.js$',
|
||||
|
|
24
yarn.lock
24
yarn.lock
|
@ -144,6 +144,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@assemblyscript/loader/-/loader-0.10.1.tgz#70e45678f06c72fa2e350e8553ec4a4d72b92e06"
|
||||
integrity sha512-H71nDOOL8Y7kWRLqf6Sums+01Q5msqBW2KhDUTemh1tvY04eSkSXrK0uj/4mmY0Xr16/3zyZmsrxN7CKuRbNRg==
|
||||
|
||||
"@assemblyscript/loader@^0.19.21":
|
||||
version "0.19.23"
|
||||
resolved "https://registry.yarnpkg.com/@assemblyscript/loader/-/loader-0.19.23.tgz#7fccae28d0a2692869f1d1219d36093bc24d5e72"
|
||||
integrity sha512-ulkCYfFbYj01ie1MDOyxv2F6SpRN1TOj7fQxbP07D6HmeR+gr2JLSmINKjga2emB+b1L2KGrFKBTc+e00p54nw==
|
||||
|
||||
"@aws-crypto/crc32@5.2.0":
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@aws-crypto/crc32/-/crc32-5.2.0.tgz#cfcc22570949c98c6689cfcbd2d693d36cdae2e1"
|
||||
|
@ -19557,6 +19562,15 @@ hdr-histogram-js@^2.0.1:
|
|||
base64-js "^1.2.0"
|
||||
pako "^1.0.3"
|
||||
|
||||
hdr-histogram-js@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/hdr-histogram-js/-/hdr-histogram-js-3.0.0.tgz#8e2d9a68e3313147804c47d85a9c22a93f85e24b"
|
||||
integrity sha512-/EpvQI2/Z98mNFYEnlqJ8Ogful8OpArLG/6Tf2bPnkutBVLIeMVNHjk1ZDfshF2BUweipzbk+dB1hgSB7SIakw==
|
||||
dependencies:
|
||||
"@assemblyscript/loader" "^0.19.21"
|
||||
base64-js "^1.2.0"
|
||||
pako "^1.0.3"
|
||||
|
||||
hdr-histogram-percentiles-obj@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/hdr-histogram-percentiles-obj/-/hdr-histogram-percentiles-obj-3.0.0.tgz#9409f4de0c2dda78e61de2d9d78b1e9f3cba283c"
|
||||
|
@ -23620,14 +23634,6 @@ napi-build-utils@^1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/napi-build-utils/-/napi-build-utils-1.0.2.tgz#b1fddc0b2c46e380a0b7a76f984dd47c41a13806"
|
||||
integrity sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==
|
||||
|
||||
native-hdr-histogram@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/native-hdr-histogram/-/native-hdr-histogram-1.0.0.tgz#4b740ea0f919f926b8ee0edaa4c03a3de1cbdff7"
|
||||
integrity sha512-m6rSY8FCsJpM6wQ68lcKymXEPWkVPsClzNcxHE5nAQsDK5gLycWQ1eHhBW2M9Hu1yBSuJTcqH1J09Sr44447qQ==
|
||||
dependencies:
|
||||
node-addon-api "^3.0.0"
|
||||
node-gyp-build "^4.2.3"
|
||||
|
||||
natural-compare-lite@^1.4.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4"
|
||||
|
@ -23800,7 +23806,7 @@ node-gyp-build-optional-packages@5.1.1:
|
|||
dependencies:
|
||||
detect-libc "^2.0.1"
|
||||
|
||||
node-gyp-build@^4.2.2, node-gyp-build@^4.2.3, node-gyp-build@^4.3.0:
|
||||
node-gyp-build@^4.2.2, node-gyp-build@^4.3.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.5.0.tgz#7a64eefa0b21112f89f58379da128ac177f20e40"
|
||||
integrity sha512-2iGbaQBV+ITgCz76ZEjmhUKAKVf7xfY1sRl4UiKQspfZMH2h06SyhNsnSVy50cwkFQDGLyif6m/6uFXHkOZ6rg==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue