mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Move TraceView to core grafana * Remove unused code * yarn install * Remove jaeger-ui-components from CODEOWNERS and other tools * Type fixes * yarn install * Remove mock that we no longer need * Fix merge conflicts * Re-add Apache license for trace view components * Use an exclamation-circle instead of triangle to denote errors * Remove eslint disables and update betterer results instead
72 lines
2.6 KiB
TypeScript
72 lines
2.6 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React, { useMemo, useState, createRef } from 'react';
|
|
import { useAsync } from 'react-use';
|
|
|
|
import { PanelProps } from '@grafana/data';
|
|
import { getDataSourceSrv } from '@grafana/runtime';
|
|
import { TraceView } from 'app/features/explore/TraceView/TraceView';
|
|
import TracePageSearchBar from 'app/features/explore/TraceView/components/TracePageHeader/TracePageSearchBar';
|
|
import { TopOfViewRefType } from 'app/features/explore/TraceView/components/TraceTimelineViewer/VirtualizedTraceView';
|
|
import { useSearch } from 'app/features/explore/TraceView/useSearch';
|
|
import { transformDataFrames } from 'app/features/explore/TraceView/utils/transform';
|
|
|
|
const styles = {
|
|
wrapper: css`
|
|
height: 100%;
|
|
overflow: scroll;
|
|
`,
|
|
};
|
|
|
|
export const TracesPanel: React.FunctionComponent<PanelProps> = ({ data }) => {
|
|
const topOfViewRef = createRef<HTMLDivElement>();
|
|
const traceProp = useMemo(() => transformDataFrames(data.series[0]), [data.series]);
|
|
const { search, setSearch, spanFindMatches } = useSearch(traceProp?.spans);
|
|
const [focusedSpanIdForSearch, setFocusedSpanIdForSearch] = useState('');
|
|
const [searchBarSuffix, setSearchBarSuffix] = useState('');
|
|
const dataSource = useAsync(async () => {
|
|
return await getDataSourceSrv().get(data.request?.targets[0].datasource?.uid);
|
|
});
|
|
const scrollElement = document.getElementsByClassName(styles.wrapper)[0];
|
|
const datasourceType = dataSource && dataSource.value ? dataSource.value.type : 'unknown';
|
|
|
|
if (!data || !data.series.length || !traceProp) {
|
|
return (
|
|
<div className="panel-empty">
|
|
<p>No data found in response</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className={styles.wrapper}>
|
|
<div ref={topOfViewRef}></div>
|
|
{data.series[0]?.meta?.preferredVisualisationType === 'trace' ? (
|
|
<TracePageSearchBar
|
|
navigable={true}
|
|
searchValue={search}
|
|
setSearch={setSearch}
|
|
spanFindMatches={spanFindMatches}
|
|
searchBarSuffix={searchBarSuffix}
|
|
setSearchBarSuffix={setSearchBarSuffix}
|
|
focusedSpanIdForSearch={focusedSpanIdForSearch}
|
|
setFocusedSpanIdForSearch={setFocusedSpanIdForSearch}
|
|
datasourceType={datasourceType}
|
|
/>
|
|
) : null}
|
|
|
|
<TraceView
|
|
dataFrames={data.series}
|
|
scrollElement={scrollElement}
|
|
traceProp={traceProp}
|
|
spanFindMatches={spanFindMatches}
|
|
search={search}
|
|
focusedSpanIdForSearch={focusedSpanIdForSearch}
|
|
queryResponse={data}
|
|
datasource={dataSource.value}
|
|
topOfViewRef={topOfViewRef}
|
|
topOfViewRefType={TopOfViewRefType.Panel}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|