[INFRA] Add additional perf telemetry (#205955)

## Summary
Closes https://github.com/elastic/kibana/issues/205394
This PR adds performance telemetry to metric explorer and adds time
range to existing telemetry in the host tables.
Building on #180309.

The time ranges added to the telemetry use the format "now", "now-15m"
per the examples in the [performance tutorial
docs](https://docs.elastic.dev/kibana-dev-docs/tutorial/performance/adding_custom_performance_metrics#add-time-ranges)


example of perf temeletry with the query range metadata can be seen
[here](https://telemetry-v2-staging.elastic.dev/s/apm/app/discover#/?_g=(filters:!(),query:(language:kuery,query:''),refreshInterval:(pause:!t,value:60000),time:(from:'2025-01-08T18:30:00.000Z',to:'2025-01-08T19:00:00.000Z'))&_a=(columns:!(),dataSource:(dataViewId:'0d6d7d31-1369-4a53-b36d-fbe97e4e5a0e',type:dataView),filters:!(),interval:auto,query:(language:kuery,query:'eventName%20:%20%22kibana:plugin_render_time%22%20and%20context.pageName%20:%20%22application:metrics:%2Fexplorer%22%20'),sort:!(!(timestamp,desc))))
This commit is contained in:
Bryce Buchanan 2025-01-10 02:50:15 -08:00 committed by GitHub
parent 3b42b80bce
commit c7e4249b6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -14,10 +14,10 @@ import type { HostNodeRow } from '../hooks/use_hosts_table';
import { useHostsTableContext } from '../hooks/use_hosts_table';
import { useHostsViewContext } from '../hooks/use_hosts_view';
import { useHostCountContext } from '../hooks/use_host_count';
import { useUnifiedSearchContext } from '../hooks/use_unified_search';
import { FlyoutWrapper } from './host_details_flyout/flyout_wrapper';
import { DEFAULT_PAGE_SIZE, PAGE_SIZE_OPTIONS } from '../constants';
import { FilterAction } from './table/filter_action';
import { useUnifiedSearchContext } from '../hooks/use_unified_search';
export const HostsTable = () => {
const { loading } = useHostsViewContext();
@ -44,6 +44,10 @@ export const HostsTable = () => {
useEffect(() => {
if (!loading && !hostCountLoading) {
onPageReady({
meta: {
rangeFrom: searchCriteria.dateRange.from,
rangeTo: searchCriteria.dateRange.to,
},
customMetrics: {
key1: 'num_of_hosts',
value1: count,

View file

@ -8,6 +8,7 @@
import { i18n } from '@kbn/i18n';
import React, { useEffect, useState } from 'react';
import { useTrackPageview, FeatureFeedbackButton } from '@kbn/observability-shared-plugin/public';
import { usePerformanceContext } from '@kbn/ebt-tools';
import { OnboardingFlow } from '../../../components/shared/templates/no_data_config';
import { InfraPageTemplate } from '../../../components/shared/templates/infra_page_template';
import { WithMetricsExplorerOptionsUrlState } from '../../../containers/metrics_explorer/with_metrics_explorer_options_url_state';
@ -65,6 +66,8 @@ const MetricsExplorerContent = () => {
const { kibanaVersion, isCloudEnv, isServerlessEnv } = useKibanaEnvironmentContext();
const { onPageReady } = usePerformanceContext();
useTrackPageview({ app: 'infra_metrics', path: 'metrics_explorer' });
useTrackPageview({ app: 'infra_metrics', path: 'metrics_explorer', delay: 15000 });
@ -93,6 +96,15 @@ const MetricsExplorerContent = () => {
currentTimerange: timeRange,
};
if (!isLoading) {
onPageReady({
meta: {
rangeFrom: timeRange.from,
rangeTo: timeRange.to,
},
});
}
return (
<InfraPageTemplate
onboardingFlow={OnboardingFlow.Infra}