Skip to content
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
5 changes: 5 additions & 0 deletions src/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ function extractTags (trace, tags) {
case 'resource.name':
trace[map[tag]] = String(tags[tag])
break
case 'error':
if (tags[tag]) {
trace.error = 1
}
break
case 'error.type':
case 'error.msg':
case 'error.stack':
Expand Down
28 changes: 27 additions & 1 deletion test/format.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,33 @@ describe('format', () => {
expect(trace.meta['error.stack']).to.equal(span._error.stack)
})

it('should set the error flag when there is an error tag', () => {
describe('when there is an `error` tag ', () => {
it('should set the error flag when error tag is true', () => {
span._tags['error'] = true

trace = format(span)

expect(trace.error).to.equal(1)
})

it('should not set the error flag when error is false', () => {
span._tags['error'] = false

trace = format(span)

expect(trace.error).to.equal(0)
})

it('should not extract error to meta', () => {
span._tags['error'] = true

trace = format(span)

expect(trace.meta['error']).to.be.undefined
})
})

it('should set the error flag when there is an error-related tag', () => {
span._tags['error.type'] = 'Error'
span._tags['error.msg'] = 'boom'
span._tags['error.stack'] = ''
Expand Down