Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Remove start and end from setupRequest #112828

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions x-pack/plugins/apm/public/utils/testHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export function expectTextsInDocument(output: any, texts: string[]) {
}

interface MockSetup {
start: number;
end: number;
apmEventClient: any;
internalClient: any;
config: APMConfig;
Expand Down Expand Up @@ -162,8 +160,6 @@ export async function inspectSearchParams(
let error;

const mockSetup = {
start: 1528113600000,
end: 1528977600000,
apmEventClient: { search: spy } as any,
internalClient: { search: spy } as any,
config: new Proxy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,29 @@ import {
getSearchAggregatedTransactions,
getTransactionDurationFieldForAggregatedTransactions,
} from '../../helpers/aggregated_transactions';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';

export async function getTransactionDurationChartPreview({
alertParams,
setup,
}: {
alertParams: AlertParams;
setup: Setup & SetupTimeRange;
setup: Setup;
}) {
const searchAggregatedTransactions = await getSearchAggregatedTransactions({
...setup,
kuery: '',
});

const { apmEventClient, start, end } = setup;
const { apmEventClient } = setup;
const {
aggregationType,
environment,
serviceName,
transactionType,
interval,
start,
end,
} = alertParams;
const searchAggregatedTransactions = await getSearchAggregatedTransactions({
...setup,
kuery: '',
});

const query = {
bool: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { ProcessorEvent } from '../../../../common/processor_event';
import { AlertParams } from '../../../routes/alerts/chart_preview';
import { rangeQuery } from '../../../../../observability/server';
import { environmentQuery } from '../../../../common/utils/environment_query';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';

export async function getTransactionErrorCountChartPreview({
setup,
alertParams,
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
alertParams: AlertParams;
}) {
const { apmEventClient, start, end } = setup;
const { serviceName, environment, interval } = alertParams;
const { apmEventClient } = setup;
const { serviceName, environment, interval, start, end } = alertParams;

const query = {
bool: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
getProcessorEventForAggregatedTransactions,
getSearchAggregatedTransactions,
} from '../../helpers/aggregated_transactions';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';
import {
calculateFailedTransactionRate,
getOutcomeAggregation,
Expand All @@ -27,17 +27,20 @@ export async function getTransactionErrorRateChartPreview({
setup,
alertParams,
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
alertParams: AlertParams;
}) {
const { apmEventClient } = setup;
const { serviceName, environment, transactionType, interval, start, end } =
alertParams;

Comment on lines +33 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor thing but I noticed this elsewhere also: probably unintentional on your part but it's easier for a reviewer to understand the actual changes if lines are not re-ordered like here.

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

const { apmEventClient, start, end } = setup;
const { serviceName, environment, transactionType, interval } = alertParams;

const outcomes = getOutcomeAggregation();

const params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { AggregationOptionsByType } from '../../../../../../../src/core/types/el
import { ESFilter } from '../../../../../../../src/core/types/elasticsearch';
import { EVENT_OUTCOME } from '../../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';
import { getBucketSize } from '../../helpers/get_bucket_size';
import {
getTimeseriesAggregation,
Expand All @@ -27,7 +27,7 @@ interface Options extends CorrelationsOptions {
fieldNames: string[];
}
export async function getCorrelationsForFailedTransactions(options: Options) {
const { fieldNames, setup } = options;
const { fieldNames, setup, start, end } = options;
const { apmEventClient } = setup;
const filters = getCorrelationsFilters(options);

Expand Down Expand Up @@ -82,19 +82,23 @@ export async function getCorrelationsForFailedTransactions(options: Options) {
);

const topSigTerms = processSignificantTermAggs({ sigTermAggs });
return getErrorRateTimeSeries({ setup, filters, topSigTerms });
return getErrorRateTimeSeries({ setup, filters, topSigTerms, start, end });
}

export async function getErrorRateTimeSeries({
setup,
filters,
topSigTerms,
start,
end,
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
filters: ESFilter[];
topSigTerms: TopSigTerm[];
start: number;
end: number;
}) {
const { start, end, apmEventClient } = setup;
const { apmEventClient } = setup;
const { intervalString } = getBucketSize({ start, end, numBuckets: 15 });

if (isEmpty(topSigTerms)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
import { CorrelationsOptions, getCorrelationsFilters } from '../get_filters';

export async function getOverallErrorTimeseries(options: CorrelationsOptions) {
const { setup } = options;
const { setup, start, end } = options;
const filters = getCorrelationsFilters(options);
const { start, end, apmEventClient } = setup;
const { apmEventClient } = setup;
const { intervalString } = getBucketSize({ start, end, numBuckets: 15 });

const params = {
Expand Down
9 changes: 6 additions & 3 deletions x-pack/plugins/apm/server/lib/correlations/get_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { Setup, SetupTimeRange } from '../helpers/setup_request';
import { Setup } from '../helpers/setup_request';
import { ESFilter } from '../../../../../../src/core/types/elasticsearch';
import { rangeQuery, kqlQuery } from '../../../../observability/server';
import { environmentQuery } from '../../../common/utils/environment_query';
Expand All @@ -18,12 +18,14 @@ import {
import { ProcessorEvent } from '../../../common/processor_event';

export interface CorrelationsOptions {
setup: Setup & SetupTimeRange;
setup: Setup;
environment: string;
kuery: string;
serviceName: string | undefined;
transactionType: string | undefined;
transactionName: string | undefined;
start: number;
end: number;
}

export function getCorrelationsFilters({
Expand All @@ -33,8 +35,9 @@ export function getCorrelationsFilters({
serviceName,
transactionType,
transactionName,
start,
end,
}: CorrelationsOptions) {
const { start, end } = setup;
const correlationsFilters: ESFilter[] = [
{ term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } },
...rangeQuery(start, end),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { ESFilter } from '../../../../../../../src/core/types/elasticsearch';
import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';

export async function getDurationForPercentile({
durationPercentile,
Expand All @@ -17,7 +17,7 @@ export async function getDurationForPercentile({
}: {
durationPercentile: number;
filters: ESFilter[];
setup: Setup & SetupTimeRange;
setup: Setup;
}) {
const { apmEventClient } = setup;
const res = await apmEventClient.search('get_duration_for_percentiles', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { AggregationOptionsByType } from '../../../../../../../src/core/types/elasticsearch';
import { ESFilter } from '../../../../../../../src/core/types/elasticsearch';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';
import { TopSigTerm } from '../process_significant_term_aggs';

import {
Expand All @@ -23,7 +23,7 @@ export async function getLatencyDistribution({
maxLatency,
distributionInterval,
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
filters: ESFilter[];
topSigTerms: TopSigTerm[];
maxLatency: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
import { ESFilter } from '../../../../../../../src/core/types/elasticsearch';
import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../../common/processor_event';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import { Setup } from '../../helpers/setup_request';
import { TopSigTerm } from '../process_significant_term_aggs';

export async function getMaxLatency({
setup,
filters,
topSigTerms = [],
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
filters: ESFilter[];
topSigTerms?: TopSigTerm[];
}) {
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 @@ -24,6 +24,8 @@ describe('getEnvironments', () => {
setup,
serviceName: 'foo',
searchAggregatedTransactions: false,
start: 0,
end: 50000,
})
);

Expand All @@ -35,6 +37,8 @@ describe('getEnvironments', () => {
getEnvironments({
setup,
searchAggregatedTransactions: false,
start: 0,
end: 50000,
})
);

Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/apm/server/lib/environments/get_environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_valu
import { ProcessorEvent } from '../../../common/processor_event';
import { rangeQuery } from '../../../../observability/server';
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
import { Setup } from '../helpers/setup_request';

/**
* This is used for getting the list of environments for the environments selector,
Expand All @@ -23,16 +23,20 @@ export async function getEnvironments({
setup,
serviceName,
searchAggregatedTransactions,
start,
end,
}: {
setup: Setup & SetupTimeRange;
setup: Setup;
serviceName?: string;
searchAggregatedTransactions: boolean;
start: number;
end: number;
}) {
const operationName = serviceName
? 'get_environments_for_service'
: 'get_environments';

const { start, end, apmEventClient, config } = setup;
const { apmEventClient, config } = setup;

const filter = rangeQuery(start, end);

Expand Down

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

Loading