From 838593f0e4615ff4b1b693c9b81f16d50d2e9649 Mon Sep 17 00:00:00 2001 From: Jason Bulicek Date: Mon, 1 Oct 2018 15:09:15 -0700 Subject: [PATCH 1/3] have traces search for service tag in spans --- .../connectors/traces/stub/tracesConnector.js | 25 +++++++++++-------- .../traces/details/timeline/span.jsx | 3 ++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/server/connectors/traces/stub/tracesConnector.js b/server/connectors/traces/stub/tracesConnector.js index 1aa8f799..66a191a5 100644 --- a/server/connectors/traces/stub/tracesConnector.js +++ b/server/connectors/traces/stub/tracesConnector.js @@ -51,10 +51,11 @@ const trace = () => { startTime: 1504784384000, duration: 3525000, logs: [], - tags: [{ - key: 'url', - value: 'http://trace.io/blah' - }, + tags: [ + { + key: 'url', + value: 'http://trace.io/blah' + }, { key: 'url2', value: 'some:data' @@ -73,10 +74,11 @@ const trace = () => { startTime: 1504784384000 + 250000, duration: 1505000, logs: [], - tags: [{ - key: 'url', - value: 'http://trace.io/blah' - }, + tags: [ + { + key: 'url', + value: 'http://trace.io/blah' + }, { key: 'error', value: true @@ -114,12 +116,15 @@ const trace = () => { traceId, parentSpanId: span2, spanId: span3, - serviceName: 'tyrell-service', + serviceName: 'this-should-not-show', operationName: 'tully-1', startTime: 1504784384000 + 250000 + 120000, duration: 605000, logs: [], - tags: [] + tags: [{ + key: 'service', + value: 'tyrell-service' + }] }, { traceId, diff --git a/src/components/traces/details/timeline/span.jsx b/src/components/traces/details/timeline/span.jsx index ae0a2ef1..a5028166 100644 --- a/src/components/traces/details/timeline/span.jsx +++ b/src/components/traces/details/timeline/span.jsx @@ -88,7 +88,6 @@ export default class Span extends React.Component { } = this.props; const { - serviceName, depth, expandable, expanded, @@ -97,6 +96,8 @@ export default class Span extends React.Component { operationName } = span; + const serviceName = Span.getTagValue(span, 'service') || span.serviceName; + const depthFactor = depth * 0.5; // coordinates From 958c69b4a805d9d20c0a075770176394cce926ff Mon Sep 17 00:00:00 2001 From: Jason Bulicek Date: Tue, 2 Oct 2018 09:23:25 -0700 Subject: [PATCH 2/3] add tag search for service key in haystack connector to display in trace results table "service names" list --- .../traces/haystack/search/searchResultsTransformer.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/connectors/traces/haystack/search/searchResultsTransformer.js b/server/connectors/traces/haystack/search/searchResultsTransformer.js index 132e3263..34650af3 100644 --- a/server/connectors/traces/haystack/search/searchResultsTransformer.js +++ b/server/connectors/traces/haystack/search/searchResultsTransformer.js @@ -65,7 +65,7 @@ function isSpanError(span) { } function createServicesSummary(trace) { - const services = _.countBy(trace, span => span.serviceName); + const services = _.countBy(trace, span => findTag(span, 'service') || span.serviceName); return _.keys(services).map(service => ({ name: service, @@ -100,9 +100,10 @@ function createQueriedOperationSummary(trace, operationName, endToEndDuration) { function toSearchResult(trace, query) { const rootSpan = trace.find(span => !span.parentSpanId); + const serviceName = findTag(rootSpan.tags, 'service') || rootSpan.serviceName; const root = { url: findTag(rootSpan.tags, 'url') || '', - serviceName: rootSpan.serviceName, + serviceName, operationName: rootSpan.operationName, duration: rootSpan.duration, error: isSpanError(rootSpan) From 3518b1379a7543db1258b190ee8be4ac48d99e8f Mon Sep 17 00:00:00 2001 From: Jason Bulicek Date: Tue, 27 Nov 2018 13:54:29 -0800 Subject: [PATCH 3/3] add test for service tag --- haystack-idl | 2 +- test/src/components/traces/traces.spec.jsx | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/haystack-idl b/haystack-idl index e20a26e4..973079a7 160000 --- a/haystack-idl +++ b/haystack-idl @@ -1 +1 @@ -Subproject commit e20a26e462355856c259b6a4c6c483fc53d8cb56 +Subproject commit 973079a72b44be74cc1fa6bd81daa6f27d9ce810 diff --git a/test/src/components/traces/traces.spec.jsx b/test/src/components/traces/traces.spec.jsx index 669c59ba..0a1cfff9 100644 --- a/test/src/components/traces/traces.spec.jsx +++ b/test/src/components/traces/traces.spec.jsx @@ -205,6 +205,10 @@ const stubDetails = [ { key: 'success', value: 'false' + }, + { + key: 'service', + value: 'service-tag' } ] }, @@ -414,7 +418,6 @@ describe('', () => { it('should render results after getting search results', () => { const tracesSearchStore = createStubStore(stubResults, fulfilledPromise); const wrapper = mount(); - expect(tracesSearchStore.fetchSearchResults.callCount).to.equal(1); expect(wrapper.find('.react-bs-table-container')).to.have.length(1); expect(wrapper.find('tr.tr-no-border')).to.have.length(2); @@ -617,6 +620,15 @@ describe('', () => { expect(wrapper.find('.span-bar')).to.have.length(stubDetails.length); }); + it('renders serviceName correctly when it is liked in service tag', () => { + const traceDetailsStore = createStubDetailsStore(stubDetails, fulfilledPromise); + const wrapper = mount(); + + const spanServiceName = wrapper.find('Span').at(1).find('.span-service-label').text(); + + expect(spanServiceName).to.equal('service-tag'); + }); + it('renders the descendents on Span Click', () => { const traceDetailsStore = createStubDetailsStore(stubDetails, fulfilledPromise); const wrapper = mount();