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] Explicitly set environment for cross-service links #87481

Merged
merged 10 commits into from
Jan 15, 2021

Conversation

dgieselaar
Copy link
Member

Closes #87028.

@dgieselaar dgieselaar added release_note:fix Team:APM All issues that need APM UI Team support v7.11.0 labels Jan 6, 2021
@dgieselaar dgieselaar requested a review from a team as a code owner January 6, 2021 13:41
@elasticmachine
Copy link
Contributor

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

@dgieselaar
Copy link
Member Author

@elasticmachine merge upstream

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

lgtm. I expect we'll remove the logic in isEnvironmentEqualToQueryEnvironment in 7.12 as we remove the "all" option?

@dgieselaar
Copy link
Member Author

@sqren I made some changes, maybe good to have another look

Comment on lines 38 to 39
requestedEnvironment?: string,
queryEnvironment?: string
Copy link
Member

@sorenlouv sorenlouv Jan 12, 2021

Choose a reason for hiding this comment

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

Perhaps:

Suggested change
requestedEnvironment?: string,
queryEnvironment?: string
requestedEnvironment?: string,
currentEnvironment?: string

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 wanted to keep this as queryEnvironment because how an empty value is interpreted is specific to whether it's a query parameter. Maybe currentQueryEnvironment is a good compromise here, but happy to go with your suggestion as well.

) {
const normalizedRequestedEnvironment =
requestedEnvironment || ENVIRONMENT_NOT_DEFINED.value;
const normalizedQueryEnvironment = queryEnvironment || ENVIRONMENT_ALL.value;
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should change the default so that if no environment is set (in the url) it'll default to ENVIRONMENT_NOT_DEFINED.value.

Ideally when empty I think it should pick "production" if that's available or the top environment. This is similar to what we do with transaction type.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I think all is a good default here - there's no all option for transaction types so maybe not the right thing to compare it to.

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

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

Just a few comments. Feel free to merge as-is

@@ -33,3 +33,18 @@ export const ENVIRONMENT_NOT_DEFINED = {
export function getEnvironmentLabel(environment: string) {
return environmentLabels[environment] || environment;
}

export function getEnvironmentUrlParam(
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment why this helper is needed?

Comment on lines 78 to 81
const nextEnvironment = getEnvironmentUrlParam(
rootTransaction?.service.environment,
environment
);
Copy link
Member

Choose a reason for hiding this comment

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

This would be easier to understand if it was destructured:

Suggested change
const nextEnvironment = getEnvironmentUrlParam(
rootTransaction?.service.environment,
environment
);
const nextEnvironment = getEnvironmentUrlParam({
requestedEnvironment: rootTransaction?.service.environment,
currentEnvironment: environment
});

@@ -11,7 +11,7 @@ export function useServiceMapHref(serviceName?: string) {
const pathFor = serviceName
? `/services/${serviceName}/service-map`
: '/service-map';
return useAPMHref(pathFor);
return useAPMHref({ path: pathFor });
Copy link
Member

Choose a reason for hiding this comment

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

Can you rename pathFor to path or inline it?

Suggested change
return useAPMHref({ path: pathFor });
return useAPMHref({ path });


return getAPMHref({ basePath, path, query, search });
return getAPMHref({ basePath, path, query: nextQuery, search });
Copy link
Member

Choose a reason for hiding this comment

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

Good idea destructuring useAPMHref 👍

As I mentioned to @cauemarcondes in another PR, I don't think getAPMHref should take both query and search (the latter is essentially just a serialised version of the former). But that can wait until 7.12.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
apm 5.5MB 5.5MB +2.3KB

History

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

@dgieselaar dgieselaar changed the title [APM] Explicitly set environment for cross-service links if needed [APM] Explicitly set environment for cross-service links Jan 15, 2021
@dgieselaar dgieselaar merged commit f5ec1dc into elastic:master Jan 15, 2021
@dgieselaar dgieselaar deleted the environment-cross-service branch January 15, 2021 21:34
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Jan 15, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dgieselaar added a commit to dgieselaar/kibana that referenced this pull request Jan 15, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dgieselaar added a commit that referenced this pull request Jan 17, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dgieselaar added a commit that referenced this pull request Jan 17, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 18, 2021
* master: (33 commits)
  [Security Solution][Case] Fix patch cases integration test with alerts (elastic#88311)
  [Security Solutions][Detection Engine] Removes duplicate API calls (elastic#88420)
  Fix log msg (elastic#88370)
  [Test] Add tag cloud visualization to dashboard in functional test for reporting (elastic#87600)
  removing kibana-core-ui from codeowners (elastic#88111)
  [Alerting] Migrate Event Log plugin to TS project references (elastic#81557)
  [Maps] fix zooming while drawing shape filter logs errors in console (elastic#88413)
  Porting fixes 1 (elastic#88477)
  [APM] Explicitly set environment for cross-service links (elastic#87481)
  chore(NA): remove mocha junit ci integrations (elastic#88129)
  [APM] Only display relevant sections for rum agent in service overview (elastic#88410)
  [Enterprise Search] Automatically mock shared logic files (elastic#88494)
  [APM] Disable Create custom link button on Transaction details page for read-only users
  [Docs] clean-up vega map reference documenation (elastic#88487)
  [Security Solution] Fix Timeline event details layout (elastic#88377)
  Change DELETE to POST for _bulk_delete to avoid incompatibility issues (elastic#87914)
  [Monitoring] Change cloud messaging on no data page (elastic#88375)
  [Uptime] clear ping state when PingList component in unmounted (elastic#88321)
  [APM] Consistent terminology for latency and throughput (elastic#88452)
  fix copy (elastic#88481)
  ...
JasonStoltz pushed a commit to JasonStoltz/kibana that referenced this pull request Jan 19, 2021
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix Team:APM All issues that need APM UI Team support v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Service environment is implicitly/wrongly carried over when linking to another service
4 participants