parent
6977be0140
commit
b0c5b2f741
104 changed files with 3424 additions and 3464 deletions
|
@ -14,6 +14,7 @@ export interface SpanOptions {
|
|||
type?: string;
|
||||
subtype?: string;
|
||||
labels?: Record<string, string>;
|
||||
intercept?: boolean;
|
||||
}
|
||||
|
||||
type Span = Exclude<typeof agent.currentSpan, undefined | null>;
|
||||
|
@ -36,24 +37,28 @@ export async function withSpan<T>(
|
|||
): Promise<T> {
|
||||
const options = parseSpanOptions(optionsOrName);
|
||||
|
||||
const { name, type, subtype, labels } = options;
|
||||
const { name, type, subtype, labels, intercept } = options;
|
||||
|
||||
if (!agent.isStarted()) {
|
||||
return cb();
|
||||
}
|
||||
|
||||
let createdSpan: Span | undefined;
|
||||
|
||||
// When a span starts, it's marked as the active span in its context.
|
||||
// When it ends, it's not untracked, which means that if a span
|
||||
// starts directly after this one ends, the newly started span is a
|
||||
// child of this span, even though it should be a sibling.
|
||||
// To mitigate this, we queue a microtask by awaiting a promise.
|
||||
if (!intercept) {
|
||||
await Promise.resolve();
|
||||
|
||||
const span = agent.startSpan(name);
|
||||
createdSpan = agent.startSpan(name) ?? undefined;
|
||||
|
||||
if (!span) {
|
||||
if (!createdSpan) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
|
||||
// If a span is created in the same context as the span that we just
|
||||
// started, it will be a sibling, not a child. E.g., the Elasticsearch span
|
||||
|
@ -61,33 +66,51 @@ export async function withSpan<T>(
|
|||
// mitigate this we create a new context.
|
||||
|
||||
return runInNewContext(() => {
|
||||
const promise = cb(createdSpan);
|
||||
|
||||
let span: Span | undefined = createdSpan;
|
||||
|
||||
if (intercept) {
|
||||
span = agent.currentSpan ?? undefined;
|
||||
}
|
||||
|
||||
if (!span) {
|
||||
return promise;
|
||||
}
|
||||
|
||||
const targetedSpan = span;
|
||||
|
||||
if (name) {
|
||||
targetedSpan.name = name;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
if (type) {
|
||||
span.type = type;
|
||||
targetedSpan.type = type;
|
||||
}
|
||||
if (subtype) {
|
||||
span.subtype = subtype;
|
||||
targetedSpan.subtype = subtype;
|
||||
}
|
||||
|
||||
if (labels) {
|
||||
span.addLabels(labels);
|
||||
targetedSpan.addLabels(labels);
|
||||
}
|
||||
|
||||
return cb(span)
|
||||
return promise
|
||||
.then((res) => {
|
||||
if (!span.outcome || span.outcome === 'unknown') {
|
||||
span.outcome = 'success';
|
||||
if (!targetedSpan.outcome || targetedSpan.outcome === 'unknown') {
|
||||
targetedSpan.outcome = 'success';
|
||||
}
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
if (!span.outcome || span.outcome === 'unknown') {
|
||||
span.outcome = 'failure';
|
||||
if (!targetedSpan.outcome || targetedSpan.outcome === 'unknown') {
|
||||
targetedSpan.outcome = 'failure';
|
||||
}
|
||||
throw err;
|
||||
})
|
||||
.finally(() => {
|
||||
span.end();
|
||||
targetedSpan.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,18 +15,16 @@ import {
|
|||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { environmentQuery, rangeQuery } from '../../../../server/utils/queries';
|
||||
import { AlertParams } from '../../../routes/alerts/chart_preview';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { getBucketSize } from '../../helpers/get_bucket_size';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
export function getTransactionDurationChartPreview({
|
||||
export async function getTransactionDurationChartPreview({
|
||||
alertParams,
|
||||
setup,
|
||||
}: {
|
||||
alertParams: AlertParams;
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_transaction_duration_chart_preview', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
const {
|
||||
aggregationType,
|
||||
|
@ -74,7 +72,10 @@ export function getTransactionDurationChartPreview({
|
|||
apm: { events: [ProcessorEvent.transaction] },
|
||||
body: { size: 0, query, aggs },
|
||||
};
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_transaction_duration_chart_preview',
|
||||
params
|
||||
);
|
||||
|
||||
if (!resp.aggregations) {
|
||||
return [];
|
||||
|
@ -92,5 +93,4 @@ export function getTransactionDurationChartPreview({
|
|||
|
||||
return { x, y };
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,18 +9,16 @@ import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames';
|
|||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { AlertParams } from '../../../routes/alerts/chart_preview';
|
||||
import { environmentQuery, rangeQuery } from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { getBucketSize } from '../../helpers/get_bucket_size';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
export function getTransactionErrorCountChartPreview({
|
||||
export async function getTransactionErrorCountChartPreview({
|
||||
setup,
|
||||
alertParams,
|
||||
}: {
|
||||
setup: Setup & SetupTimeRange;
|
||||
alertParams: AlertParams;
|
||||
}) {
|
||||
return withApmSpan('get_transaction_error_count_chart_preview', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
const { serviceName, environment } = alertParams;
|
||||
|
||||
|
@ -50,7 +48,10 @@ export function getTransactionErrorCountChartPreview({
|
|||
body: { size: 0, query, aggs },
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_transaction_error_count_chart_preview',
|
||||
params
|
||||
);
|
||||
|
||||
if (!resp.aggregations) {
|
||||
return [];
|
||||
|
@ -62,5 +63,4 @@ export function getTransactionErrorCountChartPreview({
|
|||
y: bucket.doc_count,
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -64,7 +64,10 @@ export async function getTransactionErrorRateChartPreview({
|
|||
body: { size: 0, query, aggs },
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_transaction_error_rate_chart_preview',
|
||||
params
|
||||
);
|
||||
|
||||
if (!resp.aggregations) {
|
||||
return [];
|
||||
|
|
|
@ -21,14 +21,12 @@ import {
|
|||
getTimeseriesAggregation,
|
||||
getTransactionErrorRateTimeSeries,
|
||||
} from '../../helpers/transaction_error_rate';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { CorrelationsOptions, getCorrelationsFilters } from '../get_filters';
|
||||
|
||||
interface Options extends CorrelationsOptions {
|
||||
fieldNames: string[];
|
||||
}
|
||||
export async function getCorrelationsForFailedTransactions(options: Options) {
|
||||
return withApmSpan('get_correlations_for_failed_transactions', async () => {
|
||||
const { fieldNames, setup } = options;
|
||||
const { apmEventClient } = setup;
|
||||
const filters = getCorrelationsFilters(options);
|
||||
|
@ -70,7 +68,10 @@ export async function getCorrelationsForFailedTransactions(options: Options) {
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_correlations_for_failed_transactions',
|
||||
params
|
||||
);
|
||||
if (!response.aggregations) {
|
||||
return { significantTerms: [] };
|
||||
}
|
||||
|
@ -82,7 +83,6 @@ export async function getCorrelationsForFailedTransactions(options: Options) {
|
|||
|
||||
const topSigTerms = processSignificantTermAggs({ sigTermAggs });
|
||||
return getErrorRateTimeSeries({ setup, filters, topSigTerms });
|
||||
});
|
||||
}
|
||||
|
||||
export async function getErrorRateTimeSeries({
|
||||
|
@ -94,7 +94,6 @@ export async function getErrorRateTimeSeries({
|
|||
filters: ESFilter[];
|
||||
topSigTerms: TopSigTerm[];
|
||||
}) {
|
||||
return withApmSpan('get_error_rate_timeseries', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
const { intervalString } = getBucketSize({ start, end, numBuckets: 15 });
|
||||
|
||||
|
@ -130,7 +129,10 @@ export async function getErrorRateTimeSeries({
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_error_rate_timeseries',
|
||||
params
|
||||
);
|
||||
const { aggregations } = response;
|
||||
|
||||
if (!aggregations) {
|
||||
|
@ -147,5 +149,4 @@ export async function getErrorRateTimeSeries({
|
|||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,11 +11,9 @@ import {
|
|||
getTimeseriesAggregation,
|
||||
getTransactionErrorRateTimeSeries,
|
||||
} from '../../helpers/transaction_error_rate';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { CorrelationsOptions, getCorrelationsFilters } from '../get_filters';
|
||||
|
||||
export async function getOverallErrorTimeseries(options: CorrelationsOptions) {
|
||||
return withApmSpan('get_error_rate_timeseries', async () => {
|
||||
const { setup } = options;
|
||||
const filters = getCorrelationsFilters(options);
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
@ -33,7 +31,10 @@ export async function getOverallErrorTimeseries(options: CorrelationsOptions) {
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_error_rate_timeseries',
|
||||
params
|
||||
);
|
||||
const { aggregations } = response;
|
||||
|
||||
if (!aggregations) {
|
||||
|
@ -47,5 +48,4 @@ export async function getOverallErrorTimeseries(options: CorrelationsOptions) {
|
|||
),
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ export async function getCorrelationsForSlowTransactions(options: Options) {
|
|||
return { significantTerms: [] };
|
||||
}
|
||||
|
||||
const response = await withApmSpan('get_significant_terms', () => {
|
||||
const params = {
|
||||
apm: { events: [ProcessorEvent.transaction] },
|
||||
body: {
|
||||
|
@ -93,8 +92,12 @@ export async function getCorrelationsForSlowTransactions(options: Options) {
|
|||
}, {} as Record<string, { significant_terms: AggregationOptionsByType['significant_terms'] }>),
|
||||
},
|
||||
};
|
||||
return apmEventClient.search(params);
|
||||
});
|
||||
|
||||
const response = await apmEventClient.search(
|
||||
'get_significant_terms',
|
||||
params
|
||||
);
|
||||
|
||||
if (!response.aggregations) {
|
||||
return { significantTerms: [] };
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { ESFilter } from '../../../../../../../typings/elasticsearch';
|
||||
import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
export async function getDurationForPercentile({
|
||||
|
@ -20,9 +19,8 @@ export async function getDurationForPercentile({
|
|||
filters: ESFilter[];
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_duration_for_percentiles', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
const res = await apmEventClient.search({
|
||||
const res = await apmEventClient.search('get_duration_for_percentiles', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.transaction],
|
||||
},
|
||||
|
@ -42,9 +40,6 @@ export async function getDurationForPercentile({
|
|||
},
|
||||
});
|
||||
|
||||
const duration = Object.values(
|
||||
res.aggregations?.percentile.values || {}
|
||||
)[0];
|
||||
const duration = Object.values(res.aggregations?.percentile.values || {})[0];
|
||||
return duration || 0;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ESFilter } from '../../../../../../../typings/elasticsearch';
|
|||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { TopSigTerm } from '../process_significant_term_aggs';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
import {
|
||||
getDistributionAggregation,
|
||||
trimBuckets,
|
||||
|
@ -29,7 +29,6 @@ export async function getLatencyDistribution({
|
|||
maxLatency: number;
|
||||
distributionInterval: number;
|
||||
}) {
|
||||
return withApmSpan('get_latency_distribution', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const distributionAgg = getDistributionAggregation(
|
||||
|
@ -68,9 +67,11 @@ export async function getLatencyDistribution({
|
|||
},
|
||||
};
|
||||
|
||||
const response = await withApmSpan('get_terms_distribution', () =>
|
||||
apmEventClient.search(params)
|
||||
const response = await apmEventClient.search(
|
||||
'get_latency_distribution',
|
||||
params
|
||||
);
|
||||
|
||||
type Agg = NonNullable<typeof response.aggregations>;
|
||||
|
||||
if (!response.aggregations) {
|
||||
|
@ -94,5 +95,4 @@ export async function getLatencyDistribution({
|
|||
})),
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { ESFilter } from '../../../../../../../typings/elasticsearch';
|
||||
import { TRANSACTION_DURATION } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { TopSigTerm } from '../process_significant_term_aggs';
|
||||
|
||||
|
@ -21,7 +20,6 @@ export async function getMaxLatency({
|
|||
filters: ESFilter[];
|
||||
topSigTerms?: TopSigTerm[];
|
||||
}) {
|
||||
return withApmSpan('get_max_latency', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -54,8 +52,7 @@ export async function getMaxLatency({
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_max_latency', params);
|
||||
// return response.aggregations?.max_latency.value;
|
||||
return Object.values(response.aggregations?.max_latency.values ?? {})[0];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -71,8 +71,9 @@ export async function getOverallLatencyDistribution(
|
|||
},
|
||||
};
|
||||
|
||||
const response = await withApmSpan('get_terms_distribution', () =>
|
||||
apmEventClient.search(params)
|
||||
const response = await apmEventClient.search(
|
||||
'get_terms_distribution',
|
||||
params
|
||||
);
|
||||
|
||||
if (!response.aggregations) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
} from '../../../common/elasticsearch_fieldnames';
|
||||
import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
/**
|
||||
* This is used for getting *all* environments, and does not filter by range.
|
||||
|
@ -30,10 +29,10 @@ export async function getAllEnvironments({
|
|||
searchAggregatedTransactions: boolean;
|
||||
includeMissing?: boolean;
|
||||
}) {
|
||||
const spanName = serviceName
|
||||
const operationName = serviceName
|
||||
? 'get_all_environments_for_service'
|
||||
: 'get_all_environments_for_all_services';
|
||||
return withApmSpan(spanName, async () => {
|
||||
|
||||
const { apmEventClient, config } = setup;
|
||||
const maxServiceEnvironments = config['xpack.apm.maxServiceEnvironments'];
|
||||
|
||||
|
@ -68,21 +67,18 @@ export async function getAllEnvironments({
|
|||
field: SERVICE_ENVIRONMENT,
|
||||
size: maxServiceEnvironments,
|
||||
...(!serviceName ? { min_doc_count: 0 } : {}),
|
||||
missing: includeMissing
|
||||
? ENVIRONMENT_NOT_DEFINED.value
|
||||
: undefined,
|
||||
missing: includeMissing ? ENVIRONMENT_NOT_DEFINED.value : undefined,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(operationName, params);
|
||||
|
||||
const environments =
|
||||
resp.aggregations?.environments.buckets.map(
|
||||
(bucket) => bucket.key as string
|
||||
) || [];
|
||||
return environments;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values';
|
||||
import { ProcessorEvent } from '../../../common/processor_event';
|
||||
import { rangeQuery } from '../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
|
||||
|
@ -29,11 +28,10 @@ export async function getEnvironments({
|
|||
serviceName?: string;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
const spanName = serviceName
|
||||
const operationName = serviceName
|
||||
? 'get_environments_for_service'
|
||||
: 'get_environments';
|
||||
|
||||
return withApmSpan(spanName, async () => {
|
||||
const { start, end, apmEventClient, config } = setup;
|
||||
|
||||
const filter = rangeQuery(start, end);
|
||||
|
@ -75,7 +73,7 @@ export async function getEnvironments({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(operationName, params);
|
||||
const aggs = resp.aggregations;
|
||||
const environmentsBuckets = aggs?.environments.buckets || [];
|
||||
|
||||
|
@ -84,5 +82,4 @@ export async function getEnvironments({
|
|||
);
|
||||
|
||||
return environments;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
exports[`get buckets should make the correct query 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
"get_error_distribution_buckets",
|
||||
Object {
|
||||
"apm": Object {
|
||||
"events": Array [
|
||||
|
|
|
@ -65,7 +65,7 @@ describe('get buckets', () => {
|
|||
});
|
||||
|
||||
it('should limit query results to error documents', () => {
|
||||
const query = clientSpy.mock.calls[0][0];
|
||||
const query = clientSpy.mock.calls[0][1];
|
||||
expect(query.apm.events).toEqual([ProcessorEvent.error]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,6 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
export async function getBuckets({
|
||||
|
@ -34,7 +33,6 @@ export async function getBuckets({
|
|||
bucketSize: number;
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_error_distribution_buckets', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
const filter: ESFilter[] = [
|
||||
{ term: { [SERVICE_NAME]: serviceName } },
|
||||
|
@ -74,7 +72,10 @@ export async function getBuckets({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_error_distribution_buckets',
|
||||
params
|
||||
);
|
||||
|
||||
const buckets = (resp.aggregations?.distribution.buckets || []).map(
|
||||
(bucket) => ({
|
||||
|
@ -87,5 +88,4 @@ export async function getBuckets({
|
|||
noHits: resp.hits.total.value === 0,
|
||||
buckets: resp.hits.total.value > 0 ? buckets : [],
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,11 +17,10 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { getTransaction } from '../transactions/get_transaction';
|
||||
|
||||
export function getErrorGroupSample({
|
||||
export async function getErrorGroupSample({
|
||||
environment,
|
||||
kuery,
|
||||
serviceName,
|
||||
|
@ -34,7 +33,6 @@ export function getErrorGroupSample({
|
|||
groupId: string;
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_error_group_sample', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -62,7 +60,7 @@ export function getErrorGroupSample({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search('get_error_group_sample', params);
|
||||
const error = resp.hits.hits[0]?._source;
|
||||
const transactionId = error?.transaction?.id;
|
||||
const traceId = error?.trace?.id;
|
||||
|
@ -77,5 +75,4 @@ export function getErrorGroupSample({
|
|||
error,
|
||||
occurrencesCount: resp.hits.total.value,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,11 +15,10 @@ import {
|
|||
} from '../../../common/elasticsearch_fieldnames';
|
||||
import { getErrorGroupsProjection } from '../../projections/errors';
|
||||
import { mergeProjection } from '../../projections/util/merge_projection';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { getErrorName } from '../helpers/get_error_name';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
|
||||
export function getErrorGroups({
|
||||
export async function getErrorGroups({
|
||||
environment,
|
||||
kuery,
|
||||
serviceName,
|
||||
|
@ -34,7 +33,6 @@ export function getErrorGroups({
|
|||
sortDirection?: 'asc' | 'desc';
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_error_groups', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
// sort buckets by last occurrence of error
|
||||
|
@ -94,12 +92,11 @@ export function getErrorGroups({
|
|||
},
|
||||
});
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search('get_error_groups', params);
|
||||
|
||||
// aggregations can be undefined when no matching indices are found.
|
||||
// this is an exception rather than the rule so the ES type does not account for this.
|
||||
const hits = (resp.aggregations?.error_groups.buckets || []).map(
|
||||
(bucket) => {
|
||||
const hits = (resp.aggregations?.error_groups.buckets || []).map((bucket) => {
|
||||
const source = bucket.sample.hits.hits[0]._source;
|
||||
const message = getErrorName(source);
|
||||
|
||||
|
@ -112,9 +109,7 @@ export function getErrorGroups({
|
|||
handled: source.error.exception?.[0].handled,
|
||||
type: source.error.exception?.[0].type,
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return hits;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import {
|
|||
} from '../../../../common/elasticsearch_fieldnames';
|
||||
import { APMConfig } from '../../..';
|
||||
import { APMEventClient } from '../create_es_client/create_apm_event_client';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export async function getHasAggregatedTransactions({
|
||||
start,
|
||||
|
@ -25,8 +24,9 @@ export async function getHasAggregatedTransactions({
|
|||
end?: number;
|
||||
apmEventClient: APMEventClient;
|
||||
}) {
|
||||
return withApmSpan('get_has_aggregated_transactions', async () => {
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_has_aggregated_transactions',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -41,14 +41,14 @@ export async function getHasAggregatedTransactions({
|
|||
},
|
||||
},
|
||||
terminateAfter: 1,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (response.hits.total.value > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
export async function getSearchAggregatedTransactions({
|
||||
|
|
|
@ -81,17 +81,26 @@ export async function callAsyncWithDebug<T>({
|
|||
return res;
|
||||
}
|
||||
|
||||
export const getDebugBody = (
|
||||
params: Record<string, any>,
|
||||
requestType: string
|
||||
) => {
|
||||
export const getDebugBody = ({
|
||||
params,
|
||||
requestType,
|
||||
operationName,
|
||||
}: {
|
||||
params: Record<string, any>;
|
||||
requestType: string;
|
||||
operationName: string;
|
||||
}) => {
|
||||
const operationLine = `${operationName}\n`;
|
||||
|
||||
if (requestType === 'search') {
|
||||
return `GET ${params.index}/_search\n${formatObj(params.body)}`;
|
||||
return `${operationLine}GET ${params.index}/_search\n${formatObj(
|
||||
params.body
|
||||
)}`;
|
||||
}
|
||||
|
||||
return `${chalk.bold('ES operation:')} ${requestType}\n${chalk.bold(
|
||||
'ES query:'
|
||||
)}\n${formatObj(params)}`;
|
||||
)}\n${operationLine}${formatObj(params)}`;
|
||||
};
|
||||
|
||||
export const getDebugTitle = (request: KibanaRequest) =>
|
||||
|
|
|
@ -47,7 +47,7 @@ describe('createApmEventClient', () => {
|
|||
},
|
||||
});
|
||||
|
||||
await eventClient.search({
|
||||
await eventClient.search('foo', {
|
||||
apm: {
|
||||
events: [],
|
||||
},
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { ValuesType } from 'utility-types';
|
||||
import { withApmSpan } from '../../../../utils/with_apm_span';
|
||||
import { Profile } from '../../../../../typings/es_schemas/ui/profile';
|
||||
import {
|
||||
ElasticsearchClient,
|
||||
|
@ -34,6 +35,7 @@ import { unpackProcessorEvents } from './unpack_processor_events';
|
|||
export type APMEventESSearchRequest = Omit<ESSearchRequest, 'index'> & {
|
||||
apm: {
|
||||
events: ProcessorEvent[];
|
||||
includeLegacyData?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -78,11 +80,13 @@ export function createApmEventClient({
|
|||
}) {
|
||||
return {
|
||||
async search<TParams extends APMEventESSearchRequest>(
|
||||
params: TParams,
|
||||
{ includeLegacyData = false } = {}
|
||||
operationName: string,
|
||||
params: TParams
|
||||
): Promise<TypedSearchResponse<TParams>> {
|
||||
const withProcessorEventFilter = unpackProcessorEvents(params, indices);
|
||||
|
||||
const { includeLegacyData = false } = params.apm;
|
||||
|
||||
const withPossibleLegacyDataFilter = !includeLegacyData
|
||||
? addFilterToExcludeLegacyData(withProcessorEventFilter)
|
||||
: withProcessorEventFilter;
|
||||
|
@ -98,15 +102,18 @@ export function createApmEventClient({
|
|||
|
||||
return callAsyncWithDebug({
|
||||
cb: () => {
|
||||
const searchPromise = cancelEsRequestOnAbort(
|
||||
esClient.search(searchParams),
|
||||
request
|
||||
const searchPromise = withApmSpan(operationName, () =>
|
||||
cancelEsRequestOnAbort(esClient.search(searchParams), request)
|
||||
);
|
||||
|
||||
return unwrapEsResponse(searchPromise);
|
||||
},
|
||||
getDebugMessage: () => ({
|
||||
body: getDebugBody(searchParams, requestType),
|
||||
body: getDebugBody({
|
||||
params: searchParams,
|
||||
requestType,
|
||||
operationName,
|
||||
}),
|
||||
title: getDebugTitle(request),
|
||||
}),
|
||||
isCalledWithInternalUser: false,
|
||||
|
|
|
@ -31,7 +31,9 @@ export function createInternalESClient({
|
|||
}: Pick<APMRouteHandlerResources, 'context' | 'request'> & { debug: boolean }) {
|
||||
const { asInternalUser } = context.core.elasticsearch.client;
|
||||
|
||||
function callEs<T extends { body: any }>({
|
||||
function callEs<T extends { body: any }>(
|
||||
operationName: string,
|
||||
{
|
||||
cb,
|
||||
requestType,
|
||||
params,
|
||||
|
@ -39,12 +41,13 @@ export function createInternalESClient({
|
|||
requestType: string;
|
||||
cb: () => TransportRequestPromise<T>;
|
||||
params: Record<string, any>;
|
||||
}) {
|
||||
}
|
||||
) {
|
||||
return callAsyncWithDebug({
|
||||
cb: () => unwrapEsResponse(cancelEsRequestOnAbort(cb(), request)),
|
||||
getDebugMessage: () => ({
|
||||
title: getDebugTitle(request),
|
||||
body: getDebugBody(params, requestType),
|
||||
body: getDebugBody({ params, requestType, operationName }),
|
||||
}),
|
||||
debug,
|
||||
isCalledWithInternalUser: true,
|
||||
|
@ -59,30 +62,37 @@ export function createInternalESClient({
|
|||
TDocument = unknown,
|
||||
TSearchRequest extends ESSearchRequest = ESSearchRequest
|
||||
>(
|
||||
operationName: string,
|
||||
params: TSearchRequest
|
||||
): Promise<ESSearchResponse<TDocument, TSearchRequest>> => {
|
||||
return callEs({
|
||||
return callEs(operationName, {
|
||||
requestType: 'search',
|
||||
cb: () => asInternalUser.search(params),
|
||||
params,
|
||||
});
|
||||
},
|
||||
index: <T>(params: APMIndexDocumentParams<T>) => {
|
||||
return callEs({
|
||||
index: <T>(operationName: string, params: APMIndexDocumentParams<T>) => {
|
||||
return callEs(operationName, {
|
||||
requestType: 'index',
|
||||
cb: () => asInternalUser.index(params),
|
||||
params,
|
||||
});
|
||||
},
|
||||
delete: (params: estypes.DeleteRequest): Promise<{ result: string }> => {
|
||||
return callEs({
|
||||
delete: (
|
||||
operationName: string,
|
||||
params: estypes.DeleteRequest
|
||||
): Promise<{ result: string }> => {
|
||||
return callEs(operationName, {
|
||||
requestType: 'delete',
|
||||
cb: () => asInternalUser.delete(params),
|
||||
params,
|
||||
});
|
||||
},
|
||||
indicesCreate: (params: estypes.IndicesCreateRequest) => {
|
||||
return callEs({
|
||||
indicesCreate: (
|
||||
operationName: string,
|
||||
params: estypes.IndicesCreateRequest
|
||||
) => {
|
||||
return callEs(operationName, {
|
||||
requestType: 'indices.create',
|
||||
cb: () => asInternalUser.indices.create(params),
|
||||
params,
|
||||
|
|
|
@ -109,7 +109,7 @@ describe('setupRequest', () => {
|
|||
it('calls callWithRequest', async () => {
|
||||
const mockResources = getMockResources();
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('foo', {
|
||||
apm: { events: [ProcessorEvent.transaction] },
|
||||
body: { foo: 'bar' },
|
||||
});
|
||||
|
@ -137,7 +137,7 @@ describe('setupRequest', () => {
|
|||
it('calls callWithInternalUser', async () => {
|
||||
const mockResources = getMockResources();
|
||||
const { internalClient } = await setupRequest(mockResources);
|
||||
await internalClient.search({
|
||||
await internalClient.search('foo', {
|
||||
index: ['apm-*'],
|
||||
body: { foo: 'bar' },
|
||||
} as any);
|
||||
|
@ -156,7 +156,7 @@ describe('setupRequest', () => {
|
|||
it('adds a range filter for `observer.version_major` to the existing filter', async () => {
|
||||
const mockResources = getMockResources();
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('foo', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.transaction],
|
||||
},
|
||||
|
@ -183,19 +183,15 @@ describe('setupRequest', () => {
|
|||
it('does not add a range filter for `observer.version_major` if includeLegacyData=true', async () => {
|
||||
const mockResources = getMockResources();
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
await apmEventClient.search(
|
||||
{
|
||||
await apmEventClient.search('foo', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
includeLegacyData: true,
|
||||
},
|
||||
body: {
|
||||
query: { bool: { filter: [{ term: { field: 'someTerm' } }] } },
|
||||
},
|
||||
},
|
||||
{
|
||||
includeLegacyData: true,
|
||||
}
|
||||
);
|
||||
});
|
||||
const params =
|
||||
mockResources.context.core.elasticsearch.client.asCurrentUser.search
|
||||
.mock.calls[0][0];
|
||||
|
@ -221,7 +217,7 @@ describe('without a bool filter', () => {
|
|||
it('adds a range filter for `observer.version_major`', async () => {
|
||||
const mockResources = getMockResources();
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('foo', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -251,7 +247,7 @@ describe('with includeFrozen=false', () => {
|
|||
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('foo', {
|
||||
apm: {
|
||||
events: [],
|
||||
},
|
||||
|
@ -273,7 +269,7 @@ describe('with includeFrozen=true', () => {
|
|||
|
||||
const { apmEventClient } = await setupRequest(mockResources);
|
||||
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('foo', {
|
||||
apm: { events: [] },
|
||||
});
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ export async function fetchAndTransformGcMetrics({
|
|||
serviceNodeName,
|
||||
chartBase,
|
||||
fieldName,
|
||||
operationName,
|
||||
}: {
|
||||
environment?: string;
|
||||
kuery?: string;
|
||||
|
@ -38,6 +39,7 @@ export async function fetchAndTransformGcMetrics({
|
|||
serviceNodeName?: string;
|
||||
chartBase: ChartBase;
|
||||
fieldName: typeof METRIC_JAVA_GC_COUNT | typeof METRIC_JAVA_GC_TIME;
|
||||
operationName: string;
|
||||
}) {
|
||||
const { start, end, apmEventClient, config } = setup;
|
||||
|
||||
|
@ -108,7 +110,7 @@ export async function fetchAndTransformGcMetrics({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(operationName, params);
|
||||
|
||||
const { aggregations } = response;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import { METRIC_JAVA_GC_COUNT } from '../../../../../../common/elasticsearch_fieldnames';
|
||||
import { Setup, SetupTimeRange } from '../../../../helpers/setup_request';
|
||||
import { fetchAndTransformGcMetrics } from './fetch_and_transform_gc_metrics';
|
||||
|
@ -45,8 +44,7 @@ function getGcRateChart({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_gc_rate_charts', () =>
|
||||
fetchAndTransformGcMetrics({
|
||||
return fetchAndTransformGcMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -54,8 +52,8 @@ function getGcRateChart({
|
|||
serviceNodeName,
|
||||
chartBase,
|
||||
fieldName: METRIC_JAVA_GC_COUNT,
|
||||
})
|
||||
);
|
||||
operationName: 'get_gc_rate_charts',
|
||||
});
|
||||
}
|
||||
|
||||
export { getGcRateChart };
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import { METRIC_JAVA_GC_TIME } from '../../../../../../common/elasticsearch_fieldnames';
|
||||
import { Setup, SetupTimeRange } from '../../../../helpers/setup_request';
|
||||
import { fetchAndTransformGcMetrics } from './fetch_and_transform_gc_metrics';
|
||||
|
@ -45,8 +44,7 @@ function getGcTimeChart({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_gc_time_charts', () =>
|
||||
fetchAndTransformGcMetrics({
|
||||
return fetchAndTransformGcMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -54,8 +52,8 @@ function getGcTimeChart({
|
|||
serviceNodeName,
|
||||
chartBase,
|
||||
fieldName: METRIC_JAVA_GC_TIME,
|
||||
})
|
||||
);
|
||||
operationName: 'get_gc_time_charts',
|
||||
});
|
||||
}
|
||||
|
||||
export { getGcTimeChart };
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import {
|
||||
METRIC_JAVA_HEAP_MEMORY_MAX,
|
||||
METRIC_JAVA_HEAP_MEMORY_COMMITTED,
|
||||
|
@ -65,8 +64,7 @@ export function getHeapMemoryChart({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_heap_memory_charts', () =>
|
||||
fetchAndTransformMetrics({
|
||||
return fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -81,6 +79,6 @@ export function getHeapMemoryChart({
|
|||
heapMemoryUsed: { avg: { field: METRIC_JAVA_HEAP_MEMORY_USED } },
|
||||
},
|
||||
additionalFilters: [{ term: { [AGENT_NAME]: 'java' } }],
|
||||
})
|
||||
);
|
||||
operationName: 'get_heap_memory_charts',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import {
|
||||
METRIC_JAVA_NON_HEAP_MEMORY_MAX,
|
||||
METRIC_JAVA_NON_HEAP_MEMORY_COMMITTED,
|
||||
|
@ -62,8 +61,7 @@ export async function getNonHeapMemoryChart({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_non_heap_memory_charts', () =>
|
||||
fetchAndTransformMetrics({
|
||||
return fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -80,6 +78,6 @@ export async function getNonHeapMemoryChart({
|
|||
},
|
||||
},
|
||||
additionalFilters: [{ term: { [AGENT_NAME]: 'java' } }],
|
||||
})
|
||||
);
|
||||
operationName: 'get_non_heap_memory_charts',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import {
|
||||
METRIC_JAVA_THREAD_COUNT,
|
||||
AGENT_NAME,
|
||||
|
@ -54,8 +53,7 @@ export async function getThreadCountChart({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_thread_count_charts', () =>
|
||||
fetchAndTransformMetrics({
|
||||
return fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -67,6 +65,6 @@ export async function getThreadCountChart({
|
|||
threadCountMax: { max: { field: METRIC_JAVA_THREAD_COUNT } },
|
||||
},
|
||||
additionalFilters: [{ term: { [AGENT_NAME]: 'java' } }],
|
||||
})
|
||||
);
|
||||
operationName: 'get_thread_count_charts',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import theme from '@elastic/eui/dist/eui_theme_light.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { withApmSpan } from '../../../../../utils/with_apm_span';
|
||||
import {
|
||||
METRIC_SYSTEM_CPU_PERCENT,
|
||||
METRIC_PROCESS_CPU_PERCENT,
|
||||
|
@ -66,8 +65,7 @@ export function getCPUChartData({
|
|||
serviceName: string;
|
||||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_cpu_metric_charts', () =>
|
||||
fetchAndTransformMetrics({
|
||||
return fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -80,6 +78,6 @@ export function getCPUChartData({
|
|||
processCPUAverage: { avg: { field: METRIC_PROCESS_CPU_PERCENT } },
|
||||
processCPUMax: { max: { field: METRIC_PROCESS_CPU_PERCENT } },
|
||||
},
|
||||
})
|
||||
);
|
||||
operationName: 'get_cpu_metric_charts',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -84,10 +84,7 @@ export async function getMemoryChartData({
|
|||
serviceNodeName?: string;
|
||||
}) {
|
||||
return withApmSpan('get_memory_metrics_charts', async () => {
|
||||
const cgroupResponse = await withApmSpan(
|
||||
'get_cgroup_memory_metrics_charts',
|
||||
() =>
|
||||
fetchAndTransformMetrics({
|
||||
const cgroupResponse = await fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -101,12 +98,11 @@ export async function getMemoryChartData({
|
|||
additionalFilters: [
|
||||
{ exists: { field: METRIC_CGROUP_MEMORY_USAGE_BYTES } },
|
||||
],
|
||||
})
|
||||
);
|
||||
operationName: 'get_cgroup_memory_metrics_charts',
|
||||
});
|
||||
|
||||
if (cgroupResponse.noHits) {
|
||||
return await withApmSpan('get_system_memory_metrics_charts', () =>
|
||||
fetchAndTransformMetrics({
|
||||
return await fetchAndTransformMetrics({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -121,8 +117,8 @@ export async function getMemoryChartData({
|
|||
{ exists: { field: METRIC_SYSTEM_FREE_MEMORY } },
|
||||
{ exists: { field: METRIC_SYSTEM_TOTAL_MEMORY } },
|
||||
],
|
||||
})
|
||||
);
|
||||
operationName: 'get_system_memory_metrics_charts',
|
||||
});
|
||||
}
|
||||
|
||||
return cgroupResponse;
|
||||
|
|
|
@ -56,6 +56,7 @@ export async function fetchAndTransformMetrics<T extends MetricAggs>({
|
|||
chartBase,
|
||||
aggs,
|
||||
additionalFilters = [],
|
||||
operationName,
|
||||
}: {
|
||||
environment?: string;
|
||||
kuery?: string;
|
||||
|
@ -65,6 +66,7 @@ export async function fetchAndTransformMetrics<T extends MetricAggs>({
|
|||
chartBase: ChartBase;
|
||||
aggs: T;
|
||||
additionalFilters?: Filter[];
|
||||
operationName: string;
|
||||
}) {
|
||||
const { start, end, apmEventClient, config } = setup;
|
||||
|
||||
|
@ -98,7 +100,7 @@ export async function fetchAndTransformMetrics<T extends MetricAggs>({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(operationName, params);
|
||||
|
||||
return transformDataToMetricsChart(response, chartBase);
|
||||
}
|
||||
|
|
|
@ -10,16 +10,14 @@ import { rangeQuery } from '../../../server/utils/queries';
|
|||
import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export function getServiceCount({
|
||||
export async function getServiceCount({
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
}: {
|
||||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('observability_overview_get_service_count', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -43,7 +41,9 @@ export function getServiceCount({
|
|||
},
|
||||
};
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'observability_overview_get_service_count',
|
||||
params
|
||||
);
|
||||
return aggregations?.serviceCount.value || 0;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@ import { rangeQuery } from '../../../server/utils/queries';
|
|||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { calculateThroughput } from '../helpers/calculate_throughput';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export function getTransactionsPerMinute({
|
||||
export async function getTransactionsPerMinute({
|
||||
setup,
|
||||
bucketSize,
|
||||
searchAggregatedTransactions,
|
||||
|
@ -25,12 +24,11 @@ export function getTransactionsPerMinute({
|
|||
bucketSize: string;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan(
|
||||
'observability_overview_get_transactions_per_minute',
|
||||
async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const { aggregations } = await apmEventClient.search({
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'observability_overview_get_transactions_per_minute',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -65,7 +63,8 @@ export function getTransactionsPerMinute({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (!aggregations || !aggregations.transactionType.buckets) {
|
||||
return { value: undefined, timeseries: [] };
|
||||
|
@ -90,6 +89,4 @@ export function getTransactionsPerMinute({
|
|||
y: bucket.throughput.value,
|
||||
})) || [],
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,9 @@
|
|||
*/
|
||||
|
||||
import { ProcessorEvent } from '../../../common/processor_event';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { Setup } from '../helpers/setup_request';
|
||||
|
||||
export function getHasData({ setup }: { setup: Setup }) {
|
||||
return withApmSpan('observability_overview_has_apm_data', async () => {
|
||||
export async function getHasData({ setup }: { setup: Setup }) {
|
||||
const { apmEventClient } = setup;
|
||||
try {
|
||||
const params = {
|
||||
|
@ -27,10 +25,12 @@ export function getHasData({ setup }: { setup: Setup }) {
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'observability_overview_has_apm_data',
|
||||
params
|
||||
);
|
||||
return response.hits.total.value > 0;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ export async function getClientMetrics({
|
|||
});
|
||||
|
||||
const { apmEventClient } = setup;
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_client_metrics', params);
|
||||
const {
|
||||
hasFetchStartField: { backEnd, totalPageLoadDuration },
|
||||
} = response.aggregations!;
|
||||
|
|
|
@ -94,7 +94,7 @@ export async function getJSErrors({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_js_errors', params);
|
||||
|
||||
const { totalErrorGroups, totalErrorPages, errors } =
|
||||
response.aggregations ?? {};
|
||||
|
|
|
@ -64,7 +64,7 @@ export async function getLongTaskMetrics({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_long_task_metrics', params);
|
||||
|
||||
const pkey = percentile.toFixed(1);
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ export async function getPageLoadDistribution({
|
|||
const {
|
||||
aggregations,
|
||||
hits: { total },
|
||||
} = await apmEventClient.search(params);
|
||||
} = await apmEventClient.search('get_page_load_distribution', params);
|
||||
|
||||
if (total.value === 0) {
|
||||
return null;
|
||||
|
@ -210,7 +210,10 @@ const getPercentilesDistribution = async ({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'get_page_load_distribution',
|
||||
params
|
||||
);
|
||||
|
||||
return aggregations?.loadDistribution.values ?? [];
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ export async function getPageViewTrends({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_page_view_trends', params);
|
||||
|
||||
const { topBreakdowns } = response.aggregations ?? {};
|
||||
|
||||
|
|
|
@ -92,7 +92,10 @@ export const getPageLoadDistBreakdown = async ({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'get_page_load_dist_breakdown',
|
||||
params
|
||||
);
|
||||
|
||||
const pageDistBreakdowns = aggregations?.breakdowns.buckets;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ export async function getRumServices({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_rum_services', params);
|
||||
|
||||
const result = response.aggregations?.services.buckets ?? [];
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ export async function getUrlSearch({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_url_search', params);
|
||||
const { urls, totalUrls } = response.aggregations ?? {};
|
||||
|
||||
const pkey = percentile.toFixed(1);
|
||||
|
|
|
@ -51,7 +51,7 @@ export async function getVisitorBreakdown({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_visitor_breakdown', params);
|
||||
const { browsers, os } = response.aggregations!;
|
||||
|
||||
const totalItems = response.hits.total.value;
|
||||
|
|
|
@ -103,7 +103,7 @@ export async function getWebCoreVitals({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_web_core_vitals', params);
|
||||
const {
|
||||
lcp,
|
||||
cls,
|
||||
|
|
|
@ -51,7 +51,7 @@ export async function hasRumData({
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('has_rum_data', params);
|
||||
return {
|
||||
indices: setup.indices['apm_oss.transactionIndices']!,
|
||||
hasData: response.hits.total.value > 0,
|
||||
|
|
|
@ -14,13 +14,11 @@ import {
|
|||
ServiceConnectionNode,
|
||||
} from '../../../common/service_map';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export async function fetchServicePathsFromTraceIds(
|
||||
setup: Setup & SetupTimeRange,
|
||||
traceIds: string[]
|
||||
) {
|
||||
return withApmSpan('get_service_paths_from_trace_ids', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
// make sure there's a range so ES can skip shards
|
||||
|
@ -210,12 +208,13 @@ export async function fetchServicePathsFromTraceIds(
|
|||
return response;`,
|
||||
},
|
||||
},
|
||||
},
|
||||
} as const,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const serviceMapFromTraceIdsScriptResponse = await apmEventClient.search(
|
||||
'get_service_paths_from_trace_ids',
|
||||
serviceMapParams
|
||||
);
|
||||
|
||||
|
@ -232,5 +231,4 @@ export async function fetchServicePathsFromTraceIds(
|
|||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ async function getConnectionData({
|
|||
}
|
||||
|
||||
async function getServicesData(options: IEnvOptions) {
|
||||
return withApmSpan('get_service_stats_for_service_map', async () => {
|
||||
const { environment, setup, searchAggregatedTransactions } = options;
|
||||
|
||||
const projection = getServicesProjection({
|
||||
|
@ -137,7 +136,10 @@ async function getServicesData(options: IEnvOptions) {
|
|||
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_stats_for_service_map',
|
||||
params
|
||||
);
|
||||
|
||||
return (
|
||||
response.aggregations?.services.buckets.map((bucket) => {
|
||||
|
@ -149,7 +151,6 @@ async function getServicesData(options: IEnvOptions) {
|
|||
};
|
||||
}) || []
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export type ConnectionsResponse = PromiseReturnType<typeof getConnectionData>;
|
||||
|
|
|
@ -120,7 +120,7 @@ async function getErrorStats({
|
|||
});
|
||||
}
|
||||
|
||||
function getTransactionStats({
|
||||
async function getTransactionStats({
|
||||
setup,
|
||||
filter,
|
||||
minutes,
|
||||
|
@ -129,7 +129,6 @@ function getTransactionStats({
|
|||
avgTransactionDuration: number | null;
|
||||
avgRequestsPerMinute: number | null;
|
||||
}> {
|
||||
return withApmSpan('get_transaction_stats_for_service_map_node', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -172,7 +171,10 @@ function getTransactionStats({
|
|||
},
|
||||
},
|
||||
};
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_transaction_stats_for_service_map_node',
|
||||
params
|
||||
);
|
||||
|
||||
const totalRequests = response.hits.total.value;
|
||||
|
||||
|
@ -180,17 +182,17 @@ function getTransactionStats({
|
|||
avgTransactionDuration: response.aggregations?.duration.value ?? null,
|
||||
avgRequestsPerMinute: totalRequests > 0 ? totalRequests / minutes : null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function getCpuStats({
|
||||
async function getCpuStats({
|
||||
setup,
|
||||
filter,
|
||||
}: TaskParameters): Promise<{ avgCpuUsage: number | null }> {
|
||||
return withApmSpan('get_avg_cpu_usage_for_service_map_node', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_avg_cpu_usage_for_service_map_node',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -206,10 +208,10 @@ function getCpuStats({
|
|||
},
|
||||
aggs: { avgCpuUsage: { avg: { field: METRIC_SYSTEM_CPU_PERCENT } } },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return { avgCpuUsage: response.aggregations?.avgCpuUsage.value ?? null };
|
||||
});
|
||||
}
|
||||
|
||||
function getMemoryStats({
|
||||
|
@ -219,7 +221,7 @@ function getMemoryStats({
|
|||
return withApmSpan('get_memory_stats_for_service_map_node', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const getAvgMemoryUsage = ({
|
||||
const getAvgMemoryUsage = async ({
|
||||
additionalFilters,
|
||||
script,
|
||||
}: {
|
||||
|
@ -228,8 +230,9 @@ function getMemoryStats({
|
|||
| typeof percentCgroupMemoryUsedScript
|
||||
| typeof percentSystemMemoryUsedScript;
|
||||
}) => {
|
||||
return withApmSpan('get_avg_memory_for_service_map_node', async () => {
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_avg_memory_for_service_map_node',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -244,9 +247,9 @@ function getMemoryStats({
|
|||
avgMemoryUsage: { avg: { script } },
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
return response.aggregations?.avgMemoryUsage.value ?? null;
|
||||
});
|
||||
};
|
||||
|
||||
let avgMemoryUsage = await getAvgMemoryUsage({
|
||||
|
|
|
@ -18,12 +18,11 @@ import {
|
|||
import { ProcessorEvent } from '../../../common/processor_event';
|
||||
import { SERVICE_MAP_TIMEOUT_ERROR } from '../../../common/service_map';
|
||||
import { environmentQuery, rangeQuery } from '../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
|
||||
const MAX_TRACES_TO_INSPECT = 1000;
|
||||
|
||||
export function getTraceSampleIds({
|
||||
export async function getTraceSampleIds({
|
||||
serviceName,
|
||||
environment,
|
||||
setup,
|
||||
|
@ -32,7 +31,6 @@ export function getTraceSampleIds({
|
|||
environment?: string;
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_trace_sample_ids', async () => {
|
||||
const { start, end, apmEventClient, config } = setup;
|
||||
|
||||
const query = {
|
||||
|
@ -127,12 +125,14 @@ export function getTraceSampleIds({
|
|||
};
|
||||
|
||||
try {
|
||||
const tracesSampleResponse = await apmEventClient.search(params);
|
||||
const tracesSampleResponse = await apmEventClient.search(
|
||||
'get_trace_sample_ids',
|
||||
params
|
||||
);
|
||||
// make sure at least one trace per composite/connection bucket
|
||||
// is queried
|
||||
const traceIdsWithPriority =
|
||||
tracesSampleResponse.aggregations?.connections.buckets.flatMap(
|
||||
(bucket) =>
|
||||
tracesSampleResponse.aggregations?.connections.buckets.flatMap((bucket) =>
|
||||
bucket.sample.trace_ids.buckets.map((sampleDocBucket, index) => ({
|
||||
traceId: sampleDocBucket.key as string,
|
||||
priority: index,
|
||||
|
@ -153,5 +153,4 @@ export function getTraceSampleIds({
|
|||
}
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,10 +14,9 @@ import {
|
|||
import { SERVICE_NODE_NAME_MISSING } from '../../../common/service_nodes';
|
||||
import { getServiceNodesProjection } from '../../projections/service_nodes';
|
||||
import { mergeProjection } from '../../projections/util/merge_projection';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
|
||||
const getServiceNodes = ({
|
||||
const getServiceNodes = async ({
|
||||
kuery,
|
||||
setup,
|
||||
serviceName,
|
||||
|
@ -26,7 +25,6 @@ const getServiceNodes = ({
|
|||
setup: Setup & SetupTimeRange;
|
||||
serviceName: string;
|
||||
}) => {
|
||||
return withApmSpan('get_service_nodes', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const projection = getServiceNodesProjection({ kuery, setup, serviceName });
|
||||
|
@ -67,7 +65,7 @@ const getServiceNodes = ({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search('get_service_nodes', params);
|
||||
|
||||
if (!response.aggregations) {
|
||||
return [];
|
||||
|
@ -88,7 +86,6 @@ const getServiceNodes = ({
|
|||
item.nonHeapMemory !== null ||
|
||||
item.threadCount != null
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
export { getServiceNodes };
|
||||
|
|
|
@ -22,6 +22,7 @@ Object {
|
|||
"events": Array [
|
||||
"transaction",
|
||||
],
|
||||
"includeLegacyData": true,
|
||||
},
|
||||
"body": Object {
|
||||
"query": Object {
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
SERVICE_VERSION,
|
||||
} from '../../../../common/elasticsearch_fieldnames';
|
||||
import { environmentQuery, rangeQuery } from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import {
|
||||
getDocumentTypeFilterForAggregatedTransactions,
|
||||
getProcessorEventForAggregatedTransactions,
|
||||
|
@ -31,7 +30,6 @@ export async function getDerivedServiceAnnotations({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_derived_service_annotations', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const filter: ESFilter[] = [
|
||||
|
@ -44,7 +42,7 @@ export async function getDerivedServiceAnnotations({
|
|||
|
||||
const versions =
|
||||
(
|
||||
await apmEventClient.search({
|
||||
await apmEventClient.search('get_derived_service_annotations', {
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -75,8 +73,9 @@ export async function getDerivedServiceAnnotations({
|
|||
}
|
||||
const annotations = await Promise.all(
|
||||
versions.map(async (version) => {
|
||||
return withApmSpan('get_first_seen_of_version', async () => {
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_first_seen_of_version',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -95,7 +94,8 @@ export async function getDerivedServiceAnnotations({
|
|||
'@timestamp': 'asc',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const firstSeen = new Date(
|
||||
response.hits.hits[0]._source['@timestamp']
|
||||
|
@ -117,9 +117,7 @@ export async function getDerivedServiceAnnotations({
|
|||
'@timestamp': firstSeen,
|
||||
text: version,
|
||||
};
|
||||
});
|
||||
})
|
||||
);
|
||||
return annotations.filter(Boolean) as Annotation[];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ import {
|
|||
import { rangeQuery } from '../../../server/utils/queries';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export function getServiceAgentName({
|
||||
export async function getServiceAgentName({
|
||||
serviceName,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
|
@ -24,7 +23,6 @@ export function getServiceAgentName({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_service_agent_name', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -56,10 +54,10 @@ export function getServiceAgentName({
|
|||
},
|
||||
};
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const agentName = aggregations?.agents.buckets[0]?.key as
|
||||
| string
|
||||
| undefined;
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'get_service_agent_name',
|
||||
params
|
||||
);
|
||||
const agentName = aggregations?.agents.buckets[0]?.key as string | undefined;
|
||||
return { agentName };
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ export const getDestinationMap = ({
|
|||
return withApmSpan('get_service_destination_map', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const response = await withApmSpan('get_exit_span_samples', async () =>
|
||||
apmEventClient.search({
|
||||
const response = await apmEventClient.search('get_exit_span_samples', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.span],
|
||||
},
|
||||
|
@ -78,17 +77,18 @@ export const getDestinationMap = ({
|
|||
{ field: SPAN_SUBTYPE },
|
||||
{ field: SPAN_ID },
|
||||
],
|
||||
sort: {
|
||||
sort: [
|
||||
{
|
||||
'@timestamp': 'desc' as const,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const outgoingConnections =
|
||||
response.aggregations?.connections.buckets.map((bucket) => {
|
||||
|
@ -104,10 +104,9 @@ export const getDestinationMap = ({
|
|||
};
|
||||
}) ?? [];
|
||||
|
||||
const transactionResponse = await withApmSpan(
|
||||
const transactionResponse = await apmEventClient.search(
|
||||
'get_transactions_for_exit_spans',
|
||||
() =>
|
||||
apmEventClient.search({
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.transaction],
|
||||
},
|
||||
|
@ -135,7 +134,7 @@ export const getDestinationMap = ({
|
|||
] as const),
|
||||
_source: false,
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
const incomingConnections = transactionResponse.hits.hits.map((hit) => ({
|
||||
|
|
|
@ -18,9 +18,8 @@ import { environmentQuery, rangeQuery } from '../../../../server/utils/queries';
|
|||
import { getBucketSize } from '../../helpers/get_bucket_size';
|
||||
import { EventOutcome } from '../../../../common/event_outcome';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export const getMetrics = ({
|
||||
export const getMetrics = async ({
|
||||
setup,
|
||||
serviceName,
|
||||
environment,
|
||||
|
@ -31,10 +30,11 @@ export const getMetrics = ({
|
|||
environment?: string;
|
||||
numBuckets: number;
|
||||
}) => {
|
||||
return withApmSpan('get_service_destination_metrics', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_destination_metrics',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -46,7 +46,9 @@ export const getMetrics = ({
|
|||
filter: [
|
||||
{ term: { [SERVICE_NAME]: serviceName } },
|
||||
{
|
||||
exists: { field: SPAN_DESTINATION_SERVICE_RESPONSE_TIME_COUNT },
|
||||
exists: {
|
||||
field: SPAN_DESTINATION_SERVICE_RESPONSE_TIME_COUNT,
|
||||
},
|
||||
},
|
||||
...rangeQuery(start, end),
|
||||
...environmentQuery(environment),
|
||||
|
@ -99,7 +101,8 @@ export const getMetrics = ({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
response.aggregations?.connections.buckets.map((bucket) => ({
|
||||
|
@ -141,5 +144,4 @@ export const getMetrics = ({
|
|||
})),
|
||||
})) ?? []
|
||||
);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -18,7 +18,6 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { getBucketSize } from '../../helpers/get_bucket_size';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
|
@ -43,14 +42,13 @@ export async function getServiceErrorGroupDetailedStatistics({
|
|||
start: number;
|
||||
end: number;
|
||||
}): Promise<Array<{ groupId: string; timeseries: Coordinate[] }>> {
|
||||
return withApmSpan(
|
||||
'get_service_error_group_detailed_statistics',
|
||||
async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const { intervalString } = getBucketSize({ start, end, numBuckets });
|
||||
|
||||
const timeseriesResponse = await apmEventClient.search({
|
||||
const timeseriesResponse = await apmEventClient.search(
|
||||
'get_service_error_group_detailed_statistics',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -90,14 +88,14 @@ export async function getServiceErrorGroupDetailedStatistics({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (!timeseriesResponse.aggregations) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return timeseriesResponse.aggregations.error_groups.buckets.map(
|
||||
(bucket) => {
|
||||
return timeseriesResponse.aggregations.error_groups.buckets.map((bucket) => {
|
||||
const groupId = bucket.key as string;
|
||||
return {
|
||||
groupId,
|
||||
|
@ -108,10 +106,7 @@ export async function getServiceErrorGroupDetailedStatistics({
|
|||
};
|
||||
}),
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export async function getServiceErrorGroupPeriods({
|
||||
|
|
|
@ -19,11 +19,10 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { getErrorName } from '../../helpers/get_error_name';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
|
||||
export function getServiceErrorGroupMainStatistics({
|
||||
export async function getServiceErrorGroupMainStatistics({
|
||||
kuery,
|
||||
serviceName,
|
||||
setup,
|
||||
|
@ -36,10 +35,11 @@ export function getServiceErrorGroupMainStatistics({
|
|||
transactionType: string;
|
||||
environment?: string;
|
||||
}) {
|
||||
return withApmSpan('get_service_error_group_main_statistics', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_error_group_main_statistics',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -79,14 +79,14 @@ export function getServiceErrorGroupMainStatistics({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const errorGroups =
|
||||
response.aggregations?.error_groups.buckets.map((bucket) => ({
|
||||
group_id: bucket.key as string,
|
||||
name:
|
||||
getErrorName(bucket.sample.hits.hits[0]._source) ??
|
||||
NOT_AVAILABLE_LABEL,
|
||||
getErrorName(bucket.sample.hits.hits[0]._source) ?? NOT_AVAILABLE_LABEL,
|
||||
last_seen: new Date(
|
||||
bucket.sample.hits.hits[0]?._source['@timestamp']
|
||||
).getTime(),
|
||||
|
@ -98,5 +98,4 @@ export function getServiceErrorGroupMainStatistics({
|
|||
(response.aggregations?.error_groups.sum_other_doc_count ?? 0) === 0,
|
||||
error_groups: errorGroups,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -59,8 +59,9 @@ export async function getServiceErrorGroups({
|
|||
|
||||
const { intervalString } = getBucketSize({ start, end, numBuckets });
|
||||
|
||||
const response = await withApmSpan('get_top_service_error_groups', () =>
|
||||
apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_top_service_error_groups',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -104,7 +105,7 @@ export async function getServiceErrorGroups({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
const errorGroups =
|
||||
|
@ -139,10 +140,9 @@ export async function getServiceErrorGroups({
|
|||
(group) => group.group_id
|
||||
);
|
||||
|
||||
const timeseriesResponse = await withApmSpan(
|
||||
const timeseriesResponse = await apmEventClient.search(
|
||||
'get_service_error_groups_timeseries',
|
||||
async () =>
|
||||
apmEventClient.search({
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -182,7 +182,7 @@ export async function getServiceErrorGroups({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
TRANSACTION_TYPE,
|
||||
} from '../../../common/elasticsearch_fieldnames';
|
||||
import { environmentQuery, kqlQuery, rangeQuery } from '../../utils/queries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
|
||||
|
@ -37,7 +36,6 @@ export async function getServiceInstanceMetadataDetails({
|
|||
environment?: string;
|
||||
kuery?: string;
|
||||
}) {
|
||||
return withApmSpan('get_service_instance_metadata_details', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
const filter = [
|
||||
{ term: { [SERVICE_NAME]: serviceName } },
|
||||
|
@ -48,7 +46,9 @@ export async function getServiceInstanceMetadataDetails({
|
|||
...kqlQuery(kuery),
|
||||
];
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_instance_metadata_details',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -61,7 +61,8 @@ export async function getServiceInstanceMetadataDetails({
|
|||
size: 1,
|
||||
query: { bool: { filter } },
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const sample = response.hits.hits[0]?._source;
|
||||
|
||||
|
@ -80,5 +81,4 @@ export async function getServiceInstanceMetadataDetails({
|
|||
host,
|
||||
cloud,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
percentCgroupMemoryUsedScript,
|
||||
percentSystemMemoryUsedScript,
|
||||
} from '../../metrics/by_agent/shared/memory';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
interface ServiceInstanceSystemMetricPrimaryStatistics {
|
||||
serviceNodeName: string;
|
||||
|
@ -67,9 +66,6 @@ export async function getServiceInstancesSystemMetricStatistics<
|
|||
size?: number;
|
||||
isComparisonSearch: T;
|
||||
}): Promise<Array<ServiceInstanceSystemMetricStatistics<T>>> {
|
||||
return withApmSpan(
|
||||
'get_service_instances_system_metric_statistics',
|
||||
async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const { intervalString } = getBucketSize({ start, end, numBuckets });
|
||||
|
@ -128,7 +124,9 @@ export async function getServiceInstancesSystemMetricStatistics<
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_instances_system_metric_statistics',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -161,7 +159,8 @@ export async function getServiceInstancesSystemMetricStatistics<
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
(response.aggregations?.[SERVICE_NODE_NAME].buckets.map(
|
||||
|
@ -203,6 +202,4 @@ export async function getServiceInstancesSystemMetricStatistics<
|
|||
}
|
||||
) as Array<ServiceInstanceSystemMetricStatistics<T>>) || []
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import {
|
|||
getLatencyValue,
|
||||
} from '../../helpers/latency_aggregation_type';
|
||||
import { Setup } from '../../helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
interface ServiceInstanceTransactionPrimaryStatistics {
|
||||
serviceNodeName: string;
|
||||
|
@ -77,9 +76,6 @@ export async function getServiceInstancesTransactionStatistics<
|
|||
size?: number;
|
||||
numBuckets?: number;
|
||||
}): Promise<Array<ServiceInstanceTransactionStatistics<T>>> {
|
||||
return withApmSpan(
|
||||
'get_service_instances_transaction_statistics',
|
||||
async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const { intervalString, bucketSize } = getBucketSize({
|
||||
|
@ -142,7 +138,9 @@ export async function getServiceInstancesTransactionStatistics<
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_instances_transaction_statistics',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -151,7 +149,8 @@ export async function getServiceInstancesTransactionStatistics<
|
|||
],
|
||||
},
|
||||
body: { size: 0, query, aggs },
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const bucketSizeInMinutes = bucketSize / 60;
|
||||
|
||||
|
@ -197,6 +196,4 @@ export async function getServiceInstancesTransactionStatistics<
|
|||
}
|
||||
) as Array<ServiceInstanceTransactionStatistics<T>>) || []
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw'
|
|||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { should } from './get_service_metadata_icons';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
type ServiceMetadataDetailsRaw = Pick<
|
||||
TransactionRaw,
|
||||
|
@ -59,7 +58,7 @@ export interface ServiceMetadataDetails {
|
|||
};
|
||||
}
|
||||
|
||||
export function getServiceMetadataDetails({
|
||||
export async function getServiceMetadataDetails({
|
||||
serviceName,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
|
@ -68,7 +67,6 @@ export function getServiceMetadataDetails({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}): Promise<ServiceMetadataDetails> {
|
||||
return withApmSpan('get_service_metadata_details', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const filter = [
|
||||
|
@ -115,7 +113,10 @@ export function getServiceMetadataDetails({
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_metadata_details',
|
||||
params
|
||||
);
|
||||
|
||||
if (response.hits.total.value === 0) {
|
||||
return {
|
||||
|
@ -168,5 +169,4 @@ export function getServiceMetadataDetails({
|
|||
container: containerDetails,
|
||||
cloud: cloudDetails,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import { rangeQuery } from '../../../server/utils/queries';
|
|||
import { TransactionRaw } from '../../../typings/es_schemas/raw/transaction_raw';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
type ServiceMetadataIconsRaw = Pick<
|
||||
TransactionRaw,
|
||||
|
@ -41,7 +40,7 @@ export const should = [
|
|||
{ exists: { field: AGENT_NAME } },
|
||||
];
|
||||
|
||||
export function getServiceMetadataIcons({
|
||||
export async function getServiceMetadataIcons({
|
||||
serviceName,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
|
@ -50,7 +49,6 @@ export function getServiceMetadataIcons({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}): Promise<ServiceMetadataIcons> {
|
||||
return withApmSpan('get_service_metadata_icons', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const filter = [
|
||||
|
@ -75,7 +73,10 @@ export function getServiceMetadataIcons({
|
|||
},
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search(params);
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_metadata_icons',
|
||||
params
|
||||
);
|
||||
|
||||
if (response.hits.total.value === 0) {
|
||||
return {
|
||||
|
@ -100,5 +101,4 @@ export function getServiceMetadataIcons({
|
|||
containerType,
|
||||
cloudProvider: cloud?.provider,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,9 +13,8 @@ import {
|
|||
import { NOT_AVAILABLE_LABEL } from '../../../common/i18n';
|
||||
import { mergeProjection } from '../../projections/util/merge_projection';
|
||||
import { getServiceNodesProjection } from '../../projections/service_nodes';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export function getServiceNodeMetadata({
|
||||
export async function getServiceNodeMetadata({
|
||||
kuery,
|
||||
serviceName,
|
||||
serviceNodeName,
|
||||
|
@ -26,7 +25,6 @@ export function getServiceNodeMetadata({
|
|||
serviceNodeName: string;
|
||||
setup: Setup & SetupTimeRange;
|
||||
}) {
|
||||
return withApmSpan('get_service_node_metadata', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const query = mergeProjection(
|
||||
|
@ -57,13 +55,14 @@ export function getServiceNodeMetadata({
|
|||
}
|
||||
);
|
||||
|
||||
const response = await apmEventClient.search(query);
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_node_metadata',
|
||||
query
|
||||
);
|
||||
|
||||
return {
|
||||
host: response.aggregations?.host.buckets[0]?.key || NOT_AVAILABLE_LABEL,
|
||||
containerId:
|
||||
response.aggregations?.containerId.buckets[0]?.key ||
|
||||
NOT_AVAILABLE_LABEL,
|
||||
response.aggregations?.containerId.buckets[0]?.key || NOT_AVAILABLE_LABEL,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import {
|
|||
kqlQuery,
|
||||
} from '../../../server/utils/queries';
|
||||
import { Coordinate } from '../../../typings/timeseries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import {
|
||||
getDocumentTypeFilterForAggregatedTransactions,
|
||||
getProcessorEventForAggregatedTransactions,
|
||||
|
@ -68,9 +67,6 @@ export async function getServiceTransactionGroupDetailedStatistics({
|
|||
impact: number;
|
||||
}>
|
||||
> {
|
||||
return withApmSpan(
|
||||
'get_service_transaction_group_detailed_statistics',
|
||||
async () => {
|
||||
const { apmEventClient } = setup;
|
||||
const { intervalString } = getBucketSize({ start, end, numBuckets });
|
||||
|
||||
|
@ -78,7 +74,9 @@ export async function getServiceTransactionGroupDetailedStatistics({
|
|||
searchAggregatedTransactions
|
||||
);
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_transaction_group_detailed_statistics',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -143,7 +141,8 @@ export async function getServiceTransactionGroupDetailedStatistics({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const buckets = response.aggregations?.transaction_groups.buckets ?? [];
|
||||
|
||||
|
@ -157,17 +156,13 @@ export async function getServiceTransactionGroupDetailedStatistics({
|
|||
aggregation: timeseriesBucket.latency,
|
||||
}),
|
||||
}));
|
||||
const throughput = bucket.timeseries.buckets.map(
|
||||
(timeseriesBucket) => ({
|
||||
const throughput = bucket.timeseries.buckets.map((timeseriesBucket) => ({
|
||||
x: timeseriesBucket.key,
|
||||
y: timeseriesBucket.throughput_rate.value,
|
||||
})
|
||||
);
|
||||
}));
|
||||
const errorRate = bucket.timeseries.buckets.map((timeseriesBucket) => ({
|
||||
x: timeseriesBucket.key,
|
||||
y: calculateTransactionErrorPercentage(
|
||||
timeseriesBucket[EVENT_OUTCOME]
|
||||
),
|
||||
y: calculateTransactionErrorPercentage(timeseriesBucket[EVENT_OUTCOME]),
|
||||
}));
|
||||
const transactionGroupTotalDuration =
|
||||
bucket.transaction_group_total_duration.value || 0;
|
||||
|
@ -181,8 +176,6 @@ export async function getServiceTransactionGroupDetailedStatistics({
|
|||
: 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export async function getServiceTransactionGroupDetailedStatisticsPeriods({
|
||||
|
|
|
@ -18,7 +18,6 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
import {
|
||||
getDocumentTypeFilterForAggregatedTransactions,
|
||||
getProcessorEventForAggregatedTransactions,
|
||||
|
@ -56,14 +55,15 @@ export async function getServiceTransactionGroups({
|
|||
transactionType: string;
|
||||
latencyAggregationType: LatencyAggregationType;
|
||||
}) {
|
||||
return withApmSpan('get_service_transaction_groups', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const field = getTransactionDurationFieldForAggregatedTransactions(
|
||||
searchAggregatedTransactions
|
||||
);
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_transaction_groups',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -110,7 +110,8 @@ export async function getServiceTransactionGroups({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const totalDuration = response.aggregations?.total_duration.value;
|
||||
|
||||
|
@ -150,5 +151,4 @@ export async function getServiceTransactionGroups({
|
|||
(response.aggregations?.transaction_groups.sum_other_doc_count ?? 0) ===
|
||||
0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,9 +15,8 @@ import {
|
|||
getDocumentTypeFilterForAggregatedTransactions,
|
||||
getProcessorEventForAggregatedTransactions,
|
||||
} from '../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export function getServiceTransactionTypes({
|
||||
export async function getServiceTransactionTypes({
|
||||
setup,
|
||||
serviceName,
|
||||
searchAggregatedTransactions,
|
||||
|
@ -26,7 +25,6 @@ export function getServiceTransactionTypes({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_service_transaction_types', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -58,9 +56,11 @@ export function getServiceTransactionTypes({
|
|||
},
|
||||
};
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'get_service_transaction_types',
|
||||
params
|
||||
);
|
||||
const transactionTypes =
|
||||
aggregations?.types.buckets.map((bucket) => bucket.key as string) || [];
|
||||
return { transactionTypes };
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,17 +9,16 @@ import { rangeQuery } from '../../../../server/utils/queries';
|
|||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { OBSERVER_VERSION_MAJOR } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
// returns true if 6.x data is found
|
||||
export async function getLegacyDataStatus(setup: Setup & SetupTimeRange) {
|
||||
return withApmSpan('get_legacy_data_status', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const params = {
|
||||
terminateAfter: 1,
|
||||
apm: {
|
||||
events: [ProcessorEvent.transaction],
|
||||
includeLegacyData: true,
|
||||
},
|
||||
body: {
|
||||
size: 0,
|
||||
|
@ -34,10 +33,7 @@ export async function getLegacyDataStatus(setup: Setup & SetupTimeRange) {
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params, {
|
||||
includeLegacyData: true,
|
||||
});
|
||||
const resp = await apmEventClient.search('get_legacy_data_status', params);
|
||||
const hasLegacyData = resp.hits.total.value > 0;
|
||||
return hasLegacyData;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import {
|
|||
getOutcomeAggregation,
|
||||
} from '../../helpers/transaction_error_rate';
|
||||
import { ServicesItemsSetup } from './get_services_items';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
interface AggregationParams {
|
||||
environment?: string;
|
||||
|
@ -50,7 +49,6 @@ export async function getServiceTransactionStats({
|
|||
searchAggregatedTransactions,
|
||||
maxNumServices,
|
||||
}: AggregationParams) {
|
||||
return withApmSpan('get_service_transaction_stats', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const outcomes = getOutcomeAggregation();
|
||||
|
@ -66,7 +64,9 @@ export async function getServiceTransactionStats({
|
|||
outcomes,
|
||||
};
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_transaction_stats',
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -133,7 +133,8 @@ export async function getServiceTransactionStats({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
response.aggregations?.services.buckets.map((bucket) => {
|
||||
|
@ -192,5 +193,4 @@ export async function getServiceTransactionStats({
|
|||
};
|
||||
}) ?? []
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,9 +14,8 @@ import {
|
|||
import { environmentQuery, kqlQuery, rangeQuery } from '../../../utils/queries';
|
||||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function getServicesFromMetricDocuments({
|
||||
export async function getServicesFromMetricDocuments({
|
||||
environment,
|
||||
setup,
|
||||
maxNumServices,
|
||||
|
@ -27,10 +26,11 @@ export function getServicesFromMetricDocuments({
|
|||
maxNumServices: number;
|
||||
kuery?: string;
|
||||
}) {
|
||||
return withApmSpan('get_services_from_metric_documents', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_services_from_metric_documents',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.metric],
|
||||
},
|
||||
|
@ -67,7 +67,8 @@ export function getServicesFromMetricDocuments({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
response.aggregations?.services.buckets.map((bucket) => {
|
||||
|
@ -80,5 +81,4 @@ export function getServicesFromMetricDocuments({
|
|||
};
|
||||
}) ?? []
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
*/
|
||||
|
||||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup } from '../../helpers/setup_request';
|
||||
|
||||
// Note: this logic is duplicated in tutorials/apm/envs/on_prem
|
||||
export async function hasHistoricalAgentData(setup: Setup) {
|
||||
return withApmSpan('has_historical_agent_data', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -28,7 +26,6 @@ export async function hasHistoricalAgentData(setup: Setup) {
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search('has_historical_agent_data', params);
|
||||
return resp.hits.total.value > 0;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import {
|
|||
} from '../helpers/aggregated_transactions';
|
||||
import { getBucketSize } from '../helpers/get_bucket_size';
|
||||
import { Setup } from '../helpers/setup_request';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
interface Options {
|
||||
environment?: string;
|
||||
|
@ -88,11 +87,10 @@ function fetcher({
|
|||
},
|
||||
};
|
||||
|
||||
return apmEventClient.search(params);
|
||||
return apmEventClient.search('get_throughput_for_service', params);
|
||||
}
|
||||
|
||||
export function getThroughput(options: Options) {
|
||||
return withApmSpan('get_throughput_for_service', async () => {
|
||||
export async function getThroughput(options: Options) {
|
||||
const response = await fetcher(options);
|
||||
|
||||
return (
|
||||
|
@ -103,5 +101,4 @@ export function getThroughput(options: Options) {
|
|||
};
|
||||
}) ?? []
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ const maybeAdd = (to: any[], value: any) => {
|
|||
to.push(value);
|
||||
};
|
||||
|
||||
function getProfilingStats({
|
||||
async function getProfilingStats({
|
||||
apmEventClient,
|
||||
filter,
|
||||
valueTypeField,
|
||||
|
@ -50,8 +50,7 @@ function getProfilingStats({
|
|||
filter: ESFilter[];
|
||||
valueTypeField: string;
|
||||
}) {
|
||||
return withApmSpan('get_profiling_stats', async () => {
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search('get_profiling_stats', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.profile],
|
||||
},
|
||||
|
@ -92,7 +91,6 @@ function getProfilingStats({
|
|||
}) ?? [];
|
||||
|
||||
return stacks;
|
||||
});
|
||||
}
|
||||
|
||||
function getProfilesWithStacks({
|
||||
|
@ -103,8 +101,9 @@ function getProfilesWithStacks({
|
|||
filter: ESFilter[];
|
||||
}) {
|
||||
return withApmSpan('get_profiles_with_stacks', async () => {
|
||||
const cardinalityResponse = await withApmSpan('get_top_cardinality', () =>
|
||||
apmEventClient.search({
|
||||
const cardinalityResponse = await apmEventClient.search(
|
||||
'get_top_cardinality',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.profile],
|
||||
},
|
||||
|
@ -121,7 +120,7 @@ function getProfilesWithStacks({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
const cardinality = cardinalityResponse.aggregations?.top.value ?? 0;
|
||||
|
@ -140,8 +139,7 @@ function getProfilesWithStacks({
|
|||
const allResponses = await withApmSpan('get_all_stacks', async () => {
|
||||
return Promise.all(
|
||||
[...new Array(partitions)].map(async (_, num) => {
|
||||
const response = await withApmSpan('get_partition', () =>
|
||||
apmEventClient.search({
|
||||
const response = await apmEventClient.search('get_partition', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.profile],
|
||||
},
|
||||
|
@ -171,8 +169,7 @@ function getProfilesWithStacks({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
response.aggregations?.top.buckets.flatMap((bucket) => {
|
||||
|
|
|
@ -17,7 +17,6 @@ import {
|
|||
} from '../../../../common/profiling';
|
||||
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
|
||||
import { getBucketSize } from '../../helpers/get_bucket_size';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { kqlQuery } from '../../../utils/queries';
|
||||
|
||||
const configMap = mapValues(
|
||||
|
@ -38,10 +37,11 @@ export async function getServiceProfilingTimeline({
|
|||
setup: Setup & SetupTimeRange;
|
||||
environment?: string;
|
||||
}) {
|
||||
return withApmSpan('get_service_profiling_timeline', async () => {
|
||||
const { apmEventClient, start, end } = setup;
|
||||
|
||||
const response = await apmEventClient.search({
|
||||
const response = await apmEventClient.search(
|
||||
'get_service_profiling_timeline',
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.profile],
|
||||
},
|
||||
|
@ -96,7 +96,8 @@ export async function getServiceProfilingTimeline({
|
|||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const { aggregations } = response;
|
||||
|
||||
|
@ -120,5 +121,4 @@ export async function getServiceProfilingTimeline({
|
|||
},
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('services queries', () => {
|
|||
})
|
||||
);
|
||||
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[0]);
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[1]);
|
||||
|
||||
expect(allParams).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
AgentConfigurationIntake,
|
||||
} from '../../../../common/agent_configuration/configuration_types';
|
||||
import { APMIndexDocumentParams } from '../../helpers/create_es_client/create_internal_es_client';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function createOrUpdateConfiguration({
|
||||
configurationId,
|
||||
|
@ -23,7 +22,6 @@ export function createOrUpdateConfiguration({
|
|||
configurationIntake: AgentConfigurationIntake;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('create_or_update_configuration', async () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
const params: APMIndexDocumentParams<AgentConfiguration> = {
|
||||
|
@ -47,6 +45,5 @@ export function createOrUpdateConfiguration({
|
|||
params.id = configurationId;
|
||||
}
|
||||
|
||||
return internalClient.index(params);
|
||||
});
|
||||
return internalClient.index('create_or_update_agent_configuration', params);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup } from '../../helpers/setup_request';
|
||||
|
||||
export async function deleteConfiguration({
|
||||
|
@ -15,7 +14,6 @@ export async function deleteConfiguration({
|
|||
configurationId: string;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('delete_agent_configuration', async () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -24,6 +22,5 @@ export async function deleteConfiguration({
|
|||
id: configurationId,
|
||||
};
|
||||
|
||||
return internalClient.delete(params);
|
||||
});
|
||||
return internalClient.delete('delete_agent_configuration', params);
|
||||
}
|
||||
|
|
|
@ -11,18 +11,16 @@ import {
|
|||
SERVICE_ENVIRONMENT,
|
||||
SERVICE_NAME,
|
||||
} from '../../../../common/elasticsearch_fieldnames';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup } from '../../helpers/setup_request';
|
||||
import { convertConfigSettingsToString } from './convert_settings_to_string';
|
||||
|
||||
export function findExactConfiguration({
|
||||
export async function findExactConfiguration({
|
||||
service,
|
||||
setup,
|
||||
}: {
|
||||
service: AgentConfiguration['service'];
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('find_exact_agent_configuration', async () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
const serviceNameFilter = service.name
|
||||
|
@ -43,6 +41,7 @@ export function findExactConfiguration({
|
|||
};
|
||||
|
||||
const resp = await internalClient.search<AgentConfiguration, typeof params>(
|
||||
'find_exact_agent_configuration',
|
||||
params
|
||||
);
|
||||
|
||||
|
@ -53,5 +52,4 @@ export function findExactConfiguration({
|
|||
}
|
||||
|
||||
return convertConfigSettingsToString(hit);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import { ProcessorEvent } from '../../../../common/processor_event';
|
|||
import { Setup } from '../../helpers/setup_request';
|
||||
import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { AGENT_NAME } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export async function getAgentNameByService({
|
||||
serviceName,
|
||||
|
@ -18,7 +17,6 @@ export async function getAgentNameByService({
|
|||
serviceName: string;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('get_agent_name_by_service', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -45,8 +43,10 @@ export async function getAgentNameByService({
|
|||
},
|
||||
};
|
||||
|
||||
const { aggregations } = await apmEventClient.search(params);
|
||||
const { aggregations } = await apmEventClient.search(
|
||||
'get_agent_name_by_service',
|
||||
params
|
||||
);
|
||||
const agentName = aggregations?.agent_names.buckets[0]?.key;
|
||||
return agentName as string | undefined;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { withApmSpan } from '../../../../utils/with_apm_span';
|
||||
import { Setup } from '../../../helpers/setup_request';
|
||||
import {
|
||||
SERVICE_NAME,
|
||||
|
@ -20,7 +19,6 @@ export async function getExistingEnvironmentsForService({
|
|||
serviceName: string | undefined;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('get_existing_environments_for_service', async () => {
|
||||
const { internalClient, indices, config } = setup;
|
||||
const maxServiceEnvironments = config['xpack.apm.maxServiceEnvironments'];
|
||||
|
||||
|
@ -45,11 +43,13 @@ export async function getExistingEnvironmentsForService({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await internalClient.search(params);
|
||||
const resp = await internalClient.search(
|
||||
'get_existing_environments_for_service',
|
||||
params
|
||||
);
|
||||
const existingEnvironments =
|
||||
resp.aggregations?.environments.buckets.map(
|
||||
(bucket) => bucket.key as string
|
||||
) || [];
|
||||
return existingEnvironments;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,19 +11,17 @@ import { PromiseReturnType } from '../../../../../observability/typings/common';
|
|||
import { SERVICE_NAME } from '../../../../common/elasticsearch_fieldnames';
|
||||
import { ALL_OPTION_VALUE } from '../../../../common/agent_configuration/all_option';
|
||||
import { getProcessorEventForAggregatedTransactions } from '../../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export type AgentConfigurationServicesAPIResponse = PromiseReturnType<
|
||||
typeof getServiceNames
|
||||
>;
|
||||
export function getServiceNames({
|
||||
export async function getServiceNames({
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
}: {
|
||||
setup: Setup;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_service_names_for_agent_config', async () => {
|
||||
const { apmEventClient, config } = setup;
|
||||
const maxServiceSelection = config['xpack.apm.maxServiceSelection'];
|
||||
|
||||
|
@ -52,11 +50,13 @@ export function getServiceNames({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_service_names_for_agent_config',
|
||||
params
|
||||
);
|
||||
const serviceNames =
|
||||
resp.aggregations?.services.buckets
|
||||
.map((bucket) => bucket.key as string)
|
||||
.sort() || [];
|
||||
return [ALL_OPTION_VALUE, ...serviceNames];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
import { Setup } from '../../helpers/setup_request';
|
||||
import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types';
|
||||
import { convertConfigSettingsToString } from './convert_settings_to_string';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export async function listConfigurations({ setup }: { setup: Setup }) {
|
||||
const { internalClient, indices } = setup;
|
||||
|
@ -18,8 +17,9 @@ export async function listConfigurations({ setup }: { setup: Setup }) {
|
|||
size: 200,
|
||||
};
|
||||
|
||||
const resp = await withApmSpan('list_agent_configurations', () =>
|
||||
internalClient.search<AgentConfiguration>(params)
|
||||
const resp = await internalClient.search<AgentConfiguration>(
|
||||
'list_agent_configuration',
|
||||
params
|
||||
);
|
||||
|
||||
return resp.hits.hits
|
||||
|
|
|
@ -29,5 +29,8 @@ export async function markAppliedByAgent({
|
|||
},
|
||||
};
|
||||
|
||||
return internalClient.index<AgentConfiguration>(params);
|
||||
return internalClient.index<AgentConfiguration>(
|
||||
'mark_configuration_applied_by_agent',
|
||||
params
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
import { Setup } from '../../helpers/setup_request';
|
||||
import { AgentConfiguration } from '../../../../common/agent_configuration/configuration_types';
|
||||
import { convertConfigSettingsToString } from './convert_settings_to_string';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export async function searchConfigurations({
|
||||
service,
|
||||
|
@ -22,7 +21,6 @@ export async function searchConfigurations({
|
|||
service: AgentConfiguration['service'];
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('search_agent_configurations', async () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
// In the following `constant_score` is being used to disable IDF calculation (where frequency of a term influences scoring).
|
||||
|
@ -72,6 +70,7 @@ export async function searchConfigurations({
|
|||
};
|
||||
|
||||
const resp = await internalClient.search<AgentConfiguration, typeof params>(
|
||||
'search_agent_configurations',
|
||||
params
|
||||
);
|
||||
|
||||
|
@ -82,5 +81,4 @@ export async function searchConfigurations({
|
|||
}
|
||||
|
||||
return convertConfigSettingsToString(hit);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -39,7 +39,9 @@ describe('Create or Update Custom link', () => {
|
|||
|
||||
it('creates a new custom link', () => {
|
||||
createOrUpdateCustomLink({ customLink, setup: mockedSetup });
|
||||
expect(internalClientIndexMock).toHaveBeenCalledWith({
|
||||
expect(internalClientIndexMock).toHaveBeenCalledWith(
|
||||
'create_or_update_custom_link',
|
||||
{
|
||||
refresh: true,
|
||||
index: 'apmCustomLinkIndex',
|
||||
body: {
|
||||
|
@ -49,7 +51,8 @@ describe('Create or Update Custom link', () => {
|
|||
'service.name': ['opbeans-java'],
|
||||
'transaction.type': ['Request'],
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
it('update a new custom link', () => {
|
||||
createOrUpdateCustomLink({
|
||||
|
@ -57,7 +60,9 @@ describe('Create or Update Custom link', () => {
|
|||
customLink,
|
||||
setup: mockedSetup,
|
||||
});
|
||||
expect(internalClientIndexMock).toHaveBeenCalledWith({
|
||||
expect(internalClientIndexMock).toHaveBeenCalledWith(
|
||||
'create_or_update_custom_link',
|
||||
{
|
||||
refresh: true,
|
||||
index: 'apmCustomLinkIndex',
|
||||
id: 'bar',
|
||||
|
@ -68,6 +73,7 @@ describe('Create or Update Custom link', () => {
|
|||
'service.name': ['opbeans-java'],
|
||||
'transaction.type': ['Request'],
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
import { Setup } from '../../helpers/setup_request';
|
||||
import { toESFormat } from './helper';
|
||||
import { APMIndexDocumentParams } from '../../helpers/create_es_client/create_internal_es_client';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function createOrUpdateCustomLink({
|
||||
customLinkId,
|
||||
|
@ -23,7 +22,6 @@ export function createOrUpdateCustomLink({
|
|||
customLink: Omit<CustomLink, '@timestamp'>;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('create_or_update_custom_link', () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
const params: APMIndexDocumentParams<CustomLinkES> = {
|
||||
|
@ -40,6 +38,5 @@ export function createOrUpdateCustomLink({
|
|||
params.id = customLinkId;
|
||||
}
|
||||
|
||||
return internalClient.index(params);
|
||||
});
|
||||
return internalClient.index('create_or_update_custom_link', params);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { Setup } from '../../helpers/setup_request';
|
||||
|
||||
export function deleteCustomLink({
|
||||
|
@ -15,7 +14,6 @@ export function deleteCustomLink({
|
|||
customLinkId: string;
|
||||
setup: Setup;
|
||||
}) {
|
||||
return withApmSpan('delete_custom_link', () => {
|
||||
const { internalClient, indices } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -24,6 +22,5 @@ export function deleteCustomLink({
|
|||
id: customLinkId,
|
||||
};
|
||||
|
||||
return internalClient.delete(params);
|
||||
});
|
||||
return internalClient.delete('delete_custom_link', params);
|
||||
}
|
||||
|
|
|
@ -11,16 +11,14 @@ import { Setup } from '../../helpers/setup_request';
|
|||
import { ProcessorEvent } from '../../../../common/processor_event';
|
||||
import { filterOptionsRt } from './custom_link_types';
|
||||
import { splitFilterValueByComma } from './helper';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function getTransaction({
|
||||
export async function getTransaction({
|
||||
setup,
|
||||
filters = {},
|
||||
}: {
|
||||
setup: Setup;
|
||||
filters?: t.TypeOf<typeof filterOptionsRt>;
|
||||
}) {
|
||||
return withApmSpan('get_transaction_for_custom_link', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const esFilters = compact(
|
||||
|
@ -47,7 +45,9 @@ export function getTransaction({
|
|||
},
|
||||
},
|
||||
};
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_transaction_for_custom_link',
|
||||
params
|
||||
);
|
||||
return resp.hits.hits[0]?._source;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,16 +14,14 @@ import {
|
|||
import { Setup } from '../../helpers/setup_request';
|
||||
import { fromESFormat } from './helper';
|
||||
import { filterOptionsRt } from './custom_link_types';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function listCustomLinks({
|
||||
export async function listCustomLinks({
|
||||
setup,
|
||||
filters = {},
|
||||
}: {
|
||||
setup: Setup;
|
||||
filters?: t.TypeOf<typeof filterOptionsRt>;
|
||||
}): Promise<CustomLink[]> {
|
||||
return withApmSpan('list_custom_links', async () => {
|
||||
const { internalClient, indices } = setup;
|
||||
const esFilters = Object.entries(filters).map(([key, value]) => {
|
||||
return {
|
||||
|
@ -55,7 +53,10 @@ export function listCustomLinks({
|
|||
],
|
||||
},
|
||||
};
|
||||
const resp = await internalClient.search<CustomLinkES>(params);
|
||||
const resp = await internalClient.search<CustomLinkES>(
|
||||
'list_custom_links',
|
||||
params
|
||||
);
|
||||
const customLinks = resp.hits.hits.map((item) =>
|
||||
fromESFormat({
|
||||
id: item._id,
|
||||
|
@ -63,5 +64,4 @@ export function listCustomLinks({
|
|||
})
|
||||
);
|
||||
return customLinks;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import { APMError } from '../../../typings/es_schemas/ui/apm_error';
|
|||
import { rangeQuery } from '../../../server/utils/queries';
|
||||
import { Setup, SetupTimeRange } from '../helpers/setup_request';
|
||||
import { PromiseValueType } from '../../../typings/common';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export interface ErrorsPerTransaction {
|
||||
[transactionId: string]: number;
|
||||
|
@ -29,13 +28,11 @@ export async function getTraceItems(
|
|||
traceId: string,
|
||||
setup: Setup & SetupTimeRange
|
||||
) {
|
||||
return withApmSpan('get_trace_items', async () => {
|
||||
const { start, end, apmEventClient, config } = setup;
|
||||
const maxTraceItems = config['xpack.apm.ui.maxTraceItems'];
|
||||
const excludedLogLevels = ['debug', 'info', 'warning'];
|
||||
|
||||
const errorResponsePromise = withApmSpan('get_trace_error_items', () =>
|
||||
apmEventClient.search({
|
||||
const errorResponsePromise = apmEventClient.search('get_trace_items', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.error],
|
||||
},
|
||||
|
@ -61,11 +58,9 @@ export async function getTraceItems(
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const traceResponsePromise = withApmSpan('get_trace_span_items', () =>
|
||||
apmEventClient.search({
|
||||
const traceResponsePromise = apmEventClient.search('get_trace_span_items', {
|
||||
apm: {
|
||||
events: [ProcessorEvent.span, ProcessorEvent.transaction],
|
||||
},
|
||||
|
@ -89,17 +84,13 @@ export async function getTraceItems(
|
|||
],
|
||||
track_total_hits: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const [errorResponse, traceResponse]: [
|
||||
// explicit intermediary types to avoid TS "excessively deep" error
|
||||
PromiseValueType<typeof errorResponsePromise>,
|
||||
PromiseValueType<typeof traceResponsePromise>
|
||||
] = (await Promise.all([
|
||||
errorResponsePromise,
|
||||
traceResponsePromise,
|
||||
])) as any;
|
||||
] = (await Promise.all([errorResponsePromise, traceResponsePromise])) as any;
|
||||
|
||||
const exceedsMax = traceResponse.hits.total.value > maxTraceItems;
|
||||
|
||||
|
@ -127,5 +118,4 @@ export async function getTraceItems(
|
|||
exceedsMax,
|
||||
...errorFrequencies,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import {
|
|||
getOutcomeAggregation,
|
||||
getTransactionErrorRateTimeSeries,
|
||||
} from '../helpers/transaction_error_rate';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
export async function getErrorRate({
|
||||
environment,
|
||||
|
@ -58,7 +57,6 @@ export async function getErrorRate({
|
|||
transactionErrorRate: Coordinate[];
|
||||
average: number | null;
|
||||
}> {
|
||||
return withApmSpan('get_transaction_group_error_rate', async () => {
|
||||
const { apmEventClient } = setup;
|
||||
|
||||
const transactionNamefilter = transactionName
|
||||
|
@ -115,7 +113,10 @@ export async function getErrorRate({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_transaction_group_error_rate',
|
||||
params
|
||||
);
|
||||
|
||||
const noHits = resp.hits.total.value === 0;
|
||||
|
||||
|
@ -132,7 +133,6 @@ export async function getErrorRate({
|
|||
);
|
||||
|
||||
return { noHits, transactionErrorRate, average };
|
||||
});
|
||||
}
|
||||
|
||||
export async function getErrorRatePeriods({
|
||||
|
|
|
@ -11,7 +11,6 @@ import { TRANSACTION_TYPE } from '../../../common/elasticsearch_fieldnames';
|
|||
import { arrayUnionToCallable } from '../../../common/utils/array_union_to_callable';
|
||||
import { TransactionGroupRequestBase, TransactionGroupSetup } from './fetcher';
|
||||
import { getTransactionDurationFieldForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
import { withApmSpan } from '../../utils/with_apm_span';
|
||||
|
||||
interface MetricParams {
|
||||
request: TransactionGroupRequestBase;
|
||||
|
@ -39,12 +38,11 @@ function mergeRequestWithAggs<
|
|||
});
|
||||
}
|
||||
|
||||
export function getAverages({
|
||||
export async function getAverages({
|
||||
request,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
}: MetricParams) {
|
||||
return withApmSpan('get_avg_transaction_group_duration', async () => {
|
||||
const params = mergeRequestWithAggs(request, {
|
||||
avg: {
|
||||
avg: {
|
||||
|
@ -55,7 +53,10 @@ export function getAverages({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await setup.apmEventClient.search(params);
|
||||
const response = await setup.apmEventClient.search(
|
||||
'get_avg_transaction_group_duration',
|
||||
params
|
||||
);
|
||||
|
||||
return arrayUnionToCallable(
|
||||
response.aggregations?.transaction_groups.buckets ?? []
|
||||
|
@ -65,11 +66,9 @@ export function getAverages({
|
|||
avg: bucket.avg.value,
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getCounts({ request, setup }: MetricParams) {
|
||||
return withApmSpan('get_transaction_group_transaction_count', async () => {
|
||||
export async function getCounts({ request, setup }: MetricParams) {
|
||||
const params = mergeRequestWithAggs(request, {
|
||||
transaction_type: {
|
||||
top_metrics: {
|
||||
|
@ -85,7 +84,10 @@ export function getCounts({ request, setup }: MetricParams) {
|
|||
},
|
||||
});
|
||||
|
||||
const response = await setup.apmEventClient.search(params);
|
||||
const response = await setup.apmEventClient.search(
|
||||
'get_transaction_group_transaction_count',
|
||||
params
|
||||
);
|
||||
|
||||
return arrayUnionToCallable(
|
||||
response.aggregations?.transaction_groups.buckets ?? []
|
||||
|
@ -98,15 +100,13 @@ export function getCounts({ request, setup }: MetricParams) {
|
|||
] as string,
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getSums({
|
||||
export async function getSums({
|
||||
request,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
}: MetricParams) {
|
||||
return withApmSpan('get_transaction_group_latency_sums', async () => {
|
||||
const params = mergeRequestWithAggs(request, {
|
||||
sum: {
|
||||
sum: {
|
||||
|
@ -117,7 +117,10 @@ export function getSums({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await setup.apmEventClient.search(params);
|
||||
const response = await setup.apmEventClient.search(
|
||||
'get_transaction_group_latency_sums',
|
||||
params
|
||||
);
|
||||
|
||||
return arrayUnionToCallable(
|
||||
response.aggregations?.transaction_groups.buckets ?? []
|
||||
|
@ -127,15 +130,13 @@ export function getSums({
|
|||
sum: bucket.sum.value,
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getPercentiles({
|
||||
export async function getPercentiles({
|
||||
request,
|
||||
setup,
|
||||
searchAggregatedTransactions,
|
||||
}: MetricParams) {
|
||||
return withApmSpan('get_transaction_group_latency_percentiles', async () => {
|
||||
const params = mergeRequestWithAggs(request, {
|
||||
p95: {
|
||||
percentiles: {
|
||||
|
@ -148,7 +149,10 @@ export function getPercentiles({
|
|||
},
|
||||
});
|
||||
|
||||
const response = await setup.apmEventClient.search(params);
|
||||
const response = await setup.apmEventClient.search(
|
||||
'get_transaction_group_latency_percentiles',
|
||||
params
|
||||
);
|
||||
|
||||
return arrayUnionToCallable(
|
||||
response.aggregations?.transaction_groups.buckets ?? []
|
||||
|
@ -158,5 +162,4 @@ export function getPercentiles({
|
|||
p95: Object.values(bucket.p95.values)[0],
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('transaction group queries', () => {
|
|||
)
|
||||
);
|
||||
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[0]);
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[1]);
|
||||
|
||||
expect(allParams).toMatchSnapshot();
|
||||
});
|
||||
|
@ -51,7 +51,7 @@ describe('transaction group queries', () => {
|
|||
)
|
||||
);
|
||||
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[0]);
|
||||
const allParams = mock.spy.mock.calls.map((call) => call[1]);
|
||||
|
||||
expect(allParams).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -26,9 +26,8 @@ import {
|
|||
import { getMetricsDateHistogramParams } from '../../helpers/metrics';
|
||||
import { MAX_KPIS } from './constants';
|
||||
import { getVizColorForIndex } from '../../../../common/viz_colors';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export function getTransactionBreakdown({
|
||||
export async function getTransactionBreakdown({
|
||||
environment,
|
||||
kuery,
|
||||
setup,
|
||||
|
@ -43,7 +42,6 @@ export function getTransactionBreakdown({
|
|||
transactionName?: string;
|
||||
transactionType: string;
|
||||
}) {
|
||||
return withApmSpan('get_transaction_breakdown', async () => {
|
||||
const { apmEventClient, start, end, config } = setup;
|
||||
|
||||
const subAggs = {
|
||||
|
@ -133,7 +131,7 @@ export function getTransactionBreakdown({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search('get_transaction_breakdown', params);
|
||||
|
||||
const formatBucket = (
|
||||
aggs:
|
||||
|
@ -243,5 +241,4 @@ export function getTransactionBreakdown({
|
|||
}));
|
||||
|
||||
return { timeseries };
|
||||
});
|
||||
}
|
||||
|
|
|
@ -89,10 +89,9 @@ export async function getBuckets({
|
|||
] as QueryDslQueryContainer[];
|
||||
|
||||
async function getSamplesForDistributionBuckets() {
|
||||
const response = await withApmSpan(
|
||||
const response = await apmEventClient.search(
|
||||
'get_samples_for_latency_distribution_buckets',
|
||||
() =>
|
||||
apmEventClient.search({
|
||||
{
|
||||
apm: {
|
||||
events: [ProcessorEvent.transaction],
|
||||
},
|
||||
|
@ -133,7 +132,7 @@ export async function getBuckets({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -150,10 +149,9 @@ export async function getBuckets({
|
|||
}
|
||||
|
||||
async function getDistributionBuckets() {
|
||||
const response = await withApmSpan(
|
||||
const response = await apmEventClient.search(
|
||||
'get_latency_distribution_buckets',
|
||||
() =>
|
||||
apmEventClient.search({
|
||||
{
|
||||
apm: {
|
||||
events: [
|
||||
getProcessorEventForAggregatedTransactions(
|
||||
|
@ -184,7 +182,7 @@ export async function getBuckets({
|
|||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
@ -20,7 +20,6 @@ import {
|
|||
rangeQuery,
|
||||
kqlQuery,
|
||||
} from '../../../../server/utils/queries';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
|
||||
export async function getDistributionMax({
|
||||
environment,
|
||||
|
@ -39,7 +38,6 @@ export async function getDistributionMax({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_latency_distribution_max', async () => {
|
||||
const { start, end, apmEventClient } = setup;
|
||||
|
||||
const params = {
|
||||
|
@ -76,7 +74,9 @@ export async function getDistributionMax({
|
|||
},
|
||||
};
|
||||
|
||||
const resp = await apmEventClient.search(params);
|
||||
const resp = await apmEventClient.search(
|
||||
'get_latency_distribution_max',
|
||||
params
|
||||
);
|
||||
return resp.aggregations?.stats.value ?? null;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import {
|
|||
} from '../../../lib/helpers/aggregated_transactions';
|
||||
import { getBucketSize } from '../../../lib/helpers/get_bucket_size';
|
||||
import { Setup, SetupTimeRange } from '../../../lib/helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import {
|
||||
getLatencyAggregation,
|
||||
getLatencyValue,
|
||||
|
@ -112,10 +111,10 @@ function searchLatency({
|
|||
},
|
||||
};
|
||||
|
||||
return apmEventClient.search(params);
|
||||
return apmEventClient.search('get_latency_charts', params);
|
||||
}
|
||||
|
||||
export function getLatencyTimeseries({
|
||||
export async function getLatencyTimeseries({
|
||||
environment,
|
||||
kuery,
|
||||
serviceName,
|
||||
|
@ -138,7 +137,6 @@ export function getLatencyTimeseries({
|
|||
start: number;
|
||||
end: number;
|
||||
}) {
|
||||
return withApmSpan('get_latency_charts', async () => {
|
||||
const response = await searchLatency({
|
||||
environment,
|
||||
kuery,
|
||||
|
@ -171,7 +169,6 @@ export function getLatencyTimeseries({
|
|||
}
|
||||
),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function getLatencyPeriods({
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
} from '../../../lib/helpers/aggregated_transactions';
|
||||
import { getBucketSize } from '../../../lib/helpers/get_bucket_size';
|
||||
import { Setup, SetupTimeRange } from '../../../lib/helpers/setup_request';
|
||||
import { withApmSpan } from '../../../utils/with_apm_span';
|
||||
import { getThroughputBuckets } from './transform';
|
||||
|
||||
export type ThroughputChartsResponse = PromiseReturnType<
|
||||
|
@ -96,7 +95,7 @@ function searchThroughput({
|
|||
},
|
||||
};
|
||||
|
||||
return apmEventClient.search(params);
|
||||
return apmEventClient.search('get_transaction_throughput_series', params);
|
||||
}
|
||||
|
||||
export async function getThroughputCharts({
|
||||
|
@ -116,7 +115,6 @@ export async function getThroughputCharts({
|
|||
setup: Setup & SetupTimeRange;
|
||||
searchAggregatedTransactions: boolean;
|
||||
}) {
|
||||
return withApmSpan('get_transaction_throughput_series', async () => {
|
||||
const { bucketSize, intervalString } = getBucketSize(setup);
|
||||
|
||||
const response = await searchThroughput({
|
||||
|
@ -137,5 +135,4 @@ export async function getThroughputCharts({
|
|||
setupTimeRange: setup,
|
||||
}),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue