mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[APM] Fix linking between errors and transactions, and link from errors to Discover (#28477) (#28584)
* [APM] Fix linking between errors and transactions, and link from errors to Discover * Add tests
This commit is contained in:
parent
94c4eb2b33
commit
1c36215b50
5 changed files with 101 additions and 3 deletions
|
@ -79,7 +79,7 @@ exports[`DetailView should render StickyProperties 1`] = `
|
|||
pathname="/app/apm"
|
||||
query={
|
||||
Object {
|
||||
"traceid": "traceId",
|
||||
"traceId": "traceId",
|
||||
"transactionId": "myTransactionName",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ function getTransactionLink(error: APMError, transaction?: Transaction) {
|
|||
hash={path}
|
||||
query={{
|
||||
transactionId: transaction.transaction.id,
|
||||
traceid: get(transaction, TRACE_ID)
|
||||
traceId: get(transaction, TRACE_ID)
|
||||
}}
|
||||
>
|
||||
{transaction.transaction.id}
|
||||
|
|
|
@ -17,7 +17,7 @@ function getDiscoverQuery(error: APMError, kuery?: string) {
|
|||
const groupId = error.error.grouping_key;
|
||||
let query = `${SERVICE_NAME}:"${serviceName}" AND ${ERROR_GROUP_ID}:"${groupId}"`;
|
||||
if (kuery) {
|
||||
query = ` AND ${kuery}`;
|
||||
query += ` AND ${kuery}`;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import { shallow, ShallowWrapper } from 'enzyme';
|
||||
import 'jest-styled-components';
|
||||
import React from 'react';
|
||||
import { APMError } from 'x-pack/plugins/apm/typings/es_schemas/Error';
|
||||
import { DiscoverErrorButton } from '../DiscoverErrorButton';
|
||||
|
||||
describe('DiscoverErrorButton without kuery', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
beforeEach(() => {
|
||||
const error = {
|
||||
context: { service: { name: 'myServiceName' } },
|
||||
error: { grouping_key: 'myGroupingKey' }
|
||||
} as APMError;
|
||||
|
||||
wrapper = shallow(<DiscoverErrorButton error={error} />);
|
||||
});
|
||||
|
||||
it('should have correct query', () => {
|
||||
const queryProp = wrapper.prop('query') as any;
|
||||
expect(queryProp._a.query.query).toEqual(
|
||||
'context.service.name:"myServiceName" AND error.grouping_key:"myGroupingKey"'
|
||||
);
|
||||
});
|
||||
|
||||
it('should match snapshot', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
describe('DiscoverErrorButton with kuery', () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
beforeEach(() => {
|
||||
const error = {
|
||||
context: { service: { name: 'myServiceName' } },
|
||||
error: { grouping_key: 'myGroupingKey' }
|
||||
} as APMError;
|
||||
|
||||
const kuery = 'transaction.sampled: true';
|
||||
|
||||
wrapper = shallow(<DiscoverErrorButton error={error} kuery={kuery} />);
|
||||
});
|
||||
|
||||
it('should have correct query', () => {
|
||||
const queryProp = wrapper.prop('query') as any;
|
||||
expect(queryProp._a.query.query).toEqual(
|
||||
'context.service.name:"myServiceName" AND error.grouping_key:"myGroupingKey" AND transaction.sampled: true'
|
||||
);
|
||||
});
|
||||
|
||||
it('should match snapshot', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,39 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`DiscoverErrorButton with kuery should match snapshot 1`] = `
|
||||
<DiscoverButton
|
||||
query={
|
||||
Object {
|
||||
"_a": Object {
|
||||
"interval": "auto",
|
||||
"query": Object {
|
||||
"language": "lucene",
|
||||
"query": "context.service.name:\\"myServiceName\\" AND error.grouping_key:\\"myGroupingKey\\" AND transaction.sampled: true",
|
||||
},
|
||||
"sort": Object {
|
||||
"@timestamp": "desc",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
`;
|
||||
|
||||
exports[`DiscoverErrorButton without kuery should match snapshot 1`] = `
|
||||
<DiscoverButton
|
||||
query={
|
||||
Object {
|
||||
"_a": Object {
|
||||
"interval": "auto",
|
||||
"query": Object {
|
||||
"language": "lucene",
|
||||
"query": "context.service.name:\\"myServiceName\\" AND error.grouping_key:\\"myGroupingKey\\"",
|
||||
},
|
||||
"sort": Object {
|
||||
"@timestamp": "desc",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
`;
|
Loading…
Add table
Add a link
Reference in a new issue