Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan
### Fixed

- [#175](https://github.com/kobsio/kobs/pull/175): [prometheus] Fix tooltip when no unit is provided.
- [#186](https://github.com/kobsio/kobs/pull/186): [jaeger] Fix tooltip position in traces chart.

### Changed

Expand Down
24 changes: 21 additions & 3 deletions plugins/jaeger/src/components/panel/TracesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,35 @@ function isIDatum(object: Datum): object is IDatum {
}

const TracesChart: React.FunctionComponent<ITracesChartProps> = ({ name, traces, showDetails }: ITracesChartProps) => {
const { series, min, max } = useMemo<{ series: Serie[]; min: number; max: number }>(() => {
const { series, min, max, first, last } = useMemo<{
series: Serie[];
min: number;
max: number;
first: number;
last: number;
}>(() => {
// Initialize min and max so that we can simply compare during traversing.
let minimalSpans = Number.MAX_SAFE_INTEGER;
let maximalSpans = 0;
let firstTime = 0;
let lastTime = 0;
const result: IDatum[] = [];

traces.forEach((trace) => {
traces.forEach((trace, index) => {
if (trace.spans.length < minimalSpans) {
minimalSpans = trace.spans.length;
}
if (trace.spans.length > maximalSpans) {
maximalSpans = trace.spans.length;
}

if (trace.startTime < firstTime || index === 0) {
firstTime = trace.startTime;
}
if (trace.startTime > lastTime || index === 0) {
lastTime = trace.startTime;
}

result.push({
label: trace.traceName,
size: trace.spans.length,
Expand All @@ -48,6 +63,8 @@ const TracesChart: React.FunctionComponent<ITracesChartProps> = ({ name, traces,
});

return {
first: firstTime,
last: lastTime,
max: maximalSpans,
min: minimalSpans,
series: [
Expand Down Expand Up @@ -96,7 +113,8 @@ const TracesChart: React.FunctionComponent<ITracesChartProps> = ({ name, traces,
}}
theme={CHART_THEME}
tooltip={(tooltip): ReactNode => {
const isFirstHalf = tooltip.node.index < series[0].data.length / 2;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const isFirstHalf = (tooltip.node.data as any).trace.startTime < (last + first) / 2;
const hasError = isIDatum(tooltip.node.data) ? doesTraceContainsError(tooltip.node.data.trace) : false;
const squareColor = hasError ? '#c9190b' : '#0066cc';

Expand Down