-
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] Use indexPatternsService for kuery bar suggestions #49169
[APM] Use indexPatternsService for kuery bar suggestions #49169
Conversation
x-pack/legacy/plugins/apm/public/components/shared/KueryBar/index.tsx
Outdated
Show resolved
Hide resolved
💔 Build Failed
|
3401425
to
53755c4
Compare
💔 Build Failed
|
027e153
to
5b2071c
Compare
💚 Build Succeeded
|
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.
Looks good!
@@ -56,7 +63,7 @@ export function removeUndefinedProps<T>(obj: T): Partial<T> { | |||
return pick(obj, value => value !== undefined); | |||
} | |||
|
|||
export function getPathParams(pathname: string = '') { | |||
export function getPathParams(pathname: string = ''): PathParams { |
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.
How I wish we didn't have this method :D
Not sure the best way to get rid of it though. Perhaps lift some of this to the routing layer 🤔
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.
Not needed for this PR, though!
callApmApi => { | ||
return callApmApi({ | ||
pathname: '/api/apm/kuery_bar_index_pattern', | ||
forceCache: true, |
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.
Yay, forceCache
does make sense sometime, right? :p
const { config } = setup; | ||
|
||
const indexPatternsService = new IndexPatternsService( | ||
(...args: [any, any, any]) => |
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.
I think typing the arguments out will make it easier to read:
(endpoint: string, params?: Record<string, any>, options?: CallAPIOptions) =>
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.
Agree that [any,any,any] doesn't really help us. I've made a slight change based on your suggestion, because I think it should be explicit that this function is simply middleware and does not really care what arguments are passed to it:
const indexPatternsService = new IndexPatternsService(
(...rest: Parameters<APICaller>) =>
request.server.plugins.elasticsearch
.getCluster('data')
.callWithRequest(request, ...rest)
);
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.
Thanks 👍
index === 'metric' | ||
? config.get<string>(`apm_oss.metricsIndices`) | ||
: config.get<string>(`apm_oss.${index}Indices`) | ||
); |
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.
There's something that seems a little off. Perhaps it's the implicit mapping between processorEvent
and config option name. Or perhaps the dynamic resolution of config option name. How will this work with runtime index configurations?
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.
Aye, this was a little too implicit. Changed it to:
const indicesMap = {
transaction: indices['apm_oss.transactionIndices'],
metric: indices['apm_oss.metricsIndices'],
error: indices['apm_oss.errorIndices']
};
const configuredIndices = indexNames.map(name => indicesMap[name]);
and narrowed the type for processorEvent
.
5b2071c
to
981ddd3
Compare
💚 Build Succeeded |
Tests: ✅ |
Closes #44487.