Skip to content

[maps] fix Maps embeddables in a dashboard not capturing map id in execution context#153616

Merged
nreese merged 14 commits intoelastic:mainfrom
nreese:issue_153218_2
Mar 28, 2023
Merged

[maps] fix Maps embeddables in a dashboard not capturing map id in execution context#153616
nreese merged 14 commits intoelastic:mainfrom
nreese:issue_153218_2

Conversation

@nreese
Copy link
Copy Markdown
Contributor

@nreese nreese commented Mar 24, 2023

#153218

Existing execution context implementation spread results from executionContextServiceStart().get() to add map id. This implementation did not work when map was embedded in another application. When embedded, executionContextServiceStart().get() returned the id of the parent application and not the id for the map.

This PR resolves the issue by building executionContext directly in MapEmbeddable and MapApp. MapApp uses savedObjectId for executionContext.id. MapEmbeddable uses embeddableId for executionContext.id.

The PR also updates the MVT routes to include executionContextId for the execution context with _mvt calls.

Testing

To view execution context in kibana logs, add below to kibana.dev.yml. For more information https://www.elastic.co/guide/en/kibana/8.7/kibana-troubleshooting-trace-query.html

logging:
  loggers:
    - name: execution_context
      level: debug
      appenders: [console]

Execution context for lens and maps panels in dashboard

There is not a lot of consistency for what type and name should be across Kibana. I found this comment for when lens added execution context for lens embeddable that stated type:feature and name:sub_feature. Therefore, I followed the lens example and made type:maps and name:maps since maps does not have sub_features.

[2023-03-23T18:29:12.750-06:00][DEBUG][execution_context] {"type":"application","name":"dashboards","url":"/mth/app/dashboards","page":"app","id":"d98e6530-c9a8-11ed-9340-d743c2c88db8","child":{"type":"maps","name":"maps","id":"91f17723-367d-460e-ad90-dbac1fc072cb","url":"/map/de71f4f0-1902-11e9-919b-ffe5949a18d2","description":"es_geo_grid_source:cluster"}}
[2023-03-23T18:29:12.750-06:00][DEBUG][execution_context] {"type":"application","name":"dashboards","url":"/mth/app/dashboards","page":"app","id":"d98e6530-c9a8-11ed-9340-d743c2c88db8","child":{"type":"maps","name":"maps","id":"91f17723-367d-460e-ad90-dbac1fc072cb","url":"/map/de71f4f0-1902-11e9-919b-ffe5949a18d2","description":"es_term_source:terms"}}
[2023-03-23T18:29:13.241-06:00][DEBUG][execution_context] {"type":"dashboard","name":"dashboards","url":"/mth/app/dashboards","page":"app","id":"d98e6530-c9a8-11ed-9340-d743c2c88db8","description":"single map","child":{"type":"lens","name":"lnsXY","id":"b9e44118-9e67-4c1c-9159-597d8a9f80d1","description":"lens","url":"/mth/app/lens#/edit/32e87880-c9ab-11ed-9340-d743c2c88db8"}}

Execution context for maps

There is not a lot of consistency across kibana for type and name in applications. ExecutionContextService.getDefaultContext returns the below so I stuck with application for type in client and server for type in server. Here is one more link that provides some context value of name property.

return {
      type: 'application',
      name: this.appId,
      url: window.location.pathname,
    };
[2023-03-23T18:30:39.886-06:00][DEBUG][execution_context] {"type":"application","name":"maps","url":"/mth/app/maps/map/de71f4f0-1902-11e9-919b-ffe5949a18d2","id":"de71f4f0-1902-11e9-919b-ffe5949a18d2","page":"editor","description":"es_geo_grid_source:cluster"}
[2023-03-23T18:30:39.886-06:00][DEBUG][execution_context] {"type":"application","name":"maps","url":"/mth/app/maps/map/de71f4f0-1902-11e9-919b-ffe5949a18d2","id":"de71f4f0-1902-11e9-919b-ffe5949a18d2","page":"editor","description":"es_term_source:terms"}

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Mar 27, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

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
maps 266 268 +2

Async chunks

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

id before after diff
maps 2.7MB 2.7MB +816.0B
Unknown metric groups

API count

id before after diff
maps 267 269 +2

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

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

@nreese nreese marked this pull request as ready for review March 27, 2023 21:11
@nreese nreese requested a review from a team as a code owner March 27, 2023 21:11
@nreese nreese added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// release_note:skip Skip the PR/issue when compiling release notes v8.8.0 labels Mar 27, 2023
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

Copy link
Copy Markdown
Contributor

@nickpeihl nickpeihl left a comment

Choose a reason for hiding this comment

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

lgtm! this is great and will make it much easier for users and support to audit and troubleshoot es queries from kibana!

code review and tested logging execution contexts and x-opaque-id headers

}

async getTooltipProperties(properties: unknown): Promise<ITooltipProperty[]> {
async getTooltipProperties(properties: GeoJsonProperties): Promise<ITooltipProperty[]> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯

params.set('executionContextId', executionContextId);
}

return `${mvtUrlServicePath}?${params.toString()}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice use of URLSearchParams!

@nreese nreese merged commit 6907882 into elastic:main Mar 28, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Maps release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants