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] Setting for default env for service inventory #126151

Merged
merged 7 commits into from
Mar 1, 2022

Conversation

dgieselaar
Copy link
Member

Closes #126091.

@dgieselaar dgieselaar added release_note:enhancement Team:APM All issues that need APM UI Team support v8.2.0 labels Feb 22, 2022
@dgieselaar dgieselaar marked this pull request as ready for review February 22, 2022 12:31
@dgieselaar dgieselaar requested a review from a team as a code owner February 22, 2022 12:31
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)


if (last(matchingRoutes)?.path === '/services') {
const defaultServiceEnvironment =
core.uiSettings.get<boolean>(defaultApmServiceEnvironment) ||
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks! Good catch. Was copying pasta :)

@gbamparop gbamparop self-requested a review February 22, 2022 13:12
Copy link
Contributor

@gbamparop gbamparop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! - Just a trivial comment. Thanks for adding this!

@@ -27,6 +27,7 @@ export {
enableInspectEsQueries,
enableComparisonByDefault,
enableInfrastructureView,
defaultApmServiceEnvironment,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not related only to this change but since these keys are being exported from x-pack/plugins/observability/common/index.ts are there benefits to have them here as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow - mind elaborating?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just wondering if we do need these exports as it seems that the ones from /common can be used instead.


if (last(matchingRoutes)?.path === '/services') {
const defaultServiceEnvironment =
core.uiSettings.get<boolean>(defaultApmServiceEnvironment) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a string?

Copy link
Contributor

@kpatticha kpatticha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks pretty good. The only thing I've noticed is when I set a default environment which doesn't exist.

The All option is selected in the env filter but the data is filtered by the environment I set
Screenshot 2022-02-22 at 17 24 09

@dgieselaar
Copy link
Member Author

dgieselaar commented Feb 23, 2022

@kpatticha:

Overall, it looks pretty good. The only thing I've noticed is when I set a default environment which doesn't exist.

This is a good point - however it is already the case w/ the environment selector in general. It probably doesn't make sense for me to address it in this PR given the planned changes to the environment selector, so I'll go ahead and merge this in as-is.


const matchingRoutes = apmRouter.getRoutesToMatch(location.pathname);

if (last(matchingRoutes)?.path === '/services') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only check if the last matches?

Copy link
Member

@sorenlouv sorenlouv Feb 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if we had a helper like this:

const isServiceInventory = apmRouter.isRoute(location.pathname, '/services')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it's to ensure it only matches when /services is being rendered, and not one of its children. /services doesn't have children now, but when they are added, the redirect might be too aggressive. Maybe it's a little too defensive though, I'll see if there's a better way. I think a helper that takes a route path doesn't really help here, there could be multiple routes that have the same route path (e.g. /).

const location = useLocation();
const history = useHistory();

const query = qs.parse(location.search);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about this?

Suggested change
const query = qs.parse(location.search);
const { query } = useApmParams(`*`);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied via email, will post here as well:

These components are rendered before a route is actually matched, providing
the opportunity to catch invalid route params (eg a missing query param)
and then redirecting to a valid state. The downside is that useApmParams
cannot (or should not) be used.

}),
description: i18n.translate('xpack.observability.defaultApmServiceEnvironmentDescription', {
defaultMessage:
'Set the default environment for the APM app. When left empty, data from all environments will be displayed by default.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good description 👍

@dgieselaar
Copy link
Member Author

dgieselaar commented Feb 25, 2022 via email

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1132 1133 +1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
observability 355 357 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 2.7MB 2.7MB +404.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
observability 87.1KB 87.3KB +207.0B
Unknown metric groups

API count

id before after diff
observability 358 360 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @dgieselaar

@dgieselaar dgieselaar merged commit 405ef9e into elastic:main Mar 1, 2022
@dgieselaar dgieselaar deleted the default-env-setting branch March 1, 2022 12:51
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 3, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 8, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

lucasfcosta pushed a commit to lucasfcosta/kibana that referenced this pull request Mar 8, 2022
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

1 similar comment
@kibanamachine
Copy link
Contributor

Friendly reminder: Looks like this PR hasn’t been backported yet.
To create backports run node scripts/backport --pr 126151 or prevent reminders by adding the backport:skip label.

@dgieselaar dgieselaar added the backport:skip This commit does not require backporting label Mar 10, 2022
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:enhancement Team:APM All issues that need APM UI Team support v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Add setting to specify default environment
7 participants