[APM] Default time range overrides fetched range for link-to/trace URLs without range parameters (#115449)

* removing default time range from link trace url

* adding test
This commit is contained in:
Cauê Marcondes 2021-10-19 13:57:51 -04:00 committed by GitHub
parent 0447557c06
commit 36d128c3e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View file

@ -21,19 +21,35 @@ describe('getRedirectToTransactionDetailPageUrl', () => {
},
} as unknown as any;
const url = getRedirectToTransactionDetailPageUrl({ transaction });
describe('without time range', () => {
const url = getRedirectToTransactionDetailPageUrl({ transaction });
it('rounds the start time down', () => {
expect(parse(url, true).query.rangeFrom).toBe('2020-01-01T00:00:00.000Z');
it('rounds the start time down', () => {
expect(parse(url, true).query.rangeFrom).toBe('2020-01-01T00:00:00.000Z');
});
it('rounds the end time up', () => {
expect(parse(url, true).query.rangeTo).toBe('2020-01-01T00:05:00.000Z');
});
it('formats url correctly', () => {
expect(url).toBe(
'/services/opbeans-node/transactions/view?traceId=trace_id&transactionId=transaction_id&transactionName=transaction_name&transactionType=request&rangeFrom=2020-01-01T00%3A00%3A00.000Z&rangeTo=2020-01-01T00%3A05%3A00.000Z'
);
});
});
it('rounds the end time up', () => {
expect(parse(url, true).query.rangeTo).toBe('2020-01-01T00:05:00.000Z');
});
describe('with time range', () => {
const url = getRedirectToTransactionDetailPageUrl({
transaction,
rangeFrom: '2020-01-01T00:02:00.000Z',
rangeTo: '2020-01-01T00:17:59.999Z',
});
it('formats url correctly', () => {
expect(url).toBe(
'/services/opbeans-node/transactions/view?traceId=trace_id&transactionId=transaction_id&transactionName=transaction_name&transactionType=request&rangeFrom=2020-01-01T00%3A00%3A00.000Z&rangeTo=2020-01-01T00%3A05%3A00.000Z'
);
it('uses timerange provided', () => {
expect(url).toBe(
'/services/opbeans-node/transactions/view?traceId=trace_id&transactionId=transaction_id&transactionName=transaction_name&transactionType=request&rangeFrom=2020-01-01T00%3A02%3A00.000Z&rangeTo=2020-01-01T00%3A17%3A59.999Z'
);
});
});
});

View file

@ -53,12 +53,6 @@ const apmRoutes = route([
}),
}),
]),
defaults: {
query: {
rangeFrom: 'now-15m',
rangeTo: 'now',
},
},
},
{
path: '/',