Skip to content

Commit

Permalink
[#190] Remove JSON.stringify on Info the Logger
Browse files Browse the repository at this point in the history
Update Demo App for jade deprecated to pug
  • Loading branch information
feelform committed May 13, 2024
1 parent 0810f79 commit 71abe60
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 43 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to Pinpoint Node.js agent will be documented in this file.

## [0.8.5] - 2024-05-13
### Fixed
- #190 Remove JSON.stringify on Info Logger

## [0.8.4] - 2024-05-03
### Changed
- #186 Change error log level to info log
Expand Down
2 changes: 1 addition & 1 deletion demo/express/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.set('view engine', 'pug');

app.use(logger('dev'));
app.use(express.json());
Expand Down
8 changes: 4 additions & 4 deletions demo/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"start": "node ./bin/www"
},
"dependencies": {
"axios": "^0.19.2",
"axios": "^1.6.8",
"cookie-parser": "~1.4.4",
"debug": "~2.6.9",
"express": "~4.16.1",
"express": "^4.19.2",
"http-errors": "~1.6.3",
"ioredis": "^4.17.3",
"jade": "~1.11.0",
"morgan": "~1.9.1",
"pinpoint-node-agent": "^0.7.0-rc.0"
"pinpoint-node-agent": "^0.8.5-next.2",
"pug": "^3.0.2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/client/grpc-bidirectional-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class GrpcBidirectionalStream {
})
stream.on('error', (e) => {
if (log.isDebug() && e && name) {
log.debug(`GrpcBidirectionalStream stream on error. ${name} on(error): ${JSON.stringify(e)}`)
log.debug(`GrpcBidirectionalStream stream on error. ${name} on(error): ${e}`)
}
})
stream.on('status', (status) => {
if (log.isDebug() && status && name) {
log.debug(`GrpcBidirectionalStream stream data. ${name} on(status): ${JSON.stringify(status)}`)
log.debug(`GrpcBidirectionalStream stream data. ${name} on(status): ${status}`)
}
})
return stream
Expand Down
4 changes: 2 additions & 2 deletions lib/client/grpc-client-side-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ class GrpcClientSideStream {
})
stream.on('error', (e) => {
if (log.isDebug() && e && name) {
log.debug(`GrpcClientSideStream stream on error. ${name} on(error): ${JSON.stringify(e)}`)
log.debug(`GrpcClientSideStream stream on error. ${name} on(error): ${e}`)
}
})
stream.on('status', (status) => {
if (log.isDebug() && status && name) {
log.debug(`GrpcClientSideStream stream data. ${name} on(status): ${JSON.stringify(status)}`)
log.debug(`GrpcClientSideStream stream data. ${name} on(status): ${status}`)
}
})
return stream
Expand Down
24 changes: 0 additions & 24 deletions lib/client/grpc-data-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,6 @@ class GrpcDataSender {

sendAgentInfo(agentInfo, callback) {
const pAgentInfo = dataConvertor.convertAgentInfo(agentInfo)
if (log.isDebug()) {
log.debug(`sendAgentInfo pAgentInfo: ${JSON.stringify(pAgentInfo.toObject())}`)
}
this.requestAgentInfo.request(pAgentInfo, (err, response) => {
if (callback) {
callback(err, response)
Expand All @@ -134,9 +131,6 @@ class GrpcDataSender {

sendApiMetaInfo(apiMetaInfo, callback) {
const pApiMetaData = dataConvertor.convertApiMetaInfo(apiMetaInfo)
if (log.isDebug()) {
log.debug(`sendApiMetaInfo pApiMetaData: ${JSON.stringify(pApiMetaData.toObject())}`)
}
this.requestApiMetaData.request(pApiMetaData, (err, response) => {
if (err) {
log.error(err)
Expand All @@ -149,9 +143,6 @@ class GrpcDataSender {

sendStringMetaInfo(stringMetaInfo, callback) {
const pStringMetaData = dataConvertor.convertStringMetaInfo(stringMetaInfo)
if (log.isDebug()) {
log.debug(`sendStringMetaInfo pStringMetaData: ${JSON.stringify(pStringMetaData.toObject())}`)
}
this.requestStringMetaData.request(pStringMetaData, (err, response) => {
if (err) {
log.error(err)
Expand All @@ -165,9 +156,6 @@ class GrpcDataSender {
sendSpan(span) {
try {
const pSpan = span.spanMessage
if (log.isDebug()) {
log.debug(`sendSpan pSpan: ${JSON.stringify(pSpan.toObject())}`)
}
this.spanStream.write(pSpan)
} catch (e) {
if (e && e.stack) {
Expand All @@ -179,9 +167,6 @@ class GrpcDataSender {
sendSpanChunk(spanChunk) {
try {
const pSpanChunk = spanChunk.spanMessage
if (log.isDebug()) {
log.debug(`sendSpanChunk pSpanChunk: ${JSON.stringify(pSpanChunk.toObject())}`)
}
this.spanStream.write(pSpanChunk)
} catch (e) {
if (e && e.stack) {
Expand All @@ -193,9 +178,6 @@ class GrpcDataSender {
sendStat(stat) {
try {
const pStatMessage = dataConvertor.convertStat(stat)
if (log.isDebug()) {
log.debug(`sendStats pStatMessage: ${JSON.stringify(stat)}`)
}
this.statStream.write(pStatMessage)
} catch (e) {
if (e && e.stack) {
Expand All @@ -206,17 +188,11 @@ class GrpcDataSender {

sendControlHandshake(params) {
const pCmdMessage = dataConvertor.convertCmdMessage(params)
if (log.isDebug()) {
log.debug(`sendControlHandshake pCmdMessage: ${JSON.stringify(pCmdMessage.toObject())}`)
}
this.profilerStream.write(pCmdMessage)
}

sendPing() {
const pPing = dataConvertor.convertPing()
if (log.isDebug()) {
log.debug(`sendPing pPing: ${JSON.stringify(pPing)}`)
}
this.pingStream.write(pPing)
}

Expand Down
9 changes: 0 additions & 9 deletions lib/instrumentation/http-shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ exports.instrumentRequest = function (agent, moduleName) {
return function (original) {
return function (event, req, res) {
if (event === 'request') {
if (log.isInfo()) {
log.info('instrumentRequest in http-shared.js ' + JSON.stringify(req))
}

const requestData = RequestHeaderUtils.read(req)
if (!getPathMatcher().matchPath(requestData.rpcName)) {
const trace = agent.createTraceObject(requestData)
Expand All @@ -47,9 +43,6 @@ exports.instrumentRequest = function (agent, moduleName) {
}

endOfStream(res, function (err) {
if (log.isInfo()) {
log.info('endOfStream in http-shared.js ' + JSON.stringify(res))
}
if (!err) {
if (trace && trace.canSampled()) {
trace.spanRecorder.recordAttribute(DefaultAnnotationKey.HTTP_STATUS_CODE, this.statusCode)
Expand Down Expand Up @@ -131,7 +124,6 @@ exports.traceOutgoingRequest = function (agent, moduleName) {
return req

function onresponse(res) {
log.debug('intercepted http.ClientcRequest response event %o', {id: httpURL})
// Inspired by:
// https://github.com/nodejs/node/blob/9623ce572a02632b7596452e079bba066db3a429/lib/events.js#L258-L274
if (res.prependListener) {
Expand All @@ -151,7 +143,6 @@ exports.traceOutgoingRequest = function (agent, moduleName) {
}

function onEnd() {
log.debug('intercepted http.IncomingMessage end event %o', {id: httpURL})
if (asyncTrace) {
asyncEventRecorder.recordAttribute(DefaultAnnotationKey.HTTP_STATUS_CODE, this.statusCode)
asyncTrace.traceAsyncEnd(asyncEventRecorder)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pinpoint-node-agent",
"version": "0.8.4",
"version": "0.8.5",
"main": "index.js",
"scripts": {
"test": "tape ./test/**/*.test.js",
Expand Down

0 comments on commit 71abe60

Please sign in to comment.