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

[Discover] Extend EBT context with a list of activated context-aware profiles #192908

Merged
merged 26 commits into from
Sep 24, 2024

Conversation

jughosta
Copy link
Contributor

@jughosta jughosta commented Sep 13, 2024

Summary

This PR extends EBT context with discoverProfiles - a list of active context-aware profiles.

Screenshot 2024-09-16 at 17 30 47

Testing

Enable "Usage collection" global setting.

Navigate to Discover and observe kibana-browser requests in Network tab.

Checklist

@jughosta jughosta added release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Data, DataViews) backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer labels Sep 13, 2024
@jughosta jughosta self-assigned this Sep 13, 2024
@jughosta jughosta marked this pull request as ready for review September 17, 2024 14:13
@jughosta jughosta requested a review from a team as a code owner September 17, 2024 14:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@jughosta jughosta changed the title [Discover] Extend ebt context with a list of activated context-aware profiles [Discover] Extend EBT context with a list of activated context-aware profiles Sep 17, 2024
@jughosta
Copy link
Contributor Author

Noticed an issue that once Discover is visited all following EBT events on other Kibana pages still have dscProfiles in their context. We should probably reset it when user navigates away from Discover, shouldn't we?

@jughosta jughosta marked this pull request as draft September 18, 2024 14:29
@kertal
Copy link
Member

kertal commented Sep 19, 2024

Noticed an issue that once Discover is visited all following EBT events on other Kibana pages still have dscProfiles in their context. We should probably reset it when user navigates away from Discover, shouldn't we?

I do agree this would be great, if we could do that, I think it was discussed as an acceptable tradeoff in an one older discussion if we can't. Just wanted to ask @davismcphee @flash1293, we are adding dscProfiles which makes absolutely sense for our current use case, but let's think beyond that, let's say the contextual awareness won't be limited to Discover, but will conquer the 🌏 ... or just Kibana, should we already think of making this more generic, like contextualProfiles, caProfiles (california 🏄 ) , someThingElse?

@jughosta
Copy link
Contributor Author

I updated the approach, so now it should set and update dscProfiles only while on Discover page. If user navigates to another app then dscProfiles would be reset to [] and populated again on return to Discover.

802d3a2

Open for suggestions if dscProfiles naming does not fit.

@jughosta jughosta marked this pull request as ready for review September 19, 2024 09:47
Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Code changes look good and it works well, thanks! Left a few minor comments but nothing blocking.

Personally I'm ok with using a Discover specific property name to start since we don't know much about how profiles could work outside of Discover yet. We can always adjust later if needed. My only suggestion would be that maybe discoverProfiles would be clearer than dscProfiles for those unfamiliar with the property, but I'm happy with it either way.

@@ -130,6 +134,7 @@ export class ProfilesManager {
return;
}

this.trackActiveProfiles(this.rootContext$.getValue().profileId, context.profileId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also call this during resolveRootProfile in the case that an event could fire between when the root profile is resolved and the data source profile is resolved? Probably not particularly likely, but maybe possible in cases where searchOnPageLoad is off?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davismcphee I don't think that it would be helpful to report a default default-data-source-profile in this case. Better to track the active profiles when users actually access their data and we know for sure what data source was it. Then we would have a cleaner reporting regarding the usage of one profile versus another.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough 👍 It's easy enough change later on anyway if we ever identify a need for this

constructor() {}

// https://docs.elastic.dev/telemetry/collection/event-based-telemetry
public register({ core }: { core: CoreSetup }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Initially I was confused about what register actually did until I read the code. I wonder if something like initialize would be clearer for this?

type: 'keyword',
_meta: {
description:
'List of profiles which are activated by Discover Context Awareness logic',
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
'List of profiles which are activated by Discover Context Awareness logic',
'List of active Discover context awareness profiles',

Just a suggestion for a potentially simpler description.

@@ -354,6 +373,7 @@ export class DiscoverPlugin
history: this.historyService.getHistory(),
urlTracker: this.urlTracker!,
profilesManager,
ebtContextManager: profilesManager.ebtContextManager,
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than making profilesManager.ebtContextManager public, could we instead make it private and just pass ebtContextManager to getDiscoverServices? It feels like the EBT manager should be just an implementation detail of the profiles manager.

);
}

private createEmptyProfilesManager() {
return new ProfilesManager(
new RootProfileService(),
new DataSourceProfileService(),
new DocumentProfileService()
new DocumentProfileService(),
new DiscoverEBTContextManager() // it's not enabled outside of Discover
Copy link
Contributor

Choose a reason for hiding this comment

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

I sort of overlooked that this approach wouldn't work for embeddables in our initial discussions about it. I think it works well for events in Discover and we should keep it, but I also feel like we may need an additional approach later not based around global EBT context to help track events in dashboard panels. This still seems like a great place to start though since Discover usage is most important right now.

@jughosta
Copy link
Contributor Author

@davismcphee Thanks for the review! I renamed to discoverProfiles and address your other suggestions.

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Latest changes LGTM 👍 Thanks for improving our telemetry!

@@ -130,6 +134,7 @@ export class ProfilesManager {
return;
}

this.trackActiveProfiles(this.rootContext$.getValue().profileId, context.profileId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough 👍 It's easy enough change later on anyway if we ever identify a need for this

@jughosta jughosta enabled auto-merge (squash) September 24, 2024 19:45
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 996 997 +1

Page load bundle

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

id before after diff
discover 47.6KB 49.1KB +1.5KB

History

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

cc @jughosta

@jughosta jughosta merged commit c28af87 into elastic:main Sep 24, 2024
20 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 24, 2024
…profiles (elastic#192908)

- Closes elastic#186109

## Summary

This PR extends EBT context with `dscProfiles` - a list of active
context-aware profiles.

<img width="981" alt="Screenshot 2024-09-16 at 17 30 47"
src="https://github.com/user-attachments/assets/64d49abc-3ee0-4d5a-8283-cdca5d78f963">

## Testing

Enable "Usage collection" global setting.

Navigate to Discover and observe `kibana-browser` requests in Network
tab.

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit c28af87)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 24, 2024
…aware profiles (#192908) (#193926)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover] Extend EBT context with a list of activated context-aware
profiles (#192908)](#192908)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Rechkunova","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-24T21:08:21Z","message":"[Discover]
Extend EBT context with a list of activated context-aware profiles
(#192908)\n\n- Closes
https://github.com/elastic/kibana/issues/186109\r\n\r\n##
Summary\r\n\r\nThis PR extends EBT context with `dscProfiles` - a list
of active\r\ncontext-aware profiles.\r\n\r\n<img width=\"981\"
alt=\"Screenshot 2024-09-16 at 17 30
47\"\r\nsrc=\"https://github.com/user-attachments/assets/64d49abc-3ee0-4d5a-8283-cdca5d78f963\">\r\n\r\n\r\n##
Testing\r\n\r\nEnable \"Usage collection\" global
setting.\r\n\r\nNavigate to Discover and observe `kibana-browser`
requests in Network\r\ntab.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"c28af871d2fa4d8e9f0edd0eafad4d10669a62f5","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-minor","Project:OneDiscover"],"title":"[Discover]
Extend EBT context with a list of activated context-aware
profiles","number":192908,"url":"https://github.com/elastic/kibana/pull/192908","mergeCommit":{"message":"[Discover]
Extend EBT context with a list of activated context-aware profiles
(#192908)\n\n- Closes
https://github.com/elastic/kibana/issues/186109\r\n\r\n##
Summary\r\n\r\nThis PR extends EBT context with `dscProfiles` - a list
of active\r\ncontext-aware profiles.\r\n\r\n<img width=\"981\"
alt=\"Screenshot 2024-09-16 at 17 30
47\"\r\nsrc=\"https://github.com/user-attachments/assets/64d49abc-3ee0-4d5a-8283-cdca5d78f963\">\r\n\r\n\r\n##
Testing\r\n\r\nEnable \"Usage collection\" global
setting.\r\n\r\nNavigate to Discover and observe `kibana-browser`
requests in Network\r\ntab.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"c28af871d2fa4d8e9f0edd0eafad4d10669a62f5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192908","number":192908,"mergeCommit":{"message":"[Discover]
Extend EBT context with a list of activated context-aware profiles
(#192908)\n\n- Closes
https://github.com/elastic/kibana/issues/186109\r\n\r\n##
Summary\r\n\r\nThis PR extends EBT context with `dscProfiles` - a list
of active\r\ncontext-aware profiles.\r\n\r\n<img width=\"981\"
alt=\"Screenshot 2024-09-16 at 17 30
47\"\r\nsrc=\"https://github.com/user-attachments/assets/64d49abc-3ee0-4d5a-8283-cdca5d78f963\">\r\n\r\n\r\n##
Testing\r\n\r\nEnable \"Usage collection\" global
setting.\r\n\r\nNavigate to Discover and observe `kibana-browser`
requests in Network\r\ntab.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<[email protected]>","sha":"c28af871d2fa4d8e9f0edd0eafad4d10669a62f5"}}]}]
BACKPORT-->

Co-authored-by: Julia Rechkunova <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Project:OneDiscover Enrich Discover with contextual awareness / Merge with Logs Explorer release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover App Team (Document Explorer, Saved Search, Surrounding documents, Data, DataViews) v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OneDiscover] Add contextual awareness resolution results to EBT telemetry events
6 participants