Skip to content

Commit

Permalink
Revert "[APM] Adds support for metrics for latency distribution histo…
Browse files Browse the repository at this point in the history
…gram (#136083)" (#136293)

This reverts commit e337b58.
  • Loading branch information
ogupte authored Jul 13, 2022
1 parent 5bb7a83 commit 469d6f8
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ import { scaleLog } from 'd3-scale';

import { isFiniteNumber } from '@kbn/observability-plugin/common/utils/is_finite_number';
import { CommonCorrelationsQueryParams } from '../../../../common/correlations/types';
import {
SPAN_DURATION,
TRANSACTION_DURATION,
} from '../../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup } from '../../../lib/helpers/setup_request';
import { getCommonCorrelationsQuery } from './get_common_correlations_query';
import { getDurationField } from '../utils';

const getHistogramRangeSteps = (min: number, max: number, steps: number) => {
// A d3 based scale function as a helper to get equally distributed bins on a log scale.
Expand All @@ -39,7 +42,8 @@ export const fetchDurationHistogramRangeSteps = async ({

const steps = 100;

const durationField = getDurationField(eventType);
const durationField =
eventType === ProcessorEvent.span ? SPAN_DURATION : TRANSACTION_DURATION;

const resp = await apmEventClient.search(
'get_duration_histogram_range_steps',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
* 2.0.
*/

import {
SPAN_DURATION,
TRANSACTION_DURATION,
} from '../../../../common/elasticsearch_fieldnames';
import { SIGNIFICANT_VALUE_DIGITS } from '../../../../common/correlations/constants';
import { Setup } from '../../../lib/helpers/setup_request';
import { ProcessorEvent } from '../../../../common/processor_event';
import { getCommonCorrelationsQuery } from './get_common_correlations_query';
import { CommonCorrelationsQueryParams } from '../../../../common/correlations/types';
import { getDurationField } from '../utils';

export const fetchDurationPercentiles = async ({
eventType,
Expand All @@ -29,34 +32,36 @@ export const fetchDurationPercentiles = async ({
totalDocs: number;
percentiles: Record<string, number>;
}> => {
const params = {
apm: { events: [eventType] },
body: {
track_total_hits: true,
query: getCommonCorrelationsQuery({
start,
end,
environment,
kuery,
query,
}),
size: 0,
aggs: {
duration_percentiles: {
percentiles: {
hdr: {
number_of_significant_value_digits: SIGNIFICANT_VALUE_DIGITS,
const response = await setup.apmEventClient.search(
'get_duration_percentiles',
{
apm: { events: [eventType] },
body: {
track_total_hits: true,
query: getCommonCorrelationsQuery({
start,
end,
environment,
kuery,
query,
}),
size: 0,
aggs: {
duration_percentiles: {
percentiles: {
hdr: {
number_of_significant_value_digits: SIGNIFICANT_VALUE_DIGITS,
},
field:
eventType === ProcessorEvent.span
? SPAN_DURATION
: TRANSACTION_DURATION,
...(Array.isArray(percents) ? { percents } : {}),
},
field: getDurationField(eventType),
...(Array.isArray(percents) ? { percents } : {}),
},
},
},
},
};
const response = await setup.apmEventClient.search(
'get_duration_percentiles',
params
}
);

// return early with no results if the search didn't return any documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
SPAN_DURATION,
TRANSACTION_DURATION,
} from '../../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup } from '../../../lib/helpers/setup_request';
import { getCommonCorrelationsQuery } from './get_common_correlations_query';
import { Environment } from '../../../../common/environment_rt';
import { getDurationField } from '../utils';

export const fetchDurationRanges = async ({
rangeSteps,
Expand Down Expand Up @@ -61,7 +64,10 @@ export const fetchDurationRanges = async ({
aggs: {
logspace_ranges: {
range: {
field: getDurationField(eventType),
field:
eventType === ProcessorEvent.span
? SPAN_DURATION
: TRANSACTION_DURATION,
ranges,
},
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

export { computeExpectationsAndRanges } from './compute_expectations_and_ranges';
export { splitAllSettledPromises } from './split_all_settled_promises';
export { getDurationField } from './get_duration_field';
12 changes: 1 addition & 11 deletions x-pack/plugins/apm/server/routes/latency_distribution/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { termQuery } from '@kbn/observability-plugin/server';
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { getOverallLatencyDistribution } from './get_overall_latency_distribution';
import { setupRequest } from '../../lib/helpers/setup_request';
import { getSearchAggregatedTransactions } from '../../lib/helpers/transactions';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { environmentRt, kueryRt, rangeRt } from '../default_api_types';
import {
Expand Down Expand Up @@ -62,18 +61,9 @@ const latencyOverallTransactionDistributionRoute = createApmServerRoute({
termFilters,
} = resources.params.body;

const searchAggregatedTransactions = await getSearchAggregatedTransactions({
...setup,
kuery,
start,
end,
});

return getOverallLatencyDistribution({
setup,
eventType: searchAggregatedTransactions
? ProcessorEvent.metric
: ProcessorEvent.transaction,
eventType: ProcessorEvent.transaction,
environment,
kuery,
start,
Expand Down

0 comments on commit 469d6f8

Please sign in to comment.