TracesPanel: Expose focusedSpanLink and createFocusSpanLink as options (#84060)

expose focus span link via traces panel options
This commit is contained in:
Domas 2024-03-13 09:23:51 +02:00 committed by GitHub
parent e6c20e91bc
commit 9b2058f814
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 3 deletions

View File

@ -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,

View File

@ -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>
);