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

[Unified observability] Migrate deprecated IndexPattern types #124286

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

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 @@ -7,14 +7,14 @@

import React from 'react';
import { fireEvent, screen, waitFor } from '@testing-library/react';
import { mockAppIndexPattern, mockIndexPattern, mockUxSeries, render } from '../rtl_helpers';
import { mockAppDataView, mockDataView, mockUxSeries, render } from '../rtl_helpers';
import { FilterLabel } from './filter_label';
import * as useSeriesHook from '../hooks/use_series_filters';
import { buildFilterLabel } from '../../filter_value_label/filter_value_label';

// FLAKY: https://github.com/elastic/kibana/issues/115324
describe.skip('FilterLabel', function () {
mockAppIndexPattern();
mockAppDataView();

const invertFilter = jest.fn();
jest.spyOn(useSeriesHook, 'useSeriesFilters').mockReturnValue({
Expand All @@ -30,7 +30,7 @@ describe.skip('FilterLabel', function () {
negate={false}
seriesId={0}
removeFilter={jest.fn()}
indexPattern={mockIndexPattern}
dataView={mockDataView}
series={mockUxSeries}
/>
);
Expand All @@ -55,7 +55,7 @@ describe.skip('FilterLabel', function () {
negate={false}
seriesId={0}
removeFilter={removeFilter}
indexPattern={mockIndexPattern}
dataView={mockDataView}
series={mockUxSeries}
/>
);
Expand All @@ -79,7 +79,7 @@ describe.skip('FilterLabel', function () {
negate={false}
seriesId={0}
removeFilter={removeFilter}
indexPattern={mockIndexPattern}
dataView={mockDataView}
series={mockUxSeries}
/>
);
Expand All @@ -106,7 +106,7 @@ describe.skip('FilterLabel', function () {
negate={true}
seriesId={0}
removeFilter={jest.fn()}
indexPattern={mockIndexPattern}
dataView={mockDataView}
series={mockUxSeries}
/>
);
Expand All @@ -126,7 +126,7 @@ describe.skip('FilterLabel', function () {
buildFilterLabel({
field: 'user_agent.name',
label: 'Browser family',
indexPattern: mockIndexPattern,
dataView: mockDataView,
value: 'Firefox',
negate: false,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import React from 'react';
import { IndexPattern } from '../../../../../../../../src/plugins/data/public';
import { DataView } from '../../../../../../../../src/plugins/data/common';
import { useSeriesFilters } from '../hooks/use_series_filters';
import { FilterValueLabel } from '../../filter_value_label/filter_value_label';
import { SeriesUrl } from '../types';
Expand All @@ -19,7 +19,7 @@ interface Props {
series: SeriesUrl;
negate: boolean;
definitionFilter?: boolean;
indexPattern: IndexPattern;
dataView: DataView;
removeFilter: (field: string, value: string | string[], notVal: boolean) => void;
}

Expand All @@ -30,15 +30,15 @@ export function FilterLabel({
field,
value,
negate,
indexPattern,
dataView,
removeFilter,
definitionFilter,
}: Props) {
const { invertFilter } = useSeriesFilters({ seriesId, series });

return indexPattern ? (
return dataView ? (
<FilterValueLabel
indexPattern={indexPattern}
dataView={dataView}
removeFilter={removeFilter}
invertFilter={(val) => {
if (!definitionFilter) invertFilter(val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@
*/

import { AppDataType, ReportViewType, SeriesConfig } from '../types';
import { IndexPattern } from '../../../../../../../../src/plugins/data/common';
import { DataView } from '../../../../../../../../src/plugins/data/common';
import { ReportConfigMap } from '../contexts/exploratory_view_config';

interface Props {
reportType: ReportViewType;
indexPattern: IndexPattern;
dataView: DataView;
dataType: AppDataType;
reportConfigMap: ReportConfigMap;
}

export const getDefaultConfigs = ({
reportType,
dataType,
indexPattern,
dataView,
reportConfigMap,
}: Props): SeriesConfig => {
let configResult: SeriesConfig | undefined;

reportConfigMap[dataType]?.some((fn) => {
const config = fn({ indexPattern });
const config = fn({ dataView });
if (config.reportType === reportType) {
configResult = config;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
SYSTEM_MEMORY_USAGE,
} from '../constants/labels';

export function getMetricsKPIConfig({ indexPattern }: ConfigProps): SeriesConfig {
export function getMetricsKPIConfig({ dataView }: ConfigProps): SeriesConfig {
return {
reportType: ReportTypes.KPI,
defaultSeriesType: 'area',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { LayerConfig, LensAttributes } from './lens_attributes';
import { mockAppIndexPattern, mockIndexPattern } from '../rtl_helpers';
import { mockAppDataView, mockDataView } from '../rtl_helpers';
import { getDefaultConfigs } from './default_configs';
import { sampleAttribute } from './test_data/sample_attribute';

Expand All @@ -21,24 +21,24 @@ import { RECORDS_FIELD, REPORT_METRIC_FIELD, PERCENTILE_RANKS, ReportTypes } fro
import { obsvReportConfigMap } from '../obsv_exploratory_view';

describe('Lens Attribute', () => {
mockAppIndexPattern();
mockAppDataView();

const reportViewConfig = getDefaultConfigs({
reportType: 'data-distribution',
dataType: 'ux',
indexPattern: mockIndexPattern,
dataView: mockDataView,
reportConfigMap: obsvReportConfigMap,
});

reportViewConfig.baseFilters?.push(...buildExistsFilter('transaction.type', mockIndexPattern));
reportViewConfig.baseFilters?.push(...buildExistsFilter('transaction.type', mockDataView));

let lnsAttr: LensAttributes;

const layerConfig: LayerConfig = {
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
reportDefinitions: {},
time: { from: 'now-15m', to: 'now' },
color: 'green',
Expand All @@ -58,7 +58,7 @@ describe('Lens Attribute', () => {
const seriesConfigKpi = getDefaultConfigs({
reportType: ReportTypes.KPI,
dataType: 'ux',
indexPattern: mockIndexPattern,
dataView: mockDataView,
reportConfigMap: obsvReportConfigMap,
});

Expand All @@ -67,7 +67,7 @@ describe('Lens Attribute', () => {
seriesConfig: seriesConfigKpi,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
reportDefinitions: { 'service.name': ['elastic-co'] },
time: { from: 'now-15m', to: 'now' },
color: 'green',
Expand All @@ -83,7 +83,7 @@ describe('Lens Attribute', () => {
const seriesConfigKpi = getDefaultConfigs({
reportType: ReportTypes.KPI,
dataType: 'ux',
indexPattern: mockIndexPattern,
dataView: mockDataView,
reportConfigMap: obsvReportConfigMap,
});

Expand All @@ -95,7 +95,7 @@ describe('Lens Attribute', () => {
from: 'now-1h',
to: 'now',
},
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
name: 'ux-series-1',
breakdown: 'percentile',
reportDefinitions: {},
Expand Down Expand Up @@ -200,7 +200,7 @@ describe('Lens Attribute', () => {
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
reportDefinitions: { 'performance.metric': [LCP_FIELD] },
time: { from: 'now-15m', to: 'now' },
color: 'green',
Expand Down Expand Up @@ -493,7 +493,7 @@ describe('Lens Attribute', () => {
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
reportDefinitions: { 'performance.metric': [LCP_FIELD] },
breakdown: USER_AGENT_NAME,
time: { from: 'now-15m', to: 'now' },
Expand All @@ -507,7 +507,7 @@ describe('Lens Attribute', () => {
lnsAttr.getBreakdownColumn({
sourceField: USER_AGENT_NAME,
layerId: 'layer0',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
labels: layerConfig.seriesConfig.labels,
});

Expand Down Expand Up @@ -676,14 +676,14 @@ describe('Lens Attribute', () => {
describe('Layer Filters', function () {
it('should return expected filters', function () {
reportViewConfig.baseFilters?.push(
...buildPhrasesFilter('service.name', ['elastic', 'kibana'], mockIndexPattern)
...buildPhrasesFilter('service.name', ['elastic', 'kibana'], mockDataView)
);

const layerConfig1: LayerConfig = {
seriesConfig: reportViewConfig,
seriesType: 'line',
operationType: 'count',
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
reportDefinitions: { 'performance.metric': [LCP_FIELD] },
time: { from: 'now-15m', to: 'now' },
color: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
CardinalityIndexPatternColumn,
} from '../../../../../../lens/public';
import { urlFiltersToKueryString } from '../utils/stringify_kueries';
import { IndexPattern } from '../../../../../../../../src/plugins/data/common';
import { DataView } from '../../../../../../../../src/plugins/data/common';
import {
FILTER_RECORDS,
USE_BREAK_DOWN_COLUMN,
Expand Down Expand Up @@ -91,7 +91,7 @@ export interface LayerConfig {
operationType?: OperationType;
reportDefinitions: URLReportDefinition;
time: { to: string; from: string };
indexPattern: IndexPattern;
indexPattern: DataView; // TODO: Figure out if this can be renamed or if it's a Lens requirement
selectedMetricField: string;
color: string;
name: string;
Expand Down Expand Up @@ -150,7 +150,7 @@ export class LensAttributes {
sourceField: string;
layerId: string;
labels: Record<string, string>;
indexPattern: IndexPattern;
indexPattern: DataView;
}): TermsIndexPatternColumn {
const fieldMeta = indexPattern.getFieldByName(sourceField);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { SERVICE_NAME } from '../constants/elasticsearch_fieldnames';
import { MOBILE_APP, NUMBER_OF_DEVICES } from '../constants/labels';
import { MobileFields } from './mobile_fields';

export function getMobileDeviceDistributionConfig({ indexPattern }: ConfigProps): SeriesConfig {
export function getMobileDeviceDistributionConfig({ dataView }: ConfigProps): SeriesConfig {
return {
reportType: ReportTypes.DEVICE_DISTRIBUTION,
defaultSeriesType: 'bar',
Expand All @@ -36,8 +36,8 @@ export function getMobileDeviceDistributionConfig({ indexPattern }: ConfigProps)
filterFields: [...Object.keys(MobileFields), LABEL_FIELDS_FILTER],
breakdownFields: Object.keys(MobileFields),
baseFilters: [
...buildPhraseFilter('agent.name', 'iOS/swift', indexPattern),
...buildPhraseFilter('processor.event', 'transaction', indexPattern),
...buildPhraseFilter('agent.name', 'iOS/swift', dataView),
...buildPhraseFilter('processor.event', 'transaction', dataView),
],
labels: {
...FieldLabels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { CPU_USAGE, SYSTEM_MEMORY_USAGE, MOBILE_APP, RESPONSE_LATENCY } from '../constants/labels';
import { MobileFields } from './mobile_fields';

export function getMobileKPIDistributionConfig({ indexPattern }: ConfigProps): SeriesConfig {
export function getMobileKPIDistributionConfig({ dataView }: ConfigProps): SeriesConfig {
return {
reportType: ReportTypes.DISTRIBUTION,
defaultSeriesType: 'bar',
Expand All @@ -42,7 +42,7 @@ export function getMobileKPIDistributionConfig({ indexPattern }: ConfigProps): S
filterFields: [...Object.keys(MobileFields), LABEL_FIELDS_FILTER],
breakdownFields: Object.keys(MobileFields),
baseFilters: [
...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], indexPattern),
...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], dataView),
],
labels: {
...FieldLabels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../constants/labels';
import { MobileFields } from './mobile_fields';

export function getMobileKPIConfig({ indexPattern }: ConfigProps): SeriesConfig {
export function getMobileKPIConfig({ dataView }: ConfigProps): SeriesConfig {
return {
reportType: ReportTypes.KPI,
defaultSeriesType: 'line',
Expand All @@ -49,7 +49,7 @@ export function getMobileKPIConfig({ indexPattern }: ConfigProps): SeriesConfig
filterFields: [...Object.keys(MobileFields), LABEL_FIELDS_FILTER],
breakdownFields: Object.keys(MobileFields),
baseFilters: [
...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], indexPattern),
...buildPhrasesFilter('agent.name', ['iOS/swift', 'open-telemetry/swift'], dataView),
],
labels: {
...FieldLabels,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
* 2.0.
*/

import { mockAppIndexPattern, mockIndexPattern } from '../../rtl_helpers';
import { mockAppDataView, mockDataView } from '../../rtl_helpers';
import { getDefaultConfigs } from '../default_configs';
import { LayerConfig, LensAttributes } from '../lens_attributes';
import { sampleAttributeCoreWebVital } from '../test_data/sample_attribute_cwv';
import { LCP_FIELD, SERVICE_NAME, USER_AGENT_OS } from '../constants/elasticsearch_fieldnames';
import { obsvReportConfigMap } from '../../obsv_exploratory_view';

describe('Core web vital config test', function () {
mockAppIndexPattern();
mockAppDataView();

const seriesConfig = getDefaultConfigs({
reportType: 'core-web-vitals',
dataType: 'ux',
indexPattern: mockIndexPattern,
dataView: mockDataView,
reportConfigMap: obsvReportConfigMap,
});

Expand All @@ -29,7 +29,7 @@ describe('Core web vital config test', function () {
color: 'green',
name: 'test-series',
breakdown: USER_AGENT_OS,
indexPattern: mockIndexPattern,
indexPattern: mockDataView,
time: { from: 'now-15m', to: 'now' },
reportDefinitions: { [SERVICE_NAME]: ['elastic-co'] },
selectedMetricField: LCP_FIELD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
} from '../constants/elasticsearch_fieldnames';
import { CLS_LABEL, FID_LABEL, LCP_LABEL } from '../constants/labels';

export function getCoreWebVitalsConfig({ indexPattern }: ConfigProps): SeriesConfig {
export function getCoreWebVitalsConfig({ dataView }: ConfigProps): SeriesConfig {
const statusPallete = euiPaletteForStatus(3);

return {
Expand Down Expand Up @@ -87,8 +87,8 @@ export function getCoreWebVitalsConfig({ indexPattern }: ConfigProps): SeriesCon
URL_FULL,
],
baseFilters: [
...buildPhraseFilter(TRANSACTION_TYPE, 'page-load', indexPattern),
...buildPhraseFilter(PROCESSOR_EVENT, 'transaction', indexPattern),
...buildPhraseFilter(TRANSACTION_TYPE, 'page-load', dataView),
...buildPhraseFilter(PROCESSOR_EVENT, 'transaction', dataView),
],
labels: { ...FieldLabels, [SERVICE_NAME]: 'Web Application' },
definitionFields: [SERVICE_NAME, SERVICE_ENVIRONMENT],
Expand Down
Loading