diff --git a/server/connectors/traces/haystack/search/searchResultsTransformer.js b/server/connectors/traces/haystack/search/searchResultsTransformer.js index 5cf4c79c..c7c60911 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) diff --git a/server/connectors/traces/stub/tracesConnector.js b/server/connectors/traces/stub/tracesConnector.js index af25f520..695bb8cc 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 2542fb59..25381bcf 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 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();