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;
|
datasource: DataSourceApi<DataQuery, DataSourceJsonData, {}> | undefined;
|
||||||
topOfViewRef?: RefObject<HTMLDivElement>;
|
topOfViewRef?: RefObject<HTMLDivElement>;
|
||||||
createSpanLink?: SpanLinkFunc;
|
createSpanLink?: SpanLinkFunc;
|
||||||
|
focusedSpanId?: string;
|
||||||
|
createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel<Field>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function TraceView(props: Props) {
|
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 {
|
const {
|
||||||
detailStates,
|
detailStates,
|
||||||
@ -101,13 +111,16 @@ export function TraceView(props: Props) {
|
|||||||
*/
|
*/
|
||||||
const [spanNameColumnWidth, setSpanNameColumnWidth] = useState(0.4);
|
const [spanNameColumnWidth, setSpanNameColumnWidth] = useState(0.4);
|
||||||
|
|
||||||
const [focusedSpanId, createFocusSpanLink] = useFocusSpanLink({
|
const [focusedSpanIdExplore, createFocusSpanLinkExplore] = useFocusSpanLink({
|
||||||
refId: props.dataFrames[0]?.refId,
|
refId: props.dataFrames[0]?.refId,
|
||||||
exploreId: props.exploreId!,
|
exploreId: props.exploreId!,
|
||||||
datasource,
|
datasource,
|
||||||
splitOpenFn: props.splitOpenFn!,
|
splitOpenFn: props.splitOpenFn!,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const focusedSpanId = focusedSpanIdFromProps ?? focusedSpanIdExplore;
|
||||||
|
const createFocusSpanLink = createFocusSpanLinkFromProps ?? createFocusSpanLinkExplore;
|
||||||
|
|
||||||
const traceTimeline: TTraceTimeline = useMemo(
|
const traceTimeline: TTraceTimeline = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
childrenHiddenIDs,
|
childrenHiddenIDs,
|
||||||
|
@ -2,7 +2,7 @@ import { css } from '@emotion/css';
|
|||||||
import React, { useMemo, createRef } from 'react';
|
import React, { useMemo, createRef } from 'react';
|
||||||
import { useAsync } from 'react-use';
|
import { useAsync } from 'react-use';
|
||||||
|
|
||||||
import { PanelProps } from '@grafana/data';
|
import { Field, LinkModel, PanelProps } from '@grafana/data';
|
||||||
import { getDataSourceSrv } from '@grafana/runtime';
|
import { getDataSourceSrv } from '@grafana/runtime';
|
||||||
import { TraceView } from 'app/features/explore/TraceView/TraceView';
|
import { TraceView } from 'app/features/explore/TraceView/TraceView';
|
||||||
import { SpanLinkFunc } from 'app/features/explore/TraceView/components';
|
import { SpanLinkFunc } from 'app/features/explore/TraceView/components';
|
||||||
@ -17,6 +17,8 @@ const styles = {
|
|||||||
|
|
||||||
export interface TracesPanelOptions {
|
export interface TracesPanelOptions {
|
||||||
createSpanLink?: SpanLinkFunc;
|
createSpanLink?: SpanLinkFunc;
|
||||||
|
focusedSpanId?: string;
|
||||||
|
createFocusSpanLink?: (traceId: string, spanId: string) => LinkModel<Field>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) => {
|
export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) => {
|
||||||
@ -44,6 +46,8 @@ export const TracesPanel = ({ data, options }: PanelProps<TracesPanelOptions>) =
|
|||||||
datasource={dataSource.value}
|
datasource={dataSource.value}
|
||||||
topOfViewRef={topOfViewRef}
|
topOfViewRef={topOfViewRef}
|
||||||
createSpanLink={options.createSpanLink}
|
createSpanLink={options.createSpanLink}
|
||||||
|
focusedSpanId={options.focusedSpanId}
|
||||||
|
createFocusSpanLink={options.createFocusSpanLink}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user