forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
550 B
15 lines
550 B
import { useMemo, useState } from 'react';
|
|
import { filterSpans, TraceSpan } from '@jaegertracing/jaeger-ui-components';
|
|
|
|
/**
|
|
* Controls the state of search input that highlights spans if they match the search string.
|
|
* @param spans
|
|
*/
|
|
export function useSearch(spans?: TraceSpan[]) {
|
|
const [search, setSearch] = useState('');
|
|
const spanFindMatches: Set<string> | undefined | null = useMemo(() => {
|
|
return search && spans ? filterSpans(search, spans) : undefined;
|
|
}, [search, spans]);
|
|
|
|
return { search, setSearch, spanFindMatches };
|
|
}
|
|
|