Skip to content

Commit

Permalink
Merge branch '7.9' into backport/7.9/pr-72552
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 22, 2020
2 parents b1575d5 + 45eb60a commit 74406cf
Show file tree
Hide file tree
Showing 17 changed files with 6,199 additions and 7 deletions.
21 changes: 20 additions & 1 deletion x-pack/plugins/apm/server/lib/observability_overview/has_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { PROCESSOR_EVENT } from '../../../common/elasticsearch_fieldnames';
import { ProcessorEvent } from '../../../common/processor_event';
import { Setup } from '../helpers/setup_request';

export async function hasData({ setup }: { setup: Setup }) {
Expand All @@ -15,7 +17,24 @@ export async function hasData({ setup }: { setup: Setup }) {
indices['apm_oss.metricsIndices'],
],
terminateAfter: 1,
size: 0,
body: {
size: 0,
query: {
bool: {
filter: [
{
terms: {
[PROCESSOR_EVENT]: [
ProcessorEvent.error,
ProcessorEvent.metric,
ProcessorEvent.transaction,
],
},
},
],
},
},
},
};

const response = await client.search(params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TRANSACTION_TYPE,
USER_AGENT_NAME,
TRANSACTION_DURATION,
TRANSACTION_NAME,
} from '../../../../common/elasticsearch_fieldnames';
import { rangeFilter } from '../../../../common/utils/range_filter';
import { getBucketSize } from '../../helpers/get_bucket_size';
Expand All @@ -23,15 +24,20 @@ export type ESResponse = PromiseReturnType<typeof fetcher>;

export function fetcher(options: Options) {
const { end, client, indices, start, uiFiltersES } = options.setup;
const { serviceName } = options;
const { serviceName, transactionName } = options;
const { intervalString } = getBucketSize(start, end, 'auto');

const transactionNameFilter = transactionName
? [{ term: { [TRANSACTION_NAME]: transactionName } }]
: [];

const filter: ESFilter[] = [
{ term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } },
{ term: { [SERVICE_NAME]: serviceName } },
{ term: { [TRANSACTION_TYPE]: TRANSACTION_PAGE_LOAD } },
{ range: rangeFilter(start, end) },
...uiFiltersES,
...transactionNameFilter,
];

const params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { transformer } from './transformer';
export interface Options {
serviceName: string;
setup: Setup & SetupTimeRange & SetupUIFilters;
transactionName?: string;
}

export type AvgDurationByBrowserAPIResponse = Array<{
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/server/routes/transaction_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const transactionGroupsAvgDurationByBrowser = createRoute(() => ({
}),
query: t.intersection([
t.partial({
transactionType: t.string,
transactionName: t.string,
}),
uiFiltersRt,
Expand All @@ -174,10 +173,12 @@ export const transactionGroupsAvgDurationByBrowser = createRoute(() => ({
handler: async ({ context, request }) => {
const setup = await setupRequest(context, request);
const { serviceName } = context.params.path;
const { transactionName } = context.params.query;

return getTransactionAvgDurationByBrowser({
serviceName,
setup,
transactionName,
});
},
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const scheduleTaskFnFactory: ScheduleTaskFnFactory<ESQueueCreateJobFn<
JobParamsPNG
>> = function createJobFactoryFn(reporting) {
const config = reporting.getConfig();
const setupDeps = reporting.getPluginSetupDeps();
const crypto = cryptoFactory(config.get('encryptionKey'));

return async function scheduleTask(
Expand All @@ -32,7 +31,7 @@ export const scheduleTaskFnFactory: ScheduleTaskFnFactory<ESQueueCreateJobFn<
headers: serializedEncryptedHeaders,
browserTimezone,
layout,
basePath: setupDeps.basePath(req),
basePath: config.kbnConfig.get('server', 'basePath'),
forceNow: new Date().toISOString(),
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const scheduleTaskFnFactory: ScheduleTaskFnFactory<ESQueueCreateJobFn<
JobParamsPDF
>> = function createJobFactoryFn(reporting, logger) {
const config = reporting.getConfig();
const setupDeps = reporting.getPluginSetupDeps();
const crypto = cryptoFactory(config.get('encryptionKey'));
const compatibilityShim = compatibilityShimFactory(logger);

Expand All @@ -30,7 +29,7 @@ export const scheduleTaskFnFactory: ScheduleTaskFnFactory<ESQueueCreateJobFn<
validateUrls(relativeUrls);

return {
basePath: setupDeps.basePath(req),
basePath: config.kbnConfig.get('server', 'basePath'),
browserTimezone,
forceNow: new Date().toISOString(),
headers: serializedEncryptedHeaders,
Expand Down
Binary file not shown.
Loading

0 comments on commit 74406cf

Please sign in to comment.