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
31 changes: 19 additions & 12 deletions test/lib/logging-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
*/

'use strict'
const helpers = module.exports
const tap = require('tap')

tap.Test.prototype.addAssert('validateAnnotations', 2, validateLogLine)
const assert = require('node:assert')

// NOTE: pino adds hostname to log lines which is why we don't check it here
helpers.CONTEXT_KEYS = [
const CONTEXT_KEYS = [
'entity.name',
'entity.type',
'entity.guid',
Expand All @@ -23,21 +21,30 @@ helpers.CONTEXT_KEYS = [
* To be registered as a tap assertion
*/
function validateLogLine({ line: logLine, message, level, config }) {
this.equal(
assert.equal(
logLine['entity.name'],
config.applications()[0],
'should have entity name that matches app'
)
this.equal(logLine['entity.guid'], 'test-guid', 'should have set entitye guid')
this.equal(logLine['entity.type'], 'SERVICE', 'should have entity type of SERVICE')
this.equal(logLine.hostname, config.getHostnameSafe(), 'should have proper hostname')
this.match(logLine.timestamp, /[0-9]{10}/, 'should have proper unix timestamp')
this.notOk(logLine.message.includes('NR-LINKING'), 'should not contain NR-LINKING metadata')
assert.equal(logLine['entity.guid'], 'test-guid', 'should have set entity guid')
assert.equal(logLine['entity.type'], 'SERVICE', 'should have entity type of SERVICE')
assert.equal(logLine.hostname, config.getHostnameSafe(), 'should have proper hostname')
assert.equal(/[0-9]{10}/.test(logLine.timestamp), true, 'should have proper unix timestamp')
assert.equal(
logLine.message.includes('NR-LINKING'),
false,
'should not contain NR-LINKING metadata'
)
if (message) {
this.equal(logLine.message, message, 'message should be the same as log')
assert.equal(logLine.message, message, 'message should be the same as log')
}

if (level) {
this.equal(logLine.level, level, 'level should be string value not number')
assert.equal(logLine.level, level, 'level should be string value not number')
}
}

module.exports = {
CONTEXT_KEYS,
validateLogLine
}
271 changes: 0 additions & 271 deletions test/versioned/bunyan/bunyan.tap.js

This file was deleted.

Loading
Loading