[EBT] Add Meta description for EBT metrics on management pages (#225095)

## Summary

Resolves https://github.com/elastic/observability-dev/issues/4556.

This PR will amend the existing EBT `onPageReady` tracking for TTFCP
with some descriptions to help consumers of the telemetry data
understand the context around what we are tracking for this timing data.

Also exports the `Meta` type for re-use in a Synthetics-specific
implementation that needs to accept this parameter.
This commit is contained in:
Justin Kambic 2025-06-26 15:59:48 -04:00 committed by GitHub
parent 9f6eb0a0cb
commit 21fcf54178
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 37 additions and 5 deletions

View file

@ -10,7 +10,18 @@
type ApmPageId = 'services' | 'traces' | 'dependencies';
type InfraPageId = 'hosts';
type OnboardingPageId = 'onboarding';
type AlertingPageId = 'alerts';
type AlertDetailsPageId = 'alert_details';
type SloPageId = 'slos';
type SyntheticsPageId = 'synthetics';
export type Key = `${ApmPageId}` | `${InfraPageId}` | `${OnboardingPageId}`;
export type Key =
| `${ApmPageId}`
| `${InfraPageId}`
| `${OnboardingPageId}`
| `${AlertingPageId}`
| `${AlertDetailsPageId}`
| `${SloPageId}`
| `${SyntheticsPageId}`;
export type DescriptionWithPrefix = `[ttfmp_${Key}] ${string}`;

View file

@ -24,4 +24,5 @@ function dynamic<TElement extends React.ComponentType<any>, TRef = {}>(loader: L
export { usePerformanceContext } from './context/use_performance_context';
export { perfomanceMarkers } from './performance_markers';
export { usePageReady } from './context/use_page_ready';
export { type Meta } from './context/performance_context';
export const PerformanceContextProvider = dynamic(() => import('./context/performance_context'));

View file

@ -195,6 +195,10 @@ export function AlertDetails() {
usePageReady({
isRefreshing: isLoading,
isReady: !isLoading && !!alertDetail && activeTabId === 'overview',
meta: {
description:
'[ttfmp_alert_details] The Observability Alert Details overview page has loaded successfully.',
},
});
if (isLoading) {

View file

@ -136,6 +136,7 @@ function InternalAlertsPage() {
meta: {
rangeFrom: alertSearchBarStateProps.rangeFrom,
rangeTo: alertSearchBarStateProps.rangeTo,
description: '[ttfmp_alerts] The Observability Alerts page has loaded a table of alerts.',
},
});

View file

@ -108,6 +108,9 @@ export function SloDetailsPage() {
usePageReady({
isReady: !isLoading && slo !== undefined,
isRefreshing: isRefetching,
meta: {
description: '[ttfmp_slos] The SLO details page has loaded and SLO data is present.',
},
});
useBreadcrumbs(getBreadcrumbs(basePath, slo), { serverless });

View file

@ -82,6 +82,13 @@ export function SloList() {
usePageReady({
isReady: !isLoading && sloList !== undefined,
isRefreshing: isLoading,
customMetrics: {
key1: 'slo_list_count',
value1: sloList?.total ?? 0,
},
meta: {
description: '[ttfmp_slos] The SLOs list has finished loading.',
},
});
return (

View file

@ -39,7 +39,9 @@ export const MonitorListContainer = ({
const { status: overviewStatus } = useSelector(selectOverviewStatus);
useSyntheticsPageReady();
useSyntheticsPageReady({
meta: { description: '[ttfmp_synthetics] Synthetics monitor list has loaded.' },
});
// TODO: Display inline errors in the management table

View file

@ -42,7 +42,9 @@ export const OverviewPage: React.FC = () => {
const { loading: locationsLoading, locationsLoaded } = useSelector(selectServiceLocationsState);
useSyntheticsPageReady();
useSyntheticsPageReady({
meta: { description: '[ttfmp_synthetics] Synthetics overview page has loaded monitor data.' },
});
useEffect(() => {
if (!locationsLoading && !locationsLoaded) {

View file

@ -6,10 +6,10 @@
*/
import { useDispatch, useSelector } from 'react-redux';
import { usePageReady } from '@kbn/ebt-tools';
import { usePageReady, type Meta } from '@kbn/ebt-tools';
import { initialLoadReported, selectOverviewStatus } from '../state/overview_status';
export const useSyntheticsPageReady = () => {
export const useSyntheticsPageReady = (props?: { meta?: Meta }) => {
const {
loaded,
isInitialLoad,
@ -29,5 +29,6 @@ export const useSyntheticsPageReady = () => {
// This will collect the metric even when we are periodically refreshing the data in the background
// and not only when the user decides to refresh the data, the action is the same
isRefreshing: loaded && isLoadingOverviewStatus,
meta: props?.meta,
});
};