-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[APM] Service Map data background task and API endpoint #50844
Changes from all commits
6f4ae98
1deb234
658f048
dc930e8
0939da8
e4860c5
577297d
0a3e0ae
14a231f
4e2ce54
945d8b0
2121bcd
5e62db8
d7734ff
f0aec81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export const SERVICE_MAP_TASK_TYPE = 'apmServiceMap'; | ||
export const SERVICE_MAP_TASK_ID = 'apm-servicemap-processor'; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,13 @@ import { makeApmUsageCollector } from './server/lib/apm_telemetry'; | |
|
||
export const apm: LegacyPluginInitializer = kibana => { | ||
return new kibana.Plugin({ | ||
require: ['kibana', 'elasticsearch', 'xpack_main', 'apm_oss'], | ||
require: [ | ||
'kibana', | ||
'elasticsearch', | ||
'xpack_main', | ||
'apm_oss', | ||
'task_manager' | ||
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. This is another reason for not having |
||
], | ||
id: 'apm', | ||
configPrefix: 'xpack.apm', | ||
publicDir: resolve(__dirname, 'public'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,15 @@ | |
*/ | ||
|
||
import theme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import React from 'react'; | ||
import React, { useMemo } from 'react'; | ||
import { useFetcher } from '../../../hooks/useFetcher'; | ||
import { useLicense } from '../../../hooks/useLicense'; | ||
import { useUrlParams } from '../../../hooks/useUrlParams'; | ||
import { Controls } from './Controls'; | ||
import { Cytoscape } from './Cytoscape'; | ||
import { PlatinumLicensePrompt } from './PlatinumLicensePrompt'; | ||
import { useApmPluginContext } from '../../../hooks/useApmPluginContext'; | ||
import { callApi } from '../../../services/rest/callApi'; | ||
|
||
interface ServiceMapProps { | ||
serviceName?: string; | ||
|
@@ -39,35 +41,77 @@ ${theme.euiColorLightShade}`, | |
|
||
export function ServiceMap({ serviceName }: ServiceMapProps) { | ||
const { | ||
urlParams: { start, end } | ||
urlParams: { start, end, environment }, | ||
uiFilters | ||
} = useUrlParams(); | ||
|
||
const uiFiltersOmitEnv = useMemo( | ||
() => ({ | ||
...uiFilters, | ||
environment: undefined | ||
}), | ||
[uiFilters] | ||
); | ||
|
||
const { http } = useApmPluginContext().core; | ||
const { data: serviceMapStartResponse } = useFetcher(async () => { | ||
const response = await callApi<{ | ||
taskStatus: 'initialized' | 'active'; | ||
}>(http, { | ||
method: 'GET', | ||
pathname: `/api/apm/service-map-start-task` | ||
}); | ||
return response; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [http]); | ||
|
||
const { data } = useFetcher( | ||
callApmApi => { | ||
if (start && end) { | ||
if (start && end && serviceMapStartResponse) { | ||
return callApmApi({ | ||
pathname: '/api/apm/service-map', | ||
params: { query: { start, end } } | ||
params: { | ||
query: { | ||
start, | ||
end, | ||
environment, | ||
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. I think my previous comment was lost in a rebase: |
||
serviceName, | ||
uiFilters: JSON.stringify(uiFiltersOmitEnv) | ||
} | ||
} | ||
}); | ||
} | ||
}, | ||
[start, end] | ||
[ | ||
start, | ||
end, | ||
uiFiltersOmitEnv, | ||
environment, | ||
serviceName, | ||
serviceMapStartResponse | ||
] | ||
); | ||
|
||
const elements = Array.isArray(data) ? data : []; | ||
const license = useLicense(); | ||
const isValidPlatinumLicense = | ||
license?.isActive && license?.type === 'platinum'; | ||
true || | ||
(license?.isActive && | ||
(license?.type === 'platinum' || license?.type === 'trial')); | ||
|
||
return isValidPlatinumLicense ? ( | ||
<Cytoscape | ||
elements={elements} | ||
serviceName={serviceName} | ||
style={cytoscapeDivStyle} | ||
> | ||
<Controls /> | ||
</Cytoscape> | ||
) : ( | ||
<PlatinumLicensePrompt /> | ||
return ( | ||
<> | ||
{isValidPlatinumLicense ? ( | ||
<Cytoscape | ||
elements={elements} | ||
serviceName={serviceName} | ||
style={cytoscapeDivStyle} | ||
> | ||
<Controls /> | ||
</Cytoscape> | ||
) : ( | ||
<PlatinumLicensePrompt /> | ||
)} | ||
</> | ||
); | ||
} |
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.
Should we have a convention around camelCase vs kebab-case for constants?
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.
We already use snake case for constants (eg
SERVICE_MAP_TASK_ID
) as for the value, it's depends on the context. There's no existing convention for task types and task ids. Some plugins mix snake and kebab case for id:plugin_task-id
. from what i see, it looks like other plugins tend to use snake case for the task type. We could change the type toapm_service_map
to conform if we want to. The task type is represented in the API by an object key in the task definition, so i don't recommend kebab case.