2018-04-20 21:13:37 +02:00
|
|
|
/*
|
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
|
|
*/
|
|
|
|
|
2019-08-21 15:51:41 +02:00
|
|
|
import * as t from 'io-ts';
|
2018-10-23 22:34:23 +02:00
|
|
|
import { setupRequest } from '../lib/helpers/setup_request';
|
|
|
|
import { getTrace } from '../lib/traces/get_trace';
|
2019-07-26 21:01:23 +02:00
|
|
|
import { getTransactionGroupList } from '../lib/transaction_groups';
|
2019-08-21 15:51:41 +02:00
|
|
|
import { createRoute } from './create_route';
|
|
|
|
import { rangeRt, uiFiltersRt } from './default_api_types';
|
2020-09-16 19:20:08 +02:00
|
|
|
import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions';
|
2018-04-20 21:13:37 +02:00
|
|
|
|
2019-08-21 15:51:41 +02:00
|
|
|
export const tracesRoute = createRoute(() => ({
|
|
|
|
path: '/api/apm/traces',
|
|
|
|
params: {
|
2020-05-22 09:08:58 +02:00
|
|
|
query: t.intersection([rangeRt, uiFiltersRt]),
|
2019-08-21 15:51:41 +02:00
|
|
|
},
|
2019-11-21 15:46:34 +01:00
|
|
|
handler: async ({ context, request }) => {
|
|
|
|
const setup = await setupRequest(context, request);
|
2020-09-16 19:20:08 +02:00
|
|
|
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
|
|
|
|
setup
|
|
|
|
);
|
|
|
|
return getTransactionGroupList(
|
|
|
|
{ type: 'top_traces', searchAggregatedTransactions },
|
|
|
|
setup
|
|
|
|
);
|
2020-05-22 09:08:58 +02:00
|
|
|
},
|
2019-08-21 15:51:41 +02:00
|
|
|
}));
|
2018-04-20 21:13:37 +02:00
|
|
|
|
2019-08-21 15:51:41 +02:00
|
|
|
export const tracesByIdRoute = createRoute(() => ({
|
|
|
|
path: '/api/apm/traces/{traceId}',
|
|
|
|
params: {
|
|
|
|
path: t.type({
|
2020-05-22 09:08:58 +02:00
|
|
|
traceId: t.string,
|
2019-08-21 15:51:41 +02:00
|
|
|
}),
|
2020-05-22 09:08:58 +02:00
|
|
|
query: rangeRt,
|
2019-08-21 15:51:41 +02:00
|
|
|
},
|
2019-11-21 15:46:34 +01:00
|
|
|
handler: async ({ context, request }) => {
|
|
|
|
const setup = await setupRequest(context, request);
|
|
|
|
return getTrace(context.params.path.traceId, setup);
|
2020-05-22 09:08:58 +02:00
|
|
|
},
|
2019-08-21 15:51:41 +02:00
|
|
|
}));
|