diff --git a/src/format.js b/src/format.js index 9661925c21b..1c5d7adcd20 100644 --- a/src/format.js +++ b/src/format.js @@ -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': diff --git a/test/format.spec.js b/test/format.spec.js index 3fc52241a70..1d64b7891e5 100644 --- a/test/format.spec.js +++ b/test/format.spec.js @@ -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'] = ''