Skip to content

Commit 8dd557b

Browse files
authored
fix: Updated api.recordLogEvent to no longer truncate the message key in log event (#2949)
Thanks for your contribution @rChaoz 🎉
1 parent 888cfe8 commit 8dd557b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

api.js

-1
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,6 @@ API.prototype.recordLogEvent = function recordLogEvent(logEvent = {}) {
513513
)
514514
return
515515
}
516-
logEvent.message = applicationLogging.truncate(logEvent.message)
517516

518517
if (!logEvent.level) {
519518
logger.debug('no log level set, setting it to UNKNOWN')

test/unit/api/api-record-log-events.test.js

+17
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,23 @@ test('Agent API - recordCustomEvent', async (t) => {
156156
assert.equal(apiMetric.callCount, 1, 'and one API call was counted anyway')
157157
end()
158158
})
159+
160+
await t.test('it works with large JSON log messages', (t, end) => {
161+
const { agent, api } = t.nr
162+
const json = JSON.stringify({
163+
message: message.repeat(100),
164+
nested: {
165+
prop1: 123,
166+
prop2: 'a string',
167+
},
168+
array: Array.from({ length: 1000 }, (_, i) => 'item number ' + i),
169+
nonPrimitive: new Date(),
170+
})
171+
api.recordLogEvent({ message: json })
172+
const logEvent = popTopLogMessage(agent)
173+
assert.equal(logEvent.message, json)
174+
end()
175+
})
159176
})
160177

161178
test('does not collect logs when high security mode is on', (_t, end) => {

0 commit comments

Comments
 (0)