forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetucs] Added perf metrics for es queries (elastic#186313)
## Summary Added perf metrics for es queries !! Fixes elastic/synthetics-dev#351 Started reporting query time for exploratory based visualizations used in Synthetics Test data can be seen on staging telemetry cluster !! <img width="1698" alt="image" src="https://github.com/elastic/kibana/assets/3505601/120d9ea6-0162-4f56-8168-001b749d31e8"> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
86 additions
and
5 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
52 changes: 52 additions & 0 deletions
52
...ion/exploratory_view/public/components/shared/exploratory_view/hooks/use_ebt_telemetry.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,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { DefaultInspectorAdapters } from '@kbn/expressions-plugin/common'; | ||
import { reportPerformanceMetricEvent } from '@kbn/ebt-tools'; | ||
import { AnalyticsServiceSetup } from '@kbn/core-analytics-browser'; | ||
|
||
export const useEBTTelemetry = ({ | ||
analytics, | ||
queryName, | ||
}: { | ||
analytics?: AnalyticsServiceSetup; | ||
queryName?: string; | ||
}) => { | ||
const reportEvent = (inspectorAdapters?: Partial<DefaultInspectorAdapters>) => { | ||
if (inspectorAdapters) { | ||
const { requests } = inspectorAdapters; | ||
if (requests && analytics) { | ||
const listReq = requests.getRequests(); | ||
|
||
if (listReq.length > 0) { | ||
// find the highest query time, since a lens chart can contains more than on query, it doesn't make sense to | ||
// report all of them , only the query with highest latency needs to be reported | ||
const duration = listReq.reduce((acc, req) => { | ||
const queryTime = Number(req.stats?.queryTime.value.split('ms')?.[0]); | ||
return queryTime > acc ? queryTime : acc; | ||
}, 0); | ||
|
||
if (duration) { | ||
reportPerformanceMetricEvent(analytics, { | ||
eventName: 'exploratory_view_query_time', | ||
duration, | ||
meta: | ||
(queryName && { | ||
queryName, | ||
}) || | ||
undefined, | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
return { | ||
reportEvent, | ||
}; | ||
}; |
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