Skip to content
Merged
Show file tree
Hide file tree
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 Jun 3, 2025
c37e031
Rename folder
kpatticha Jun 9, 2025
bc6a9bc
[WIP] Extend base profile
kpatticha Jun 9, 2025
ea22a80
Group oblt document profile providers
kpatticha Jun 10, 2025
b0df413
Add base observability document profile
kpatticha Jun 10, 2025
774ef65
Revert extending the profile
kpatticha Jun 10, 2025
95179dc
Display attributes doc viewer tab
kpatticha Jun 10, 2025
919bcd9
Clean up
kpatticha Jun 10, 2025
04c488d
Add test
kpatticha Jun 10, 2025
8fc88bd
Fix typo
kpatticha Jun 10, 2025
28ff90d
Disable attributes doc viewer tab by default
kpatticha Jun 10, 2025
80d9234
Merge branch 'main' into 221919-discover-attributes-tab
kpatticha Jun 10, 2025
6251126
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 10, 2025
5bb273d
Use o11y root profile
kpatticha Jun 11, 2025
a0ac149
For observability root provder force to use the solutiontype
kpatticha Jun 11, 2025
4d4288a
Use the solutionType to check oblt project
kpatticha Jun 11, 2025
fc4d690
Merge branch '221919-discover-attributes-tab' of github.com:kpatticha…
kpatticha Jun 11, 2025
5871125
clean up
kpatticha Jun 11, 2025
f0f8de9
Fix tests
kpatticha Jun 12, 2025
a56fa04
Update the test to check the solutionType
kpatticha Jun 12, 2025
1aec1f6
Add test for getDocViewer
kpatticha Jun 12, 2025
40131eb
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 12, 2025
0789ee8
Fix eslint
kpatticha Jun 12, 2025
8f18a3e
Merge branch '221919-discover-attributes-tab' of github.com:kpatticha…
kpatticha Jun 12, 2025
66cc91e
Merge branch 'main' of github.com:elastic/kibana into 221919-discover…
kpatticha Jun 13, 2025
f493d35
Check for the solutionType
kpatticha Jun 13, 2025
f3972ea
Merge branch 'main' of github.com:elastic/kibana into 221919-discover…
kpatticha Jun 13, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
import type { DataTableRecord } from '@kbn/discover-utils';
import { BehaviorSubject } from 'rxjs';
import type { DocumentProfileProvider } from '../../../profiles';
import { DocumentType } from '../../../profiles';
import { DocumentType, SolutionType } from '../../../profiles';
import type { ProfileProviderServices } from '../../profile_provider_services';
import { createGetDocViewer } from './accessors';
import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts';
import type { LogOverviewContext } from '../logs_data_source_profile/profile';
import { isLogsDataSourceContext } from '../logs_data_source_profile/profile';

Expand All @@ -29,7 +28,7 @@ export const createObservabilityLogDocumentProfileProvider = (
getDocViewer: createGetDocViewer(services),
},
resolve: ({ record, rootContext, dataSourceContext }) => {
if (rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) {
if (rootContext.solutionType !== SolutionType.Observability) {
return { isMatch: false };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { BehaviorSubject } from 'rxjs';
import type { DataSourceContext, DataSourceProfileProvider } from '../../../profiles';
import { DataSourceCategory } from '../../../profiles';
import { DataSourceCategory, SolutionType } from '../../../profiles';
import type { ProfileProviderServices } from '../../profile_provider_services';
import {
getCellRenderers,
Expand All @@ -19,7 +19,6 @@ import {
getPaginationConfig,
} from './accessors';
import { extractIndexPatternFrom } from '../../extract_index_pattern_from';
import { OBSERVABILITY_ROOT_PROFILE_ID } from '../consts';
import type { ContextWithProfileId } from '../../../profile_service';

export type LogOverViewAccordionExpandedValue = 'stacktrace' | 'quality_issues' | undefined;
Expand Down Expand Up @@ -54,7 +53,7 @@ export const createLogsDataSourceProfileProvider = (
getPaginationConfig,
},
resolve: (params) => {
if (params.rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) {
if (params.rootContext.solutionType !== SolutionType.Observability) {
return { isMatch: false };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

import { createRegExpPatternFrom, testPatternAgainstAllowedList } from '@kbn/data-view-utils';
import { BehaviorSubject } from 'rxjs';
import { DataSourceCategory } from '../../../../profiles';
import { DataSourceCategory, SolutionType } from '../../../../profiles';
import { extractIndexPatternFrom } from '../../../extract_index_pattern_from';
import { OBSERVABILITY_ROOT_PROFILE_ID } from '../../consts';
import type { LogOverviewContext, LogsDataSourceProfileProvider } from '../profile';

export const createResolve = (
Expand All @@ -22,7 +21,7 @@ export const createResolve = (
]);

return (params) => {
if (params.rootContext.profileId !== OBSERVABILITY_ROOT_PROFILE_ID) {
if (params.rootContext.solutionType !== SolutionType.Observability) {
return { isMatch: false };
}

Expand Down
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),
];
};
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);
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export { createGetAppMenu } from './get_app_menu';
export { getDefaultAdHocDataViews } from './get_default_ad_hoc_data_views';
export { getDocViewer } from './get_doc_viewer';
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export { createObservabilityRootProfileProvider } from './profile';
import type { ProfileProviderServices } from '../../profile_provider_services';
import { createObservabilityRootProfileProvider } from './profile';
import { createObservabilityRootProfileProviderWithAttributesTab } from './sub_profiles/observability_root_profile_with_attributes_tab';

export const createObservabilityRootProfileProviders = (
providerServices: ProfileProviderServices
) => {
const observabilityRootProfileProvider = createObservabilityRootProfileProvider(providerServices);

return [
createObservabilityRootProfileProviderWithAttributesTab(observabilityRootProfileProvider),
observabilityRootProfileProvider,
];
};
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,
},
});
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,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { RootProfileProvider } from '../../..';
import type { RootProfileProvider, SolutionType } from '../../..';

export interface ObservabilityRootProfileContext {
allLogsIndexPattern: string | undefined;
solutionType: SolutionType.Observability;
}

export type ObservabilityRootProfileProvider = RootProfileProvider<ObservabilityRootProfileContext>;
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('tracesDataSourceProfileProvider', () => {
).toEqual(RESOLUTION_MISMATCH);
});

it("should NOT match when the root context isn't Observability", () => {
it('should NOT match when the solutionType is NOT Observability', () => {
expect(
tracesDataSourceProfileProvider.resolve({
rootContext: {
Expand Down
Loading