Skip to content

Commit

Permalink
Merge branch 'main' into issue_163381
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 2, 2023
2 parents 3b3ab03 + d2dbd93 commit 425c6ad
Show file tree
Hide file tree
Showing 127 changed files with 94,837 additions and 1,352 deletions.
104 changes: 76 additions & 28 deletions .buildkite/scripts/steps/check_types_commits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,92 @@

set -euo pipefail

# This script will collect typescript projects and run typecheck on projects between the given 2 parameters
# Could be used for selective typechecking on projects that might be affected for a given PR.
# This script detects the files changed in a given set of commits, finds the related tsconfig.json files, and scope the TypeScript type check to those.
# In CI, this script can be used for selective type-checking on projects that might be affected for a given PR.
# (The accuracy for finding related projects is not a 100%)

if [[ "${CI-}" == "true" ]]; then
.buildkite/scripts/bootstrap.sh
argv=( "$@" )
diffArgs=("--name-only")
uniq_dirs=()
uniq_tsconfigs=()

sha1=$(git merge-base $GITHUB_PR_TARGET_BRANCH $GITHUB_PR_TRIGGERED_SHA)
sha2="${GITHUB_PR_TRIGGERED_SHA-}"
else
if [[ "${1-}" == "--cached" ]]; then
# Only check staged files
sha1=$1
sha2=""
is_flag_set () {
flag=$1
if [ ${#argv[@]} -gt 0 ] && [[ ${argv[@]} =~ $flag ]]; then
true
else
# Script take between 0 and 2 arguments representing two commit SHA's:
# If 0, it will diff HEAD and HEAD^
# If 1 (SHA1), it will diff SHA1 and SHA1^
# If 2 (SHA1, SHA2), it will diff SHA1 and SHA2
sha1="${1-HEAD}"
sha2="${2-$sha1^}"
false
fi
}

get_args_for_flag_result=()
get_args_for_flag () {
flag=$1
found=false
get_args_for_flag_result=()
if [ ${#argv[@]} -gt 0 ]; then
for i in "${!argv[@]}"; do
arg="${argv[$i]}"
if [ "$found" == false ] && [[ "$arg" == "$flag" ]]; then
found=true
elif [ "$found" == true ]; then
if [[ "$arg" == -* ]]; then
return
else
get_args_for_flag_result+=("$arg")
fi
fi
done
fi
}

if is_flag_set "--help" || is_flag_set "-h"; then
echo "Detects the files changed in a given set of commits, finds the related"
echo "tsconfig.json files, and scope the TypeScript type check to those."
echo
echo "Usage:"
echo " $0 [options]"
echo " $0 [<ref1> [<ref2>]]"
echo
echo "Options:"
echo " --help, -h Show this help"
echo " --cached Check staged changes"
echo " --merge-base [<ref1> [<ref2>]]"
echo " Check changes between nearest common ansestor (merge-base) of"
echo " ref1 and ref2. Defaults: 'main' and 'HEAD'"
echo
echo "If no options are provided, the script takes between 0 and 2 arguments"
echo "representing two git refs:"
echo " If 0, it will diff HEAD and HEAD^"
echo " If 1 (REF1), it will diff REF1 and REF1^"
echo " If 2 (REF1, REF2), it will diff REF1 and REF2"
exit
fi

uniq_dirs=()
uniq_tsconfigs=()
if [[ "${CI-}" == "true" ]]; then
# Buildkite only
.buildkite/scripts/bootstrap.sh

if [[ "$sha1" == "--cached" ]]; then
echo "Detecting files changed in staging area..."
targetBranch="${GITHUB_PR_TARGET_BRANCH-}"
git fetch origin $targetBranch
sha=$(git merge-base "origin/$targetBranch" "${GITHUB_PR_TRIGGERED_SHA-}")
diffArgs+=("$sha" "${GITHUB_PR_TRIGGERED_SHA-}")
elif is_flag_set "--merge-base"; then
# Similar to when CI=true, but locally
get_args_for_flag "--merge-base"
diffArgs+=("--merge-base" "${get_args_for_flag_result[0]-main}" "${get_args_for_flag_result[1]-HEAD}")
elif is_flag_set "--cached"; then
# Only check staged files
diffArgs+=("--cached")
else
echo "Detecting files changed between $sha1 and $sha2..."
# Full manual mode!
ref1="${1-HEAD}"
diffArgs+=("$ref1" "${2-$ref1^}")
fi

files=($(git diff --name-only $sha1 $sha2))
echo "Detecting files changed..."
echo "DEBUG: git diff args: ${diffArgs[@]}"
files=($(git diff "${diffArgs[@]}"))

add_dir () {
new_dir=$1
Expand Down Expand Up @@ -117,11 +169,7 @@ if [ ${#uniq_dirs[@]} -gt 0 ]; then
fi

if [ ${#uniq_tsconfigs[@]} -eq 0 ]; then
if [[ "$sha1" == "--cached" ]]; then
echo "No tsconfig.json files found for staged changes"
else
echo "No tsconfig.json files found for changes between $sha1 and $sha2"
fi
echo "No tsconfig.json files found"
exit
fi

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@dnd-kit/utilities": "^2.0.0",
"@elastic/apm-rum": "^5.14.0",
"@elastic/apm-rum-react": "^2.0.0",
"@elastic/charts": "59.1.0",
"@elastic/charts": "60.0.0",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.4.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-management/cards_navigation/src/consts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const appDefinitions: Record<AppId, AppDefinition> = {
category: appCategories.DATA,
description: i18n.translate('management.landing.withCardNavigation.mlDescription', {
defaultMessage:
'View, export, and import machine learning analytics and anomaly detection items.',
'Identify, analyze, and process your data using advanced analysis techniques.',
}),
icon: <EuiIcon size="l" type="indexMapping" />,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ export const GaugeComponent: FC<GaugeRenderProps> = memo(
const onRenderChange = useCallback(
(isRendered: boolean = true) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
renderComplete();
});
renderComplete();
}
},
[renderComplete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,7 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = memo(
const onRenderChange = useCallback(
(isRendered: boolean = true) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
renderComplete();
});
renderComplete();
}
},
[renderComplete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -971,11 +971,6 @@ describe('MetricVisComponent', function () {
});

it('should report render complete', () => {
jest.spyOn(window, 'requestAnimationFrame').mockImplementation((cb) => {
cb(0);
return 0;
});

const renderCompleteSpy = jest.fn();
const component = shallow(
<MetricVis
Expand All @@ -1000,8 +995,6 @@ describe('MetricVisComponent', function () {
component.find(Settings).props().onRenderChange!(true);

expect(renderCompleteSpy).toHaveBeenCalledTimes(1);

(window.requestAnimationFrame as jest.Mock).mockRestore();
});

it('should convert null values to NaN', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,7 @@ export const MetricVis = ({
const onRenderChange = useCallback<RenderChangeListener>(
(isRendered) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
renderComplete();
});
renderComplete();
}
},
[renderComplete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,8 @@ const PartitionVisComponent = (props: PartitionVisComponentProps) => {
const onRenderChange = useCallback(
(isRendered: boolean = true) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
props.renderComplete();
setChartIsLoaded(true);
});
props.renderComplete();
setChartIsLoaded(true);
}
},
[props]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ export const TagCloudChart = ({
const onRenderChange = useCallback<RenderChangeListener>(
(isRendered) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
renderComplete();
});
renderComplete();
}
},
[renderComplete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@ export function XYChart({
const onRenderChange = useCallback(
(isRendered: boolean = true) => {
if (isRendered) {
// this requestAnimationFrame call is a temporary fix for https://github.com/elastic/elastic-charts/issues/2124
window.requestAnimationFrame(() => {
renderComplete();
});
renderComplete();
}
},
[renderComplete]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,4 +593,8 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:profilingUseLegacyFlamegraphAPI': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export interface UsageStats {
'securitySolution:enableGroupedNav': boolean;
'securitySolution:showRelatedIntegrations': boolean;
'visualization:visualize:legacyGaugeChartsLibrary': boolean;
'observability:profilingUseLegacyFlamegraphAPI': boolean;
'observability:profilingPerCoreWatt': number;
'observability:profilingCo2PerKWH': number;
'observability:profilingDatacenterPUE': number;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10078,6 +10078,12 @@
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:profilingUseLegacyFlamegraphAPI": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
}
}
},
Expand Down
Binary file modified test/functional/screenshots/baseline/area_chart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion x-pack/plugins/apm/ftr_e2e/cypress_test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export async function cypressTestRunner({ getService }: FtrProviderContext) {
ES_NODE: esNode,
ES_REQUEST_TIMEOUT: esRequestTimeout,
TEST_CLOUD: process.env.TEST_CLOUD,
NO_COMMAND_LOG: 1, // Temp fix, With Cypress 13, this might not be required https://github.com/elastic/kibana/pull/162383
},
});

Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/apm/server/routes/profiling/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { toNumberRt } from '@kbn/io-ts-utils';
import type { BaseFlameGraph, TopNFunctions } from '@kbn/profiling-utils';
import * as t from 'io-ts';
import { profilingUseLegacyFlamegraphAPI } from '@kbn/observability-plugin/common';
import { HOST_NAME } from '../../../common/es_fields/apm';
import { toKueryFilterFormat } from '../../../common/utils/to_kuery_filter_format';
import { getApmEventClient } from '../../lib/helpers/get_apm_event_client';
Expand Down Expand Up @@ -36,6 +37,10 @@ const profilingFlamegraphRoute = createApmServerRoute({
{ flamegraph: BaseFlameGraph; hostNames: string[] } | undefined
> => {
const { context, plugins, params } = resources;
const useLegacyFlamegraphAPI = await (
await context.core
).uiSettings.client.get<boolean>(profilingUseLegacyFlamegraphAPI);

const [esClient, apmEventClient, profilingDataAccessStart] =
await Promise.all([
(await context.core).elasticsearch.client,
Expand Down Expand Up @@ -67,6 +72,7 @@ const profilingFlamegraphRoute = createApmServerRoute({
rangeFromMs: start,
rangeToMs: end,
kuery: toKueryFilterFormat(HOST_NAME, serviceHostNames),
useLegacyFlamegraphAPI,
});

return { flamegraph, hostNames: serviceHostNames };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,24 @@ describe('ConnectorConfigurationLogic', () => {
validation_errors: [],
value: 'fourthBar',
},
{
default_value: '',
depends_on: [],
display: DisplayType.TEXTBOX,
is_valid: true,
key: 'restricted',
label: 'Restricted',
options: [],
order: 3,
required: false,
sensitive: true,
tooltip: '',
type: FieldType.STRING,
ui_restrictions: ['advanced'],
validations: [],
validation_errors: [],
value: 'I am restricted',
},
{
default_value: '',
depends_on: [{ field: 'bar', value: 'foofoo' }],
Expand Down Expand Up @@ -811,6 +829,25 @@ describe('ConnectorConfigurationLogic', () => {
validation_errors: [],
value: 'fourthBar',
},
{
default_value: '',
depends_on: [],
display: DisplayType.TEXTBOX,
is_valid: true,
key: 'restricted',
label: 'Restricted',
options: [],
order: 3,
required: false,
sensitive: true,
tooltip: '',
type: FieldType.STRING,
ui_restrictions: ['advanced'],
validations: [],
validation_errors: [],
value: 'I am restricted',
},

{
default_value: '',
depends_on: [{ field: 'bar', value: 'fafa' }],
Expand Down
Loading

0 comments on commit 425c6ad

Please sign in to comment.