Skip to content

Commit

Permalink
Merge branch 'main' into profiling/fix-package-policy
Browse files Browse the repository at this point in the history
  • Loading branch information
inge4pres authored May 2, 2023
2 parents 9d8c60f + 3cd3549 commit b1b36dc
Show file tree
Hide file tree
Showing 58 changed files with 3,038 additions and 822 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,32 @@ describe('useDataGridColumnsCellActions', () => {
expect(mockCloseCellPopover).toHaveBeenCalled();
});
});

it('should return empty array of actions when list of fields is empty', async () => {
const { result, waitForNextUpdate } = renderHook(useDataGridColumnsCellActions, {
initialProps: {
...useDataGridColumnsCellActionsProps,
fields: [],
},
});

await waitForNextUpdate();

expect(result.current).toBeInstanceOf(Array);
expect(result.current.length).toBe(0);
});

it('should return empty array of actions when list of fields is undefined', async () => {
const { result, waitForNextUpdate } = renderHook(useDataGridColumnsCellActions, {
initialProps: {
...useDataGridColumnsCellActionsProps,
fields: undefined,
},
});

await waitForNextUpdate();

expect(result.current).toBeInstanceOf(Array);
expect(result.current.length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface BulkField extends Pick<CellActionField, 'name' | 'type'> {

export interface UseDataGridColumnsCellActionsProps
extends Pick<CellActionsProps, 'triggerId' | 'metadata' | 'disabledActionTypes'> {
fields: BulkField[];
fields?: BulkField[];
dataGridRef: MutableRefObject<EuiDataGridRefProps | null>;
}
export type UseDataGridColumnsCellActions<
Expand All @@ -46,11 +46,11 @@ export const useDataGridColumnsCellActions: UseDataGridColumnsCellActions = ({
}) => {
const bulkContexts: CellActionCompatibilityContext[] = useMemo(
() =>
fields.map(({ values, ...field }) => ({
fields?.map(({ values, ...field }) => ({
field, // we are getting the actions for the whole column field, so the compatibility check will be done without the value
trigger: { id: triggerId },
metadata,
})),
})) ?? [],
[fields, triggerId, metadata]
);

Expand All @@ -60,11 +60,13 @@ export const useDataGridColumnsCellActions: UseDataGridColumnsCellActions = ({

const columnsCellActions = useMemo<EuiDataGridColumnCellAction[][]>(() => {
if (loading) {
return fields.map(() => [
() => <EuiLoadingSpinner size="s" data-test-subj="dataGridColumnCellAction-loading" />,
]);
return (
fields?.map(() => [
() => <EuiLoadingSpinner size="s" data-test-subj="dataGridColumnCellAction-loading" />,
]) ?? []
);
}
if (!columnsActions) {
if (!columnsActions || !fields || fields.length === 0) {
return [];
}
return columnsActions.map((actions, columnIndex) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ kibana_vars=(
xpack.task_manager.version_conflict_threshold
xpack.task_manager.event_loop_delay.monitor
xpack.task_manager.event_loop_delay.warn_threshold
xpack.task_manager.worker_utilization_running_average_window
xpack.uptime.index
serverless
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ export const BUILT_IN_MODEL_TAG = 'prepackaged';
export const CURATED_MODEL_TAG = 'curated';

export const CURATED_MODEL_DEFINITIONS = {
'.elser_model_1_SNAPSHOT': {
'.elser_model_1': {
config: {
input: {
field_names: ['text_field'],
},
},
description: i18n.translate('xpack.ml.trainedModels.modelsList.elserDescription', {
defaultMessage: 'Elastic Learned Sparse EncodeR',
defaultMessage: 'Elastic Learned Sparse EncodeR v1 (Tech Preview)',
}),
},
} as const;
Expand Down
103 changes: 103 additions & 0 deletions x-pack/plugins/apm/dev_docs/overflow_bucket_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
## Summary

8.7 introduced Overflow Buckets for Metrics. The below setup would enable generating the overflow buckets for the metrics indices.

### Pre-requisites

- Install golang and set go path properly

- Run Elasticsearch locally
```
yarn es snapshot
```
- Run Kibana locally
```
yarn start
```
- Git Clone APM Server locally
```
git clone [email protected]:[USER]/apm-server.git
```
- Modify `apm-server.yml` accordingly
```
## Add this to the bottom of the file
apm-server.aggregation:
service_transactions:
max_groups: 2
transactions:
max_groups: 2
## Uncomment the following lines under `output.elasticsearch:`
username: "elastic"
password: "changeme"
protocol: "http" // This is by default set to HTTPS, change it to http
```
- Run APM Server locally
```
./apm-server -c apm-server.yml -e -d "*"
```

### Steps to generate data

- Copy paste the below script in a file called `tx_max_group.go`
This file is responsible for generating 3 transactions per service.
```
package main
import (
"fmt"
"time"
"go.elastic.co/apm/v2"
)
func main() {
tracer := apm.DefaultTracer()
once(tracer, "test1")
once(tracer, "test2")
once(tracer, "test3")
tracer.Flush(nil)
}
func once(tracer *apm.Tracer, name string) {
tx := tracer.StartTransaction(name, "type")
defer tx.End()
span := tx.StartSpanOptions(name, "type", apm.SpanOptions{})
time.Sleep(time.Millisecond * 1)
span.Outcome = "success"
span.Context.SetDestinationService(apm.DestinationServiceSpanContext{
Resource: fmt.Sprintf("dest_resource"),
})
span.End()
}
```

- Now create a Bash Script file, name it anything - e.g., `service_max_group.sh`
This file will generate services and then transactions for each service using the go script above.
```
#!/usr/bin/env bash
echo "Starting script"
go build -o tx_max_group tx_max_group.go || exit 1
for i in {1..10100}
do
export ELASTIC_APM_SERVICE_NAME="service-$i"
./tx_max_group
done
echo "Ending script"
```

- Run `sh service_max_group` to generate the data

This would start generating events to APM Server. Now open Service Inventory Page on Kibana to observe the `_other` bucket.

## Known Issues

- APM Server is unable to use Fleet API to generate APM Indices. Due to this, when starting the APM Server, you will see errors like unable to find Metrics Indices. To fix this, run one of the Synthtrace Scenario files which would create the required indices.
```
node scripts/synthtrace mobile.ts --clean
```
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,10 @@ export const ConnectorConfiguration: React.FC = () => {
{
children: (
<>
<EuiText size="s">
{i18n.translate(
'xpack.enterpriseSearch.content.indices.configurationConnector.connectorPackage.description.firstParagraph',
{
defaultMessage:
'The connectors repository contains several connector client examples to help you utilize our framework for accelerated development against custom data sources.',
}
)}
</EuiText>
<EuiLink href="https://github.com/elastic/connectors" target="_blank">
{i18n.translate(
'xpack.enterpriseSearch.content.indices.configurationConnector.connectorPackage.button.label',
{
defaultMessage: 'Explore the connectors repository',
}
)}
</EuiLink>
<EuiSpacer />
<EuiText size="s">
<FormattedMessage
id="xpack.enterpriseSearch.content.indices.configurationConnector.connectorPackage.description.secondParagraph"
defaultMessage="The connectors repository contains several {link} to help you utilize our framework for accelerated development against custom data sources."
defaultMessage="The connectors repository contains several {link}. Use our framework for accelerated development against custom data sources."
values={{
link: (
<EuiLink
Expand Down Expand Up @@ -266,7 +248,7 @@ export const ConnectorConfiguration: React.FC = () => {
'xpack.enterpriseSearch.content.indices.configurationConnector.scheduleSync.description',
{
defaultMessage:
'Once your connectors are configured to your liking, don’t forget to set a recurring sync schedule to make sure your documents are indexed and relevant. You can also trigger a one-time sync without enabling a sync schedule.',
'Once configured, set a recurring sync schedule to keep your documents in sync over time. You can also simply trigger a one-time sync.',
}
)}
</EuiText>
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import type { FleetConfigType, FleetStartServices } from '../../plugin';

import { PackageInstallProvider } from '../integrations/hooks';

import { useAuthz, useFleetStatus, useFlyoutContext } from './hooks';
import { type FleetStatusProviderProps, useAuthz, useFleetStatus, useFlyoutContext } from './hooks';

import {
ConfigContext,
Expand Down Expand Up @@ -240,6 +240,7 @@ export const FleetAppContext: React.FC<{
theme$: AppMountParameters['theme$'];
/** For testing purposes only */
routerHistory?: History<any>;
fleetStatus?: FleetStatusProviderProps;
}> = memo(
({
children,
Expand All @@ -250,6 +251,7 @@ export const FleetAppContext: React.FC<{
extensions,
routerHistory,
theme$,
fleetStatus,
}) => {
const isDarkMode = useObservable<boolean>(startServices.uiSettings.get$('theme:darkMode'));

Expand All @@ -265,7 +267,7 @@ export const FleetAppContext: React.FC<{
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
<UIExtensionsContext.Provider value={extensions}>
<FleetStatusProvider>
<FleetStatusProvider defaultFleetStatus={fleetStatus}>
<Router history={history}>
<PackageInstallProvider
notifications={startServices.notifications}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ const mockedUseGetPipeline = useGetPipeline as jest.MockedFunction<typeof useGet
jest.mock('../../../../hooks', () => {
return {
...jest.requireActual('../../../../hooks'),
FleetStatusProvider: (props: any) => {
return props.children;
},
useFleetStatus: jest.fn().mockReturnValue({ isReady: true } as any),
useGetPipeline: jest.fn(),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,6 @@ import type { RegistryDataStream } from '../../../../../../../../../common/types

import { ExperimentDatastreamSettings } from './experimental_datastream_settings';

jest.mock('../../../../../../../../hooks', () => {
return {
...jest.requireActual('../../../../../../../../hooks'),
FleetStatusProvider: (props: any) => {
return props.children;
},
useFleetStatus: jest.fn().mockReturnValue({ isReady: true } as any),
sendGetStatus: jest
.fn()
.mockResolvedValue({ data: { isReady: true, missing_requirements: [] } }),
};
});

describe('ExperimentDatastreamSettings', () => {
describe('Synthetic source', () => {
it('should be enabled an not checked by default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import { useAuthz } from '../../../../../../hooks/use_authz';

import { AgentDetailsActionMenu } from './actions_menu';

jest.mock('../../../../../../hooks/use_fleet_status', () => ({
FleetStatusProvider: (props: any) => {
return props.children;
},
}));

jest.mock('../../../../../../services/experimental_features');
jest.mock('../../../../../../hooks/use_authz');

Expand Down
Loading

0 comments on commit b1b36dc

Please sign in to comment.