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

Flags yellow for annotations that match case insensitive error #1475

Merged
merged 1 commit into from
Jan 8, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions zipkin-ui/js/component_ui/spanPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import {component} from 'flightjs';
import $ from 'jquery';
import {Constants} from './traceConstants';

// Annotation values that contain the word "error" hint of a transient error.
// This adds a class when that's the case.
export function maybeMarkTransientError(row, anno) {
if (/error/i.test(anno.value)) {
row.addClass('anno-error-transient');
}
}

// annotations are named events which shouldn't hold json. If someone passed
// json, format as a single line. That way the rows corresponding to timestamps
// aren't disrupted.
Expand Down Expand Up @@ -42,9 +50,7 @@ export default component(function spanPanel() {
const $annoBody = this.$node.find('#annotations tbody').text('');
$.each((span.annotations || []), (i, anno) => {
const $row = self.$annotationTemplate.clone();
if (anno.value === Constants.ERROR) {
$row.addClass('anno-error-transient');
}
maybeMarkTransientError($row, anno);
$row.find('td').each(function() {
const $this = $(this);
const unformattedValue = anno[$this.data('key')];
Expand Down
38 changes: 38 additions & 0 deletions zipkin-ui/test/component_ui/spanPanel.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,48 @@
import {Constants} from '../../js/component_ui/traceConstants';
import {
maybeMarkTransientError,
formatAnnotationValue,
formatBinaryAnnotationValue
} from '../../js/component_ui/spanPanel';
import {endpoint, annotation} from './traceTestHelpers';

const ep = endpoint(123, 123, 'service1');

chai.config.truncateThreshold = 0;

describe('maybeMarkTransientError', () => {
const row = {
className: '',
addClass(className) {this.className = className;}
};

it('should not add class when annotation is not error', () => {
const anno = annotation(100, Constants.CLIENT_SEND, ep);

maybeMarkTransientError(row, anno);
row.className.should.equal('');
});

it('should add class when annotation is error', () => {
const anno = annotation(100, Constants.ERROR, ep);

maybeMarkTransientError(row, anno);
row.className.should.equal('anno-error-transient');
});

// uses an actual value from Finagle
it('should add class when annotation matches error', () => {
const anno = annotation(
100,
'Server Send Error: TimeoutException: socket timed out',
ep
);

maybeMarkTransientError(row, anno);
row.className.should.equal('anno-error-transient');
});
});

describe('formatAnnotationValue', () => {
it('should return same value when string', () => {
formatAnnotationValue('foo').should.equal('foo');
Expand Down