-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Synthetucs] Added perf metrics for es queries #186313
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8f10bb3
added perf metrics
shahzad31 e9bb5ac
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 4647622
Merge branch 'main' of https://github.com/elastic/kibana into perf-me…
shahzad31 3f1d46e
Merge branch 'perf-metrics' of https://github.com/shahzad31/kibana in…
shahzad31 dbd002c
fix tests
shahzad31 411b42f
Update x-pack/plugins/observability_solution/exploratory_view/public/…
shahzad31 0c92702
lint
shahzad31 67e3def
Merge branch 'main' of https://github.com/elastic/kibana into perf-me…
shahzad31 6fbf1fc
fix types
shahzad31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
50 changes: 50 additions & 0 deletions
50
...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,50 @@ | ||
/* | ||
* 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 | ||
shahzad31 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { i18n } from '@kbn/i18n'; | |
import { BehaviorSubject } from 'rxjs'; | ||
import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; | ||
import { | ||
AnalyticsServiceSetup, | ||
AppMountParameters, | ||
AppUpdater, | ||
CoreSetup, | ||
|
@@ -85,6 +86,8 @@ export class Plugin | |
{ | ||
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({})); | ||
|
||
private analyticsService?: AnalyticsServiceSetup; | ||
|
||
constructor(private readonly initContext: PluginInitializerContext) {} | ||
|
||
public setup( | ||
|
@@ -129,6 +132,8 @@ export class Plugin | |
], | ||
}); | ||
|
||
this.analyticsService = core.analytics; | ||
|
||
return { | ||
register: registerDataHandler, | ||
}; | ||
|
@@ -138,7 +143,10 @@ export class Plugin | |
return { | ||
createExploratoryViewUrl, | ||
getAppDataView: getAppDataView(pluginsStart.dataViews), | ||
ExploratoryViewEmbeddable: getExploratoryViewEmbeddable({ ...coreStart, ...pluginsStart }), | ||
ExploratoryViewEmbeddable: getExploratoryViewEmbeddable( | ||
{ ...coreStart, ...pluginsStart }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well it's coming from coreSetup, not coreStart. |
||
this.analyticsService | ||
), | ||
}; | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate why you need to find the highest query time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's because a chart may have many other queries , so we only care about slowest query.