mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* Embed flame graph * Update test * Update test * Use toggle * Update test * Add tests * Use const * Cleanup * Update profile tag * Move flame graph out of tags, remove request and other cleanup + tests * Update test * Set flame graph by profile id and simplify logic * Cleanup and redrawListView * Create/use feature toggle
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React, { useMemo, 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 { SpanLinkFunc } from 'app/features/explore/TraceView/components';
|
|
import { transformDataFrames } from 'app/features/explore/TraceView/utils/transform';
|
|
|
|
const styles = {
|
|
wrapper: css`
|
|
height: 100%;
|
|
overflow: scroll;
|
|
`,
|
|
};
|
|
|
|
export interface TracesPanelOptions {
|
|
createSpanLink?: SpanLinkFunc;
|
|
}
|
|
|
|
export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) => {
|
|
const topOfViewRef = createRef<HTMLDivElement>();
|
|
const traceProp = useMemo(() => transformDataFrames(data.series[0]), [data.series]);
|
|
const dataSource = useAsync(async () => {
|
|
return await getDataSourceSrv().get(data.request?.targets[0].datasource?.uid);
|
|
});
|
|
|
|
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>
|
|
<TraceView
|
|
dataFrames={data.series}
|
|
scrollElementClass={styles.wrapper}
|
|
traceProp={traceProp}
|
|
datasource={dataSource.value}
|
|
topOfViewRef={topOfViewRef}
|
|
createSpanLink={options.createSpanLink}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|