From d8833464101725e531a265312e7789c127f13912 Mon Sep 17 00:00:00 2001 From: Francesco Gualazzi Date: Mon, 7 Feb 2022 13:00:53 +0100 Subject: [PATCH] Stacktrace and Stackframes IDs not encoded in Kibana, use ES values (#6) * removed dead code * remove b64 encoding function, retrieve IDs from ES --- src/plugins/profiling/server/routes/index.ts | 56 ------------------- .../server/routes/search_flameChart.ts | 7 +-- .../profiling/server/routes/search_topN.ts | 7 +-- 3 files changed, 4 insertions(+), 66 deletions(-) diff --git a/src/plugins/profiling/server/routes/index.ts b/src/plugins/profiling/server/routes/index.ts index 109bfd31f42df..bd582ecd89914 100644 --- a/src/plugins/profiling/server/routes/index.ts +++ b/src/plugins/profiling/server/routes/index.ts @@ -6,59 +6,3 @@ * Side Public License, v 1. */ export { registerRoutes } from './register_routes'; - -export function getBase64Encoding(hex: string) { - const bin = []; - let i = 0; - let d; - let b; - while (i < hex.length) { - d = parseInt(hex.slice(i, i + 2), 16); - b = String.fromCharCode(d); - bin.push(b); - i += 2; - } - return btoa(bin.join('')).replace('+', '-').replace('/', '_'); -} - -export function getDocID(hi: bigint, lo: bigint) { - let hex = hi.toString(16); - const hexLo = lo.toString(16); - hex = '0'.repeat(16 - hex.length) + hex; - hex = hex + '0'.repeat(16 - hexLo.length) + hexLo; - - const bin = []; - let i = 0; - let d; - let b; - while (i < hex.length) { - d = parseInt(hex.slice(i, i + 2), 16); - b = String.fromCharCode(d); - bin.push(b); - i += 2; - } - - return btoa(bin.join('')).replace('+', '-').replace('/', '_'); -} - -export function getOtherDocID(hi: bigint, lo: bigint, other: bigint): string { - let hex = hi.toString(16); - const hexLo = lo.toString(16); - const hexOther = other.toString(16); - hex = '0'.repeat(16 - hex.length) + hex; - hex = hex + '0'.repeat(16 - hexLo.length) + hexLo; - hex = hex + '0'.repeat(16 - hexOther.length) + other; - - const bin = []; - let i = 0; - let d; - let b; - while (i < hex.length) { - d = parseInt(hex.slice(i, i + 2), 24); - b = String.fromCharCode(d); - bin.push(b); - i += 2; - } - - return btoa(bin.join('')).replace('+', '-').replace('/', '_'); -} diff --git a/src/plugins/profiling/server/routes/search_flameChart.ts b/src/plugins/profiling/server/routes/search_flameChart.ts index b41643039a5ba..cff59d70f7783 100644 --- a/src/plugins/profiling/server/routes/search_flameChart.ts +++ b/src/plugins/profiling/server/routes/search_flameChart.ts @@ -11,7 +11,6 @@ import { IEsSearchResponse } from '../../../data/common'; import type { DataRequestHandlerContext } from '../../../data/server'; import type { IRouter } from '../../../../core/server'; import { getRemoteRoutePaths } from '../../common'; -import { getBase64Encoding } from './index'; export function registerFlameChartSearchRoute(router: IRouter) { const paths = getRemoteRoutePaths(); @@ -143,8 +142,7 @@ export function registerFlameChartSearchRoute(router: IRouter { - const docID = getBase64Encoding(stackTraceItem.key); - tracesDocIDs.push(docID); + tracesDocIDs.push(stackTraceItem.key); } ); @@ -161,8 +159,7 @@ export function registerFlameChartSearchRoute(router: IRouter, @@ -100,9 +99,7 @@ export function queryTopNCommon( const docIDs: string[] = []; resTopNStackTraces.rawResponse.aggregations.histogram.buckets.forEach((timeInterval) => { timeInterval.group_by.buckets.forEach((stackTraceItem: any) => { - const docID = getBase64Encoding(stackTraceItem.key); - - docIDs.push(docID); + docIDs.push(stackTraceItem.key); }); }); @@ -130,7 +127,7 @@ export function queryTopNCommon( return response.customError({ statusCode: e.statusCode ?? 500, body: { - message: e.message, + message: 'Profiling TopN request failed: ' + e.message + '; full error ' + e.toString(), }, }); }