From 2f79140d083cf05e3e7a726ab2461710a67c7f11 Mon Sep 17 00:00:00 2001 From: Joe Farro Date: Sun, 11 Mar 2018 21:07:24 -0400 Subject: [PATCH 1/2] Fix 166 - Handle Error objs in redux trace.traces Signed-off-by: Joe Farro --- src/model/search.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/model/search.js b/src/model/search.js index 58d765b387..45b9c9ef0d 100644 --- a/src/model/search.js +++ b/src/model/search.js @@ -30,7 +30,10 @@ const isErrorTag = ({ key, value }) => key === 'error' && (value === true || val * @param trace Trace data in the format sent over the wire. * @return {TraceSummary} Summary of the trace data for use in the search results. */ -export function getTraceSummary(trace: Trace): TraceSummary { +export function getTraceSummary(trace: Trace | Error): ?TraceSummary { + if (trace instanceof Error) { + return null; + } const { processes, spans, traceID } = trace; let traceName = ''; @@ -83,7 +86,7 @@ export function getTraceSummary(trace: Trace): TraceSummary { * @return {TraceSummaries} The `{ traces, maxDuration }` value. */ export function getTraceSummaries(_traces: Trace[]): TraceSummaries { - const traces = _traces.map(getTraceSummary); + const traces = _traces.map(getTraceSummary).filter(Boolean); const maxDuration = Math.max(..._map(traces, 'duration')); return { maxDuration, traces }; } From bafe9a6f22664dd0794aa0b98dbb905b81e262ed Mon Sep 17 00:00:00 2001 From: Joe Farro Date: Tue, 13 Mar 2018 13:27:33 -0400 Subject: [PATCH 2/2] Filter for Error objs one level higher Filter in getTraceSummaries instead of further upstream because the presence of the Error will be useful in resolving #51. Signed-off-by: Joe Farro --- src/model/search.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/model/search.js b/src/model/search.js index 45b9c9ef0d..62dd3ac961 100644 --- a/src/model/search.js +++ b/src/model/search.js @@ -30,10 +30,7 @@ const isErrorTag = ({ key, value }) => key === 'error' && (value === true || val * @param trace Trace data in the format sent over the wire. * @return {TraceSummary} Summary of the trace data for use in the search results. */ -export function getTraceSummary(trace: Trace | Error): ?TraceSummary { - if (trace instanceof Error) { - return null; - } +export function getTraceSummary(trace: Trace): TraceSummary { const { processes, spans, traceID } = trace; let traceName = ''; @@ -82,11 +79,18 @@ export function getTraceSummary(trace: Trace | Error): ?TraceSummary { /** * Transforms `Trace` values into `TraceSummary` values and finds the max duration of the traces. * - * @param {Trace} _traces The trace data in the format from the HTTP request. + * @param {(Trace | Error)[]} _traces The trace data in the format from the HTTP request. * @return {TraceSummaries} The `{ traces, maxDuration }` value. */ -export function getTraceSummaries(_traces: Trace[]): TraceSummaries { - const traces = _traces.map(getTraceSummary).filter(Boolean); +export function getTraceSummaries(_traces: (Trace | Error)[]): TraceSummaries { + const traces = _traces + .map(item => { + if (item instanceof Error) { + return null; + } + return getTraceSummary(item); + }) + .filter(Boolean); const maxDuration = Math.max(..._map(traces, 'duration')); return { maxDuration, traces }; }