Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/138725
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Oct 10, 2022
2 parents 522f481 + 7e6df96 commit 9dbe7b0
Show file tree
Hide file tree
Showing 140 changed files with 2,377 additions and 1,379 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ export type ServiceFields = Fields &
| 'service.name'
| 'service.version'
| 'service.environment'
| 'transaction.type'
> &
Partial<{
_doc_count: number;
transaction: {
duration: {
summary: {
min: number;
max: number;
sum: number;
value_count: number;
};
};
failure_count: number;
success_count: number;
type: string;
'duration.summary': {
min: number;
max: number;
sum: number;
value_count: number;
};
};
}>;

Expand Down Expand Up @@ -86,10 +84,10 @@ export class ServicMetricsAggregator implements StreamAggregator<ApmFields> {
},
},
failure_count: {
type: { type: 'long' },
type: 'long',
},
success_count: {
type: { type: 'long' },
type: 'long',
},
},
},
Expand Down Expand Up @@ -141,22 +139,24 @@ export class ServicMetricsAggregator implements StreamAggregator<ApmFields> {
}

const state = this.state[key];
state.count++;

switch (event['event.outcome']) {
case 'failure':
state.failure_count++;
break;
case 'success':
state.success_count++;
break;
}

const duration = Number(event['transaction.duration.us']);

if (duration >= 0) {
state.count++;

state.sum += duration;
if (duration > state.max) state.max = duration;
if (duration < state.min) state.min = Math.min(0, duration);

switch (event['event.outcome']) {
case 'failure':
state.failure_count++;
break;
case 'success':
state.success_count++;
break;
}
}
};

Expand Down Expand Up @@ -197,18 +197,16 @@ export class ServicMetricsAggregator implements StreamAggregator<ApmFields> {
'processor.event': 'metric',
'service.name': state['service.name'],
'service.environment': state['service.environment'],
'transaction.type': state['transaction.type'],
transaction: {
duration: {
summary: {
min: state.min,
max: state.max,
sum: state.sum,
value_count: state.count,
},
'duration.summary': {
min: state.min,
max: state.max,
sum: state.sum,
value_count: state.count,
},
failure_count: state.failure_count,
success_count: state.success_count,
failure_count: state.failure_count,
type: state['transaction.type'] ?? 'request',
},
};
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';
import { Datatable } from '@kbn/expressions-plugin/common';
import MetricVisComponent, { MetricVisComponentProps } from './metric_component';
import { LabelPosition } from '../../common/constants';
Expand Down Expand Up @@ -76,15 +76,15 @@ describe('MetricVisComponent', function () {
...propOverrides,
};

return shallow(<MetricVisComponent {...props} />);
return <MetricVisComponent {...props} />;
};

it('should render component', () => {
expect(getComponent().exists()).toBe(true);
expect(shallow(getComponent()).exists()).toBe(true);
});

it('should render correct structure for single metric', function () {
expect(getComponent()).toMatchSnapshot();
expect(shallow(getComponent())).toMatchSnapshot();
});

it('should render correct structure for multi-value metrics', function () {
Expand All @@ -110,6 +110,36 @@ describe('MetricVisComponent', function () {
},
});

expect(component).toMatchSnapshot();
expect(shallow(component)).toMatchSnapshot();
});

it('should call renderComplete once for multi-value metrics', function () {
const renderComplete = jest.fn();
const component = getComponent({
renderComplete,
filterable: [true, false],
visData: {
type: 'datatable',
columns: [
{ id: 'col-0', name: '1st percentile of bytes', meta: { type: 'number' } },
{ id: 'col-1', name: '99th percentile of bytes', meta: { type: 'number' } },
],
rows: [{ 'col-0': 182, 'col-1': 445842.4634666484 }],
},
visParams: {
...visParams,
dimensions: {
...visParams.dimensions,
metrics: [
{ accessor: 0, type: 'vis_dimension', format: { id: 'number', params: {} } },
{ accessor: 1, type: 'vis_dimension', format: { id: 'number', params: {} } },
],
},
},
});

mount(component);

expect(renderComplete).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class MetricVisComponent extends Component<MetricVisComponentProps> {
return this.props.visParams.metric.autoScale && this.props.visParams.metric.colorFullBackground;
};

private renderMetric = (metric: MetricOptions, index: number) => {
private renderMetric = (metric: MetricOptions, index: number, arrayRef: MetricOptions[]) => {
const hasBuckets = this.props.visParams.dimensions.bucket !== undefined;
const MetricComponent = this.props.visParams.metric.autoScale
? AutoScaleMetricVisValue
Expand Down Expand Up @@ -157,7 +157,7 @@ class MetricVisComponent extends Component<MetricVisComponentProps> {
autoScale={this.props.visParams.metric.autoScale}
colorFullBackground={this.props.visParams.metric.colorFullBackground}
labelConfig={this.props.visParams.metric.labels}
renderComplete={this.props.renderComplete}
renderComplete={arrayRef.length - 1 === index ? this.props.renderComplete : undefined}
/>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/chart_expressions/expression_xy/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
export const PLUGIN_ID = 'expressionXy';
export const PLUGIN_NAME = 'expressionXy';

export { LayerTypes } from './constants';

export type {
XYArgs,
EndValue,
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/chart_expressions/expression_xy/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export function plugin() {
return new ExpressionXyPlugin();
}

export { LayerTypes } from '../common';

export type { ExpressionXyPluginSetup, ExpressionXyPluginStart } from './types';
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ import {
import { i18n } from '@kbn/i18n';
import type { DataView } from '@kbn/data-views-plugin/public';
import { SavedSearch } from '@kbn/saved-search-plugin/public';
import {
getVisualizeInformation,
triggerVisualizeActions,
} from '@kbn/unified-field-list-plugin/public';
import { HitsCounter } from '../hits_counter';
import { GetStateReturn } from '../../services/discover_state';
import { DiscoverHistogram } from './histogram';
import { DataCharts$, DataTotalHits$ } from '../../hooks/use_saved_search';
import { useChartPanels } from './use_chart_panels';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import {
getVisualizeInformation,
triggerVisualizeActions,
} from '../sidebar/lib/visualize_trigger_utils';
import { getUiActions } from '../../../../kibana_services';
import { PLUGIN_ID } from '../../../../../common';

const DiscoverHistogramMemoized = memo(DiscoverHistogram);
export const CHART_HIDDEN_KEY = 'discover:chartHidden';
Expand Down Expand Up @@ -72,7 +74,13 @@ export function DiscoverChart({

useEffect(() => {
if (!timeField) return;
getVisualizeInformation(timeField, dataView, savedSearch.columns || []).then((info) => {
getVisualizeInformation(
getUiActions(),
timeField,
dataView,
savedSearch.columns || [],
[]
).then((info) => {
setCanVisualize(Boolean(info));
});
}, [dataView, savedSearch.columns, timeField]);
Expand All @@ -81,7 +89,13 @@ export function DiscoverChart({
if (!timeField) {
return;
}
triggerVisualizeActions(timeField, savedSearch.columns || [], dataView);
triggerVisualizeActions(
getUiActions(),
timeField,
savedSearch.columns || [],
PLUGIN_ID,
dataView
);
}, [dataView, savedSearch.columns, timeField]);

const onShowChartOptions = useCallback(() => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.dscSidebarItem__fieldPopoverPanel {
min-width: $euiSizeXXL * 6.5;
max-width: $euiSizeXXL * 7.5;
}

.dscSidebarItem--multi {
.kbnFieldButton__button {
padding-left: 0;
Expand Down
Loading

0 comments on commit 9dbe7b0

Please sign in to comment.