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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/public/services/rest/apm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export async function loadTransactionDistribution({
start,
end,
transactionName,
transactionId,
kuery
}: IUrlParams) {
return callApi<ITransactionDistributionAPIResponse>({
Expand All @@ -136,6 +137,7 @@ export async function loadTransactionDistribution({
start,
end,
transaction_name: transactionName,
transaction_id: transactionId,
esFilterQuery: await getEncodedEsQuery(kuery)
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ export function TransactionDistributionRequest({
urlParams: IUrlParams;
render: RRRRender<ITransactionDistributionAPIResponse>;
}) {
const { serviceName, start, end, transactionName, kuery } = urlParams;
const {
serviceName,
transactionId,
start,
end,
transactionName,
kuery
} = urlParams;

if (!(serviceName && start && end && transactionName)) {
return null;
Expand All @@ -49,7 +56,9 @@ export function TransactionDistributionRequest({
<Request
id={ID}
fn={loadTransactionDistribution}
args={[{ serviceName, start, end, transactionName, kuery }]}
args={[
{ serviceName, transactionId, start, end, transactionName, kuery }
]}
selector={getTransactionDistribution}
render={render}
/>
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/apm/server/lib/traces/get_top_traces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import {
PARENT_ID,
PROCESSOR_EVENT,
TRACE_ID
TRACE_ID,
TRANSACTION_SAMPLED
} from '../../../common/constants';
import { Setup } from '../helpers/setup_request';
import { getTransactionGroups } from '../transaction_groups';
Expand Down Expand Up @@ -48,7 +49,8 @@ export async function getTopTraces(
}
},
{ term: { [PROCESSOR_EVENT]: 'transaction' } }
]
],
should: [{ term: { [TRANSACTION_SAMPLED]: true } }]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is just something we missed from before but unrelated to this ticket right? (Cool to do that here just making sure I understand)

Copy link
Copy Markdown
Contributor Author

@sorenlouv sorenlouv Nov 28, 2018

Choose a reason for hiding this comment

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

It's sorta related to this ticket, since without this clicking on an item in Trace overview might take the user to a bucket without a sample on the transaction groups page - and thus the bucket won't be highlighted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But yeah, we should probably have added it in the beginning.

}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type ESResponse = AggregationSearchResponse<void, Aggs>;
export function bucketFetcher(
serviceName: string,
transactionName: string,
transactionId: string,
bucketSize: number,
setup: Setup
): Promise<ESResponse> {
Expand All @@ -62,7 +63,10 @@ export function bucketFetcher(
}
}
],
should: [{ term: { [TRANSACTION_SAMPLED]: true } }]
should: [
{ term: { [TRANSACTION_ID]: transactionId } },
{ term: { [TRANSACTION_SAMPLED]: true } }
]
}
},
aggs: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ import { bucketTransformer } from './transform';
export async function getBuckets(
serviceName: string,
transactionName: string,
transactionId: string,
bucketSize: number,
setup: Setup
) {
const response = await bucketFetcher(
serviceName,
transactionName,
transactionId,
bucketSize,
setup
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ITransactionDistributionAPIResponse {
export async function getDistribution(
serviceName: string,
transactionName: string,
transactionId: string,
setup: Setup
): Promise<ITransactionDistributionAPIResponse> {
const bucketSize = await calculateBucketSize(
Expand All @@ -30,6 +31,7 @@ export async function getDistribution(
const { defaultSample, buckets, totalHits } = await getBuckets(
serviceName,
transactionName,
transactionId,
bucketSize,
setup
);
Expand Down
18 changes: 13 additions & 5 deletions x-pack/plugins/apm/server/routes/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,27 @@ export function initTransactionsApi(server: Server) {
pre,
validate: {
query: withDefaultValidators({
transaction_name: Joi.string().required()
transaction_name: Joi.string().required(),
transaction_id: Joi.string().default('')
})
}
},
handler: req => {
const { setup } = req.pre;
const { serviceName } = req.params;
const { transaction_name: transactionName } = req.query as {
const {
transaction_name: transactionName,
transaction_id: transactionId
} = req.query as {
transaction_name: string;
transaction_id: string;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The typescript destructuring can be a bit harder to read. Could be made simple to replace the above 7 lines with the following 2 lines:

const transactionName: string = query.transaction_name;
const transactionId: string = query.transaction_id;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I'm actually fixing this and a few other bits in another PR. Is it okay I leave as-is here, and fix it in the next PR?

return getDistribution(serviceName, transactionName, setup).catch(
defaultErrorHandler
);
return getDistribution(
serviceName,
transactionName,
transactionId,
setup
).catch(defaultErrorHandler);
}
});
}