Skip to content

Commit

Permalink
Moves automatic index pattern saved object creation from
Browse files Browse the repository at this point in the history
plugin start to when the Home screen first renders
  • Loading branch information
ogupte committed Apr 30, 2020
1 parent cf5d8d0 commit eec8279
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
11 changes: 10 additions & 1 deletion x-pack/plugins/apm/public/components/app/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
EuiTitle
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React from 'react';
import React, { useEffect } from 'react';
import { $ElementType } from 'utility-types';
import { useApmPluginContext } from '../../../hooks/useApmPluginContext';
import { ApmHeader } from '../../shared/ApmHeader';
Expand All @@ -25,6 +25,7 @@ import { SetupInstructionsLink } from '../../shared/Links/SetupInstructionsLink'
import { ServiceMap } from '../ServiceMap';
import { ServiceOverview } from '../ServiceOverview';
import { TraceOverview } from '../TraceOverview';
import { createStaticIndexPattern } from '../../../services/rest/index_pattern';

function getHomeTabs({
serviceMapEnabled = true
Expand Down Expand Up @@ -87,6 +88,14 @@ export function Home({ tab }: Props) {
homeTab => homeTab.name === tab
) as $ElementType<typeof homeTabs, number>;

useEffect(() => {
// Automatically creates static index pattern and stores as saved object
createStaticIndexPattern().catch(e => {
// eslint-disable-next-line no-console
console.log('Error creating static index pattern', e);
});
}, []);

return (
<div>
<ApmHeader>
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { featureCatalogueEntry } from './featureCatalogueEntry';
import { AlertType } from '../common/alert_types';
import { ErrorRateAlertTrigger } from './components/shared/ErrorRateAlertTrigger';
import { TransactionDurationAlertTrigger } from './components/shared/TransactionDurationAlertTrigger';
import { createStaticIndexPattern } from './services/rest/index_pattern';
import { setHelpExtension } from './setHelpExtension';
import { toggleAppLinkInNav } from './toggleAppLinkInNav';
import { setReadonlyBadge } from './updateBadge';
Expand Down Expand Up @@ -121,11 +120,5 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
errors: []
})
});

// create static index pattern and store as saved object. Not needed by APM UI but for legacy reasons in Discover, Dashboard etc.
createStaticIndexPattern().catch(e => {
// eslint-disable-next-line no-console
console.log('Error fetching static index pattern', e);
});
}
}

0 comments on commit eec8279

Please sign in to comment.