Skip to content

Commit

Permalink
Merge pull request #435 from ExpediaDotCom/service-tag
Browse files Browse the repository at this point in the history
Display serviceName based on service tag, if available
  • Loading branch information
Jeff Baker authored Nov 27, 2018
2 parents 8d43a20 + cdb75a9 commit acb2114
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
25 changes: 15 additions & 10 deletions server/connectors/traces/stub/tracesConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/components/traces/details/timeline/span.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export default class Span extends React.Component {
} = this.props;

const {
serviceName,
depth,
expandable,
expanded,
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion test/src/components/traces/traces.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ const stubDetails = [
{
key: 'success',
value: 'false'
},
{
key: 'service',
value: 'service-tag'
}
]
},
Expand Down Expand Up @@ -414,7 +418,6 @@ describe('<Traces />', () => {
it('should render results after getting search results', () => {
const tracesSearchStore = createStubStore(stubResults, fulfilledPromise);
const wrapper = mount(<TracesStubComponent tracesSearchStore={tracesSearchStore} history={stubHistory} location={stubLocation} match={stubMatch}/>);

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);
Expand Down Expand Up @@ -617,6 +620,15 @@ describe('<Traces />', () => {
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(<TraceDetailsStubComponent traceId={stubDetails[0].traceId} location={stubLocation} baseServiceName={stubDetails[0].serviceName} traceDetailsStore={traceDetailsStore} />);

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(<TraceDetailsStubComponent traceId={stubDetails[0].traceId} location={stubLocation} baseServiceName={stubDetails[0].serviceName} traceDetailsStore={traceDetailsStore} />);
Expand Down

0 comments on commit acb2114

Please sign in to comment.