Skip to content
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

Merged
merged 4 commits into from
Oct 30, 2019

Conversation

dgieselaar
Copy link
Member

Closes #44487.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@dgieselaar dgieselaar force-pushed the fake-kuery-index-pattern branch from 3401425 to 53755c4 Compare October 25, 2019 11:47
@elasticmachine
Copy link
Contributor

💔 Build Failed

@dgieselaar dgieselaar force-pushed the fake-kuery-index-pattern branch 2 times, most recently from 027e153 to 5b2071c Compare October 28, 2019 10:00
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@smith smith left a 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 {
Copy link
Member

@sorenlouv sorenlouv Oct 28, 2019

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 🤔

Copy link
Member

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,
Copy link
Member

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]) =>
Copy link
Member

@sorenlouv sorenlouv Oct 28, 2019

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) =>

Copy link
Member Author

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)
  );

Copy link
Member

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`)
);
Copy link
Member

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?

Copy link
Member Author

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.

@dgieselaar dgieselaar force-pushed the fake-kuery-index-pattern branch from 5b2071c to 981ddd3 Compare October 30, 2019 10:30
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@dgieselaar dgieselaar merged commit 46304f0 into elastic:master Oct 30, 2019
@dgieselaar dgieselaar deleted the fake-kuery-index-pattern branch October 30, 2019 11:54
@cauemarcondes cauemarcondes self-assigned this Jan 21, 2020
@cauemarcondes
Copy link
Contributor

Tests: ✅

@cauemarcondes cauemarcondes added the apm:test-plan-done Pull request that was successfully tested during the test plan label Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:test-plan-done Pull request that was successfully tested during the test plan release_note:enhancement v7.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Dynamically create fake index pattern for kuery bar (and drop requirement for actual index pattern)
6 participants