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] Average page load duration by country chart #43567

Merged
merged 11 commits into from
Aug 29, 2019

Conversation

ogupte
Copy link
Contributor

@ogupte ogupte commented Aug 20, 2019

Adds the map chart from #35571

Screen Shot 2019-08-29 at 2 08 24 PM

Can test locally by generating interesting geo data for the opbeans-rum app:
Use data generation tool at https://github.com/ogupte/apm-ui-seed
apm-ui-seed-geo --host='localhost:9200' --index='apm-8.0.0-transaction' --service-name='client' clean seed list. Then view page-loads for a RUM service.

@ogupte ogupte requested a review from a team as a code owner August 20, 2019 08:00
@ogupte ogupte self-assigned this Aug 20, 2019
@ogupte

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💔 Build Failed

return (
<div style={{ textAlign: 'center' }}>
<div style={{ fontSize: 'larger' }}>{geojsonProperties.name}</div>
<div>Avg. page load duration:</div>
Copy link
Member

Choose a reason for hiding this comment

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

translation?

@@ -13,3 +13,6 @@ bluebird.Promise.setScheduler(function (fn) { global.setImmediate.call(global, f

const MutationObserver = require('mutation-observer');
Object.defineProperty(window, 'MutationObserver', { value: MutationObserver });

const URL = { createObjectURL: () => '' };
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? (Maybe good to leave a comment here anyway).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's necessary since we have tests which attempt to render the map in jsdom in tests. window.URL.createObjectUrl is called when initializing mapbox, so this is added to not break tests.

@dgieselaar
Copy link
Member

Tooltip looks strange in Chrome/OS X:

image

const hoveredFeaturePropertiesRef = useRef<
mapboxgl.MapboxGeoJSONFeature['properties']
>(null);
const isMapReady = useRef<boolean>(false);
Copy link
Member

@dgieselaar dgieselaar Aug 25, 2019

Choose a reason for hiding this comment

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

Could you explain why you're using useRef instead of useState/useCallback? I've got a feeling this code would be simpler and more robust if we avoid useRef.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that useState should be generally preferred over useRef hooks. In the latest commit, i removed most of the useRef, and replaced them with more useCallbacks for event handlers, but but it still requires a useRef pointer to certain callbacks. This is because we're wrapping an evented object with a react view component. The initial useEffect which instantiates everything also sets up event handlers, which should not change between renders. The initial useEffect also references scoped values from that first render in the lifecycle available to the js closure of it's initial execution context.

So this is one of the cases where we must make use of useRef if we want to use functional components. If it was a class-based component, they would exist as instance variables, populated in the constructor.

if (currentLayer) {
map.removeLayer(choroplethLayerId.current);
}
const symbolLayer = (map.getStyle().layers || []).find(
Copy link
Member

Choose a reason for hiding this comment

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

Are we using this layer?

Copy link
Contributor Author

@ogupte ogupte Aug 27, 2019

Choose a reason for hiding this comment

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

The symbol layer comes along with the vector tileset from the Elastic Maps Service. We need to reference it so that we can place our custom layer before the symbol layer so it doesn't obscure labels in the map.

@sorenlouv
Copy link
Member

Like @dgieselaar I think we should only make the properties we actually use configurable. I'm okay with hardcoding the rest (as constants) if that will simplify the implementation.

@ogupte ogupte force-pushed the apm-35571-rum-ui-region-chart branch from ad24105 to 9e2735f Compare August 28, 2019 09:40
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ogupte ogupte force-pushed the apm-35571-rum-ui-region-chart branch from 9e2735f to bb892e3 Compare August 28, 2019 16:46
@sorenlouv
Copy link
Member

I'm seeing this odd behaviour when hovering over the map:
geo-map-glitch

@sorenlouv
Copy link
Member

sorenlouv commented Aug 28, 2019

Tooltips

The tooltips can be a little hard to read when the text overlaps with continent names and such. I think adding a solid background color (white) would be good.

Screen Shot 2019-08-28 at 22 28 18

Screen Shot 2019-08-28 at 22 28 05

@sorenlouv
Copy link
Member

sorenlouv commented Aug 28, 2019

Legend

I think the legend values should be rounded
Screen Shot 2019-08-28 at 22 30 36

In this case the viz is based on a single doc. It's a bit of an edge case but perhaps the lower limit should always be 0ms? We do the same with the response time charts so might make sense for this too. (that's probably not a good idea after all)
Screen Shot 2019-08-28 at 22 32 49

Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Renovate changes LGTM

@dgieselaar
Copy link
Member

@ogupte I'll excuse myself from further reviewing 😀 don't want to add a lot of noise given the time constraints, and in general I agree with @sqren's feedback.

@ogupte ogupte force-pushed the apm-35571-rum-ui-region-chart branch from b988781 to 0c618b0 Compare August 29, 2019 15:43
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

- fixed issue with map rendering multiple times
- renamed initial props to start with 'initial'
- added some more code comments
- check that a layer exists before querying features
- cleans up mouseover handler, which updates on state changes
- formats doc count for display
- style improvements
- Only render tooltip when there's data
- add better typing around Geojson propertier for world countries
@ogupte ogupte force-pushed the apm-35571-rum-ui-region-chart branch from 3445711 to 29bef0f Compare August 29, 2019 20:27
@ogupte ogupte requested a review from sorenlouv August 29, 2019 20:38
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.

🌎

@nik9000
Copy link
Member

nik9000 commented Aug 29, 2019

@elasticmachine run elasticsearch-ci/docs

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ogupte ogupte merged commit 3c68c98 into elastic:master Aug 29, 2019
ogupte added a commit to ogupte/kibana that referenced this pull request Aug 29, 2019
* [APM] Adds chart for page load averages by country in RUM page-load view

* [APM] Simplified and refined ChoroplethMap. Added legend labels.

* - Replaced Map legend slices with smooth gradient
- fixed issue with map rendering multiple times
- renamed initial props to start with 'initial'
- added some more code comments

* use correct i18n ids

* - base color progression calc directly on euiColorPrimary
- check that a layer exists before querying features

* Addressed code review feedback

* - fixes issue where min/max was not a finite value
- cleans up mouseover handler, which updates on state changes
- formats doc count for display
- style improvements

* addressed PR feedback & updated renovate.json5

* - Removed the Legend from the ChoroplethMap
- Only render tooltip when there's data

* - fix hover state not clearing properly
- add better typing around Geojson propertier for world countries

* added missing css import
ogupte added a commit to ogupte/kibana that referenced this pull request Aug 29, 2019
* [APM] Adds chart for page load averages by country in RUM page-load view

* [APM] Simplified and refined ChoroplethMap. Added legend labels.

* - Replaced Map legend slices with smooth gradient
- fixed issue with map rendering multiple times
- renamed initial props to start with 'initial'
- added some more code comments

* use correct i18n ids

* - base color progression calc directly on euiColorPrimary
- check that a layer exists before querying features

* Addressed code review feedback

* - fixes issue where min/max was not a finite value
- cleans up mouseover handler, which updates on state changes
- formats doc count for display
- style improvements

* addressed PR feedback & updated renovate.json5

* - Removed the Legend from the ChoroplethMap
- Only render tooltip when there's data

* - fix hover state not clearing properly
- add better typing around Geojson propertier for world countries

* added missing css import
ogupte added a commit that referenced this pull request Aug 30, 2019
* [APM] Adds chart for page load averages by country in RUM page-load view

* [APM] Simplified and refined ChoroplethMap. Added legend labels.

* - Replaced Map legend slices with smooth gradient
- fixed issue with map rendering multiple times
- renamed initial props to start with 'initial'
- added some more code comments

* use correct i18n ids

* - base color progression calc directly on euiColorPrimary
- check that a layer exists before querying features

* Addressed code review feedback

* - fixes issue where min/max was not a finite value
- cleans up mouseover handler, which updates on state changes
- formats doc count for display
- style improvements

* addressed PR feedback & updated renovate.json5

* - Removed the Legend from the ChoroplethMap
- Only render tooltip when there's data

* - fix hover state not clearing properly
- add better typing around Geojson propertier for world countries

* added missing css import
ogupte added a commit that referenced this pull request Aug 30, 2019
* [APM] Adds chart for page load averages by country in RUM page-load view

* [APM] Simplified and refined ChoroplethMap. Added legend labels.

* - Replaced Map legend slices with smooth gradient
- fixed issue with map rendering multiple times
- renamed initial props to start with 'initial'
- added some more code comments

* use correct i18n ids

* - base color progression calc directly on euiColorPrimary
- check that a layer exists before querying features

* Addressed code review feedback

* - fixes issue where min/max was not a finite value
- cleans up mouseover handler, which updates on state changes
- formats doc count for display
- style improvements

* addressed PR feedback & updated renovate.json5

* - Removed the Legend from the ChoroplethMap
- Only render tooltip when there's data

* - fix hover state not clearing properly
- add better typing around Geojson propertier for world countries

* added missing css import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants