-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover][Oblt] Display Attributes doc viewer tab for Observability #222391
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
Merged
kpatticha
merged 27 commits into
elastic:main
from
kpatticha:221919-discover-attributes-tab
Jun 13, 2025
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
746d695
[Discover][Oblt] Display Attributes tab for Observability
kpatticha c37e031
Rename folder
kpatticha bc6a9bc
[WIP] Extend base profile
kpatticha ea22a80
Group oblt document profile providers
kpatticha b0df413
Add base observability document profile
kpatticha 774ef65
Revert extending the profile
kpatticha 95179dc
Display attributes doc viewer tab
kpatticha 919bcd9
Clean up
kpatticha 04c488d
Add test
kpatticha 8fc88bd
Fix typo
kpatticha 28ff90d
Disable attributes doc viewer tab by default
kpatticha 80d9234
Merge branch 'main' into 221919-discover-attributes-tab
kpatticha 6251126
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 5bb273d
Use o11y root profile
kpatticha a0ac149
For observability root provder force to use the solutiontype
kpatticha 4d4288a
Use the solutionType to check oblt project
kpatticha fc4d690
Merge branch '221919-discover-attributes-tab' of github.com:kpatticha…
kpatticha 5871125
clean up
kpatticha f0f8de9
Fix tests
kpatticha a56fa04
Update the test to check the solutionType
kpatticha 1aec1f6
Add test for getDocViewer
kpatticha 40131eb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 0789ee8
Fix eslint
kpatticha 8f18a3e
Merge branch '221919-discover-attributes-tab' of github.com:kpatticha…
kpatticha 66cc91e
Merge branch 'main' of github.com:elastic/kibana into 221919-discover…
kpatticha f493d35
Check for the solutionType
kpatticha f3972ea
Merge branch 'main' of github.com:elastic/kibana into 221919-discover…
kpatticha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...blic/context_awareness/profile_providers/observability/observability_profile_providers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import type { ProfileProviderServices } from '../profile_provider_services'; | ||
| import { createObservabilityLogDocumentProfileProvider } from './log_document_profile'; | ||
| import { createObservabilityTracesSpanDocumentProfileProvider } from './traces_document_profile/span_document_profile'; | ||
| import { createObservabilityTracesTransactionDocumentProfileProvider } from './traces_document_profile/transaction_document_profile'; | ||
|
|
||
| export const createObservabilityDocumentProfileProviders = ( | ||
| providerServices: ProfileProviderServices | ||
| ) => { | ||
| return [ | ||
| createObservabilityLogDocumentProfileProvider(providerServices), | ||
| createObservabilityTracesSpanDocumentProfileProvider(providerServices), | ||
| createObservabilityTracesTransactionDocumentProfileProvider(providerServices), | ||
| ]; | ||
| }; |
40 changes: 40 additions & 0 deletions
40
...ss/profile_providers/observability/observability_root_profile/accessors/get_doc_viewer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { i18n } from '@kbn/i18n'; | ||
| import { hasAnyFieldWithPrefixes } from '../../utils/has_any_field_with_prefixes'; | ||
| import type { ObservabilityRootProfileProvider } from '../types'; | ||
|
|
||
| const attributesPrefixes = ['attributes.', 'scope.attributes.', 'resource.attributes.']; | ||
| const hasAnyAttributesField = hasAnyFieldWithPrefixes(attributesPrefixes); | ||
|
|
||
| export const getDocViewer: ObservabilityRootProfileProvider['profile']['getDocViewer'] = | ||
| (prev) => (params) => { | ||
| const prevDocViewer = prev(params); | ||
|
|
||
| return { | ||
| ...prevDocViewer, | ||
| docViewsRegistry: (registry) => { | ||
| if (hasAnyAttributesField(params.record)) { | ||
| registry.add({ | ||
| id: 'doc_view_obs_attributes_overview', | ||
| title: i18n.translate('discover.docViews.observability.attributesOverview.title', { | ||
| defaultMessage: 'Attributes', | ||
| }), | ||
| order: 9, | ||
| component: (props) => { | ||
| return 'Attributes Overview'; | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| return prevDocViewer.docViewsRegistry(registry); | ||
| }, | ||
| }; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
...vability_root_profile/sub_profiles/observability_root_profile_with_attributes_tab.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { buildDataTableRecord } from '@kbn/discover-utils'; | ||
| import { createContextAwarenessMocks } from '../../../../__mocks__'; | ||
| import { SolutionType } from '../../../../profiles'; | ||
| import { createObservabilityRootProfileProvider } from '../profile'; | ||
| import { createObservabilityRootProfileProviderWithAttributesTab } from './observability_root_profile_with_attributes_tab'; | ||
| import { DocViewsRegistry } from '@kbn/unified-doc-viewer'; | ||
|
|
||
| const mockServices = createContextAwarenessMocks().profileProviderServices; | ||
|
|
||
| describe('createObservabilityRootProfileProviderWithAttributesTab', () => { | ||
| const observabilityRootProfileProvider = createObservabilityRootProfileProvider(mockServices); | ||
| const observabilityRootProfileProviderWithAttributes = | ||
| createObservabilityRootProfileProviderWithAttributesTab(observabilityRootProfileProvider); | ||
|
|
||
| describe('getDocViewer', () => { | ||
| it('does NOT add attributes doc viewer tab to the registry when the record has no attributes fields', () => { | ||
| const getDocViewer = observabilityRootProfileProviderWithAttributes.profile.getDocViewer!( | ||
| () => ({ | ||
| title: 'test title', | ||
| docViewsRegistry: (registry) => registry, | ||
| }), | ||
| { | ||
| context: { | ||
| solutionType: SolutionType.Observability, | ||
| allLogsIndexPattern: mockServices.logsContextService.getAllLogsIndexPattern(), | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const docViewer = getDocViewer({ | ||
| record: buildMockRecord('test-index', { | ||
| foo: 'bar', | ||
| }), | ||
| }); | ||
|
|
||
| const registry = new DocViewsRegistry(); | ||
|
|
||
| expect(docViewer.title).toBe('test title'); | ||
| expect(registry.getAll()).toHaveLength(0); | ||
|
|
||
| docViewer.docViewsRegistry(registry); | ||
|
|
||
| expect(registry.getAll()).toHaveLength(0); | ||
| }); | ||
| it('adds attributes doc viwer tab to the registry when the record has any attributes. field', () => { | ||
| const getDocViewer = observabilityRootProfileProviderWithAttributes.profile.getDocViewer!( | ||
| () => ({ | ||
| title: 'test title', | ||
| docViewsRegistry: (registry) => registry, | ||
| }), | ||
| { | ||
| context: { | ||
| solutionType: SolutionType.Observability, | ||
| allLogsIndexPattern: mockServices.logsContextService.getAllLogsIndexPattern(), | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const docViewer = getDocViewer({ | ||
| record: buildMockRecord('test-index', { | ||
| 'attributes.foo': 'bar', | ||
| }), | ||
| }); | ||
|
|
||
| const registry = new DocViewsRegistry(); | ||
|
|
||
| expect(docViewer.title).toBe('test title'); | ||
| expect(registry.getAll()).toHaveLength(0); | ||
| docViewer.docViewsRegistry(registry); | ||
|
|
||
| expect(registry.getAll()).toHaveLength(1); | ||
|
|
||
| expect(registry.getAll()[0]).toEqual( | ||
| expect.objectContaining({ | ||
| id: 'doc_view_obs_attributes_overview', | ||
| title: 'Attributes', | ||
| order: 9, | ||
| component: expect.any(Function), | ||
| }) | ||
| ); | ||
| }); | ||
| it('adds attributes doc viwer tab to the registry when the record has any scope.attributes. field', () => { | ||
| const getDocViewer = observabilityRootProfileProviderWithAttributes.profile.getDocViewer!( | ||
| () => ({ | ||
| title: 'test title', | ||
| docViewsRegistry: (registry) => registry, | ||
| }), | ||
| { | ||
| context: { | ||
| solutionType: SolutionType.Observability, | ||
| allLogsIndexPattern: mockServices.logsContextService.getAllLogsIndexPattern(), | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const docViewer = getDocViewer({ | ||
| record: buildMockRecord('test-index', { | ||
| 'scope.attributes.foo': 'bar', | ||
| }), | ||
| }); | ||
|
|
||
| const registry = new DocViewsRegistry(); | ||
|
|
||
| expect(docViewer.title).toBe('test title'); | ||
| expect(registry.getAll()).toHaveLength(0); | ||
| docViewer.docViewsRegistry(registry); | ||
|
|
||
| expect(registry.getAll()).toHaveLength(1); | ||
|
|
||
| expect(registry.getAll()[0]).toEqual( | ||
| expect.objectContaining({ | ||
| id: 'doc_view_obs_attributes_overview', | ||
| title: 'Attributes', | ||
| order: 9, | ||
| component: expect.any(Function), | ||
| }) | ||
| ); | ||
| }); | ||
| it('adds attributes doc viwer tab to the registry when the record has any resource.attributes. field', () => { | ||
| const getDocViewer = observabilityRootProfileProviderWithAttributes.profile.getDocViewer!( | ||
| () => ({ | ||
| title: 'test title', | ||
| docViewsRegistry: (registry) => registry, | ||
| }), | ||
| { | ||
| context: { | ||
| solutionType: SolutionType.Observability, | ||
| allLogsIndexPattern: mockServices.logsContextService.getAllLogsIndexPattern(), | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| const docViewer = getDocViewer({ | ||
| record: buildMockRecord('test-index', { | ||
| 'resource.attributes.foo': 'bar', | ||
| }), | ||
| }); | ||
|
|
||
| const registry = new DocViewsRegistry(); | ||
|
|
||
| expect(docViewer.title).toBe('test title'); | ||
| expect(registry.getAll()).toHaveLength(0); | ||
| docViewer.docViewsRegistry(registry); | ||
|
|
||
| expect(registry.getAll()).toHaveLength(1); | ||
|
|
||
| expect(registry.getAll()[0]).toEqual( | ||
| expect.objectContaining({ | ||
| id: 'doc_view_obs_attributes_overview', | ||
| title: 'Attributes', | ||
| order: 9, | ||
| component: expect.any(Function), | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| const buildMockRecord = (index: string, fields: Record<string, unknown> = {}) => | ||
| buildDataTableRecord({ | ||
| _id: '', | ||
| _index: index, | ||
| fields: { | ||
| _index: index, | ||
| ...fields, | ||
| }, | ||
| }); |
23 changes: 23 additions & 0 deletions
23
...observability_root_profile/sub_profiles/observability_root_profile_with_attributes_tab.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { extendProfileProvider } from '../../../extend_profile_provider'; | ||
| import { getDocViewer } from '../accessors/get_doc_viewer'; | ||
| import type { ObservabilityRootProfileProvider } from '../types'; | ||
|
|
||
| export const createObservabilityRootProfileProviderWithAttributesTab = ( | ||
| observabilityRootProfileProvider: ObservabilityRootProfileProvider | ||
| ) => | ||
| extendProfileProvider(observabilityRootProfileProvider, { | ||
| profileId: 'observability-root-profile-with-attributes-tab', | ||
| isExperimental: true, | ||
| profile: { | ||
| getDocViewer, | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.