mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TracesPanel: Expose focusedSpanLink and createFocusSpanLink as options (#84060)
expose focus span link via traces panel options
This commit is contained in:
parent
e6c20e91bc
commit
9b2058f814
@ -64,10 +64,20 @@ type Props = {
|
||||
datasource: DataSourceApi<DataQuery, DataSourceJsonData, {}> | undefined;
|
||||
topOfViewRef?: RefObject<HTMLDivElement>;
|
||||
createSpanLink?: SpanLinkFunc;
|
||||
focusedSpanId?: string;
|
||||
createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel<Field>;
|
||||
};
|
||||
|
||||
export function TraceView(props: Props) {
|
||||
const { traceProp, datasource, topOfViewRef, exploreId, createSpanLink: createSpanLinkFromProps } = props;
|
||||
const {
|
||||
traceProp,
|
||||
datasource,
|
||||
topOfViewRef,
|
||||
exploreId,
|
||||
createSpanLink: createSpanLinkFromProps,
|
||||
focusedSpanId: focusedSpanIdFromProps,
|
||||
createFocusSpanLink: createFocusSpanLinkFromProps,
|
||||
} = props;
|
||||
|
||||
const {
|
||||
detailStates,
|
||||
@ -101,13 +111,16 @@ export function TraceView(props: Props) {
|
||||
*/
|
||||
const [spanNameColumnWidth, setSpanNameColumnWidth] = useState(0.4);
|
||||
|
||||
const [focusedSpanId, createFocusSpanLink] = useFocusSpanLink({
|
||||
const [focusedSpanIdExplore, createFocusSpanLinkExplore] = useFocusSpanLink({
|
||||
refId: props.dataFrames[0]?.refId,
|
||||
exploreId: props.exploreId!,
|
||||
datasource,
|
||||
splitOpenFn: props.splitOpenFn!,
|
||||
});
|
||||
|
||||
const focusedSpanId = focusedSpanIdFromProps ?? focusedSpanIdExplore;
|
||||
const createFocusSpanLink = createFocusSpanLinkFromProps ?? createFocusSpanLinkExplore;
|
||||
|
||||
const traceTimeline: TTraceTimeline = useMemo(
|
||||
() => ({
|
||||
childrenHiddenIDs,
|
||||
|
@ -2,7 +2,7 @@ import { css } from '@emotion/css';
|
||||
import React, { useMemo, createRef } from 'react';
|
||||
import { useAsync } from 'react-use';
|
||||
|
||||
import { PanelProps } from '@grafana/data';
|
||||
import { Field, LinkModel, 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';
|
||||
@ -17,6 +17,8 @@ const styles = {
|
||||
|
||||
export interface TracesPanelOptions {
|
||||
createSpanLink?: SpanLinkFunc;
|
||||
focusedSpanId?: string;
|
||||
createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel<Field>;
|
||||
}
|
||||
|
||||
export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) => {
|
||||
@ -44,6 +46,8 @@ export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) =
|
||||
datasource={dataSource.value}
|
||||
topOfViewRef={topOfViewRef}
|
||||
createSpanLink={options.createSpanLink}
|
||||
focusedSpanId={options.focusedSpanId}
|
||||
createFocusSpanLink={options.createFocusSpanLink}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user