forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Link Transaction to Infra & Logging with action menu (elastic#2…
…7291) * [APM] fixes elastic#26574 by adding an Action menu which links a transaction to the Infra & Logging UIs * [APM] - remove link to host metrics filterd by trace id until supported - replace ts-optchain with _.get - remove old, unreferenced ActionMenu dead code - add unit tests * [APM] Make sure the apm index pattern filter is passed thru via the Discover link * [APM] refactored DiscoverButton and TransactionActionMenu to use new QueryWithIndexPattern component to pass along the correct index pattern via the discover link
- Loading branch information
Showing
17 changed files
with
955 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 0 additions & 117 deletions
117
x-pack/plugins/apm/public/components/app/TransactionDetails/Transaction/ActionMenu.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
x-pack/plugins/apm/public/components/shared/DiscoverButtons/QueryWithIndexPattern.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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 React, { ReactElement } from 'react'; | ||
import { StringMap } from 'x-pack/plugins/apm/typings/common'; | ||
import { | ||
getAPMIndexPattern, | ||
ISavedObject | ||
} from '../../../services/rest/savedObjects'; | ||
|
||
export function getQueryWithIndexPattern( | ||
query: StringMap = {}, | ||
indexPattern?: ISavedObject | ||
) { | ||
if ((query._a && query._a.index) || !indexPattern) { | ||
return query; | ||
} | ||
|
||
const id = indexPattern && indexPattern.id; | ||
|
||
return { | ||
...query, | ||
_a: { | ||
...query._a, | ||
index: id | ||
} | ||
}; | ||
} | ||
|
||
interface Props { | ||
query?: StringMap; | ||
children: (query: StringMap) => ReactElement<any>; | ||
} | ||
|
||
interface State { | ||
indexPattern?: ISavedObject; | ||
} | ||
|
||
export class QueryWithIndexPattern extends React.Component<Props, State> { | ||
constructor(props: Props) { | ||
super(props); | ||
getAPMIndexPattern().then(indexPattern => { | ||
this.setState({ indexPattern }); | ||
}); | ||
this.state = {}; | ||
} | ||
public render() { | ||
const { children, query } = this.props; | ||
const { indexPattern } = this.state; | ||
const renderWithQuery = children; | ||
return renderWithQuery(getQueryWithIndexPattern(query, indexPattern)); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
.../apm/public/components/shared/DiscoverButtons/__test__/DiscoverTransactionButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 } from 'enzyme'; | ||
import 'jest-styled-components'; | ||
import React from 'react'; | ||
import { Transaction } from 'x-pack/plugins/apm/typings/es_schemas/Transaction'; | ||
import { | ||
DiscoverTransactionButton, | ||
getDiscoverQuery | ||
} from '../DiscoverTransactionButton'; | ||
import mockTransaction from './mockTransaction.json'; | ||
|
||
describe('DiscoverTransactionButton component', () => { | ||
it('should render with data', () => { | ||
const transaction: Transaction = mockTransaction; | ||
|
||
expect( | ||
shallow(<DiscoverTransactionButton transaction={transaction} />) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('getDiscoverQuery', () => { | ||
it('should return the correct query params object', () => { | ||
const transaction: Transaction = mockTransaction; | ||
const result = getDiscoverQuery(transaction); | ||
expect(result).toMatchSnapshot(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
...nts/shared/DiscoverButtons/__test__/__snapshots__/DiscoverTransactionButton.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DiscoverTransactionButton component should render with data 1`] = ` | ||
<DiscoverButton | ||
query={ | ||
Object { | ||
"_a": Object { | ||
"interval": "auto", | ||
"query": Object { | ||
"language": "lucene", | ||
"query": "processor.event:\\"transaction\\" AND transaction.id:\\"8b60bd32ecc6e150\\" AND trace.id:\\"8b60bd32ecc6e1506735a8b6cfcf175c\\"", | ||
}, | ||
}, | ||
} | ||
} | ||
/> | ||
`; | ||
|
||
exports[`getDiscoverQuery should return the correct query params object 1`] = ` | ||
Object { | ||
"_a": Object { | ||
"interval": "auto", | ||
"query": Object { | ||
"language": "lucene", | ||
"query": "processor.event:\\"transaction\\" AND transaction.id:\\"8b60bd32ecc6e150\\" AND trace.id:\\"8b60bd32ecc6e1506735a8b6cfcf175c\\"", | ||
}, | ||
}, | ||
} | ||
`; |
Oops, something went wrong.