From ca7514207f13d351111b215d375f58c965f328f2 Mon Sep 17 00:00:00 2001 From: Yuri Shkuro Date: Fri, 24 Mar 2017 17:12:16 -0400 Subject: [PATCH] Support search by trace IDs --- .../SearchTracePage/TraceSearchForm.js | 17 +++++++++++++++++ src/components/SearchTracePage/index.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/SearchTracePage/TraceSearchForm.js b/src/components/SearchTracePage/TraceSearchForm.js index de7fd96ad9..36c9b52a52 100644 --- a/src/components/SearchTracePage/TraceSearchForm.js +++ b/src/components/SearchTracePage/TraceSearchForm.js @@ -48,6 +48,13 @@ export function tagsToQuery(tags) { return tags.split('|'); } +export function traceIDsToQuery(traceIDs) { + if (!traceIDs) { + return null; + } + return traceIDs.split(','); +} + export function convertQueryParamsToFormDates({ start, end }) { let queryStartDate; let queryStartDateTime; @@ -246,6 +253,7 @@ const mapStateToProps = state => { maxDuration, minDuration, lookback, + traceID: traceIDParams, } = state.routing.locationBeforeTransitions.query; const nowInMicroseconds = moment().valueOf() * 1000; @@ -271,6 +279,12 @@ const mapStateToProps = state => { if (tagParams) { tags = tagParams instanceof Array ? tagParams.join('|') : tagParams; } + let traceIDs; + if (traceIDParams) { + traceIDs = traceIDParams instanceof Array + ? traceIDParams.join(',') + : traceIDParams; + } return { destroyOnUnmount: false, initialValues: { @@ -285,6 +299,7 @@ const mapStateToProps = state => { tags, minDuration: minDuration || null, maxDuration: maxDuration || null, + traceIDs: traceIDs || null, }, selectedService: searchSideBarFormSelector(state, 'service'), selectedLookback: searchSideBarFormSelector(state, 'lookback'), @@ -307,6 +322,7 @@ const mapDispatchToProps = dispatch => { minDuration, maxDuration, lookback, + traceIDs, } = fields; store.set('lastSearch', { service, operation }); @@ -339,6 +355,7 @@ const mapDispatchToProps = dispatch => { tag: tagsToQuery(tags) || undefined, minDuration: minDuration || null, maxDuration: maxDuration || null, + traceID: traceIDsToQuery(traceIDs) || undefined, }); }, }; diff --git a/src/components/SearchTracePage/index.js b/src/components/SearchTracePage/index.js index f54b53889b..cdd30bc212 100644 --- a/src/components/SearchTracePage/index.js +++ b/src/components/SearchTracePage/index.js @@ -77,7 +77,7 @@ const traceResultsFiltersFormSelector = formValueSelector( export default class SearchTracePage extends Component { componentDidMount() { const { searchTraces, urlQueryParams, fetchServices } = this.props; - if (urlQueryParams.service) { + if (urlQueryParams.service || urlQueryParams.traceID) { searchTraces(urlQueryParams); } fetchServices();