Skip to content

Commit

Permalink
Fix sampler shard size
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Dec 6, 2021
1 parent e5e0650 commit 0da5cf6
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 27 deletions.
1 change: 0 additions & 1 deletion x-pack/plugins/apm/common/correlations/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,3 @@ export const ERROR_CORRELATION_THRESHOLD = 0.02;

export const DEFAULT_PERCENTILE_THRESHOLD = 95;
export const DEBOUNCE_INTERVAL = 100;
export const SAMPLER_SHARD_SIZE = 10000;
4 changes: 1 addition & 3 deletions x-pack/plugins/apm/common/correlations/field_stats_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { CorrelationsParams } from './types';

export interface FieldStatsCommonRequestParams extends CorrelationsParams {
samplerShardSize: number;
}
export type FieldStatsCommonRequestParams = CorrelationsParams;

export interface Field {
fieldName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { asPercent } from '../../../../../common/utils/formatters';
import { useTheme } from '../../../../hooks/use_theme';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
import { useFetchParams } from '../use_fetch_params';
import { SAMPLER_SHARD_SIZE } from '../../../../../common/correlations/constants';

export type OnAddFilter = ({
fieldName,
Expand Down Expand Up @@ -193,7 +192,6 @@ export function TopValues({
...params,
fieldName,
fieldValue,
samplerShardSize: SAMPLER_SHARD_SIZE,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { EventOutcome } from '../../../../common/event_outcome';
import {
DEBOUNCE_INTERVAL,
DEFAULT_PERCENTILE_THRESHOLD,
SAMPLER_SHARD_SIZE,
} from '../../../../common/correlations/constants';
import type {
FailedTransactionsCorrelation,
Expand Down Expand Up @@ -201,7 +200,6 @@ export function useFailedTransactionsCorrelations() {
body: {
...fetchParams,
fieldsToSample: [...fieldsToSample],
samplerShardSize: SAMPLER_SHARD_SIZE,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { IHttpFetchError, ResponseErrorBody } from 'src/core/public';
import {
DEBOUNCE_INTERVAL,
DEFAULT_PERCENTILE_THRESHOLD,
SAMPLER_SHARD_SIZE,
} from '../../../../common/correlations/constants';
import type { FieldValuePair } from '../../../../common/correlations/types';
import { getPrioritizedFieldValuePairs } from '../../../../common/correlations/utils';
Expand Down Expand Up @@ -215,7 +214,6 @@ export function useLatencyCorrelations() {
body: {
...fetchParams,
fieldsToSample: [...fieldsToSample],
samplerShardSize: SAMPLER_SHARD_SIZE,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { getBooleanFieldStatsRequest } from './get_boolean_field_stats';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ElasticsearchClient } from 'kibana/server';
import { fetchFieldsStats } from './get_fields_stats';
import { SAMPLER_SHARD_SIZE } from '../../../../../common/correlations/constants';

const params = {
index: 'apm-*',
Expand All @@ -21,7 +20,6 @@ const params = {
includeFrozen: false,
environment: ENVIRONMENT_ALL.value,
kuery: '',
samplerShardSize: SAMPLER_SHARD_SIZE,
};

export const getExpectedQuery = (aggs: any) => {
Expand Down
15 changes: 4 additions & 11 deletions x-pack/plugins/apm/server/routes/correlations/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ const fieldStatsRoute = createApmServerRoute({
transactionName: t.string,
transactionType: t.string,
}),
environmentRt,
kueryRt,
rangeRt,
t.type({
fieldsToSample: t.array(t.string),
samplerShardSize: t.number,
}),
environmentRt,
kueryRt,
rangeRt,
]),
}),
options: { tags: ['access:apm'] },
Expand Down Expand Up @@ -129,7 +128,6 @@ const fieldValueStatsRoute = createApmServerRoute({
t.type({
fieldName: t.string,
fieldValue: t.union([t.string, t.number]),
samplerShardSize: t.union([t.string, t.number]),
}),
]),
}),
Expand All @@ -143,8 +141,7 @@ const fieldValueStatsRoute = createApmServerRoute({
const { indices } = await setupRequest(resources);
const esClient = resources.context.core.elasticsearch.client.asCurrentUser;

const { fieldName, fieldValue, samplerShardSize, ...params } =
resources.params.query;
const { fieldName, fieldValue, ...params } = resources.params.query;

return withApmSpan(
'get_correlations_field_value_stats',
Expand All @@ -153,10 +150,6 @@ const fieldValueStatsRoute = createApmServerRoute({
esClient,
{
...params,
samplerShardSize:
typeof samplerShardSize === 'string'
? parseInt(samplerShardSize, 10)
: samplerShardSize,
index: indices.transaction,
},
{ fieldName, fieldValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { FailedTransactionsCorrelationsResponse } from '../../../../plugins/apm/common/correlations/failed_transactions_correlations/types';
import { EVENT_OUTCOME } from '../../../../plugins/apm/common/elasticsearch_fieldnames';
import { EventOutcome } from '../../../../plugins/apm/common/event_outcome';
import { SAMPLER_SHARD_SIZE } from '../../../../plugins/apm/common/correlations/constants';

// These tests go through the full sequence of queries required
// to get the final results for a failed transactions correlation analysis.
Expand Down Expand Up @@ -185,7 +184,6 @@ export default function ApiTest({ getService }: FtrProviderContext) {
body: {
...getOptions(),
fieldsToSample: [...fieldsToSample],
samplerShardSize: SAMPLER_SHARD_SIZE,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import expect from '@kbn/expect';

import { FtrProviderContext } from '../../common/ftr_provider_context';
import type { LatencyCorrelationsResponse } from '../../../../plugins/apm/common/correlations/latency_correlations/types';
import { SAMPLER_SHARD_SIZE } from '../../../../plugins/apm/common/correlations/constants';

// These tests go through the full sequence of queries required
// to get the final results for a latency correlation analysis.
Expand Down Expand Up @@ -196,7 +195,6 @@ export default function ApiTest({ getService }: FtrProviderContext) {
body: {
...getOptions(),
fieldsToSample: [...fieldsToSample],
samplerShardSize: SAMPLER_SHARD_SIZE,
},
},
});
Expand Down

0 comments on commit 0da5cf6

Please sign in to comment.