Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display serviceName based on service tag, if available #435

Merged
merged 5 commits into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting you are prioritizing tag over field.. is this common or a bug?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting you are prioritizing tag over field.. is this common or a bug?

This change is to visualize our indexer change (ExpediaDotCom/haystack-traces#183 in response to opentracing/specification#131). Until there's a consensus on the OT specification, we're going to override the visualized service name with service tag, if it exists


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