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
3 changes: 3 additions & 0 deletions lib/consts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module.exports = {
MUST_COLLECT: {
ERROR: '1'
},
PROTOCOLS: {
HTTP: 'http'
}
}
2 changes: 2 additions & 0 deletions lib/instrumentations/core/http/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
collectorDataBag = {
id: requestId,
spanId: spanId,
protocol: consts.PROTOCOLS.HTTP,
host: requestParams.host,
url: util.formatDataUrl(requestParams.path),
time: clientSendTime,
Expand Down Expand Up @@ -110,6 +111,7 @@ function wrapRequest (originalHttpRequest, agent, mustCollectStore) {
var collectorDataBag = {
id: requestId,
spanId: spanId,
protocol: consts.PROTOCOLS.HTTP,
host: requestParams.host,
url: util.formatDataUrl(requestParams.path),
statusCode: incomingMessage.statusCode,
Expand Down
6 changes: 4 additions & 2 deletions lib/instrumentations/core/http/request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ describe('The http.request wrapper module', function () {
method: 'GET',
mustCollect: undefined,
time: 12345678,
url: '/'
url: '/',
protocol: 'http'
})

expect(agent.clientReceive).to.be.calledWith({
Expand All @@ -104,7 +105,8 @@ describe('The http.request wrapper module', function () {
mustCollect: undefined,
spanId: spanId,
statusCode: 200,
url: '/'
url: '/',
protocol: 'http'
})

expect(original).to.be.calledWith({
Expand Down
5 changes: 4 additions & 1 deletion lib/instrumentations/core/http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function wrapListener (listener, agent, mustCollectStore) {
url: util.formatDataUrl(requestUrl.pathname),
time: serverRecieveTime,
method: method,
protocol: consts.PROTOCOLS.HTTP,
parentId: headers['x-parent'],
originTime: headers['x-client-send']
}
Expand All @@ -76,6 +77,7 @@ function wrapListener (listener, agent, mustCollectStore) {
host: headers.host,
url: util.formatDataUrl(requestUrl.pathname),
time: serverSendTime,
protocol: consts.PROTOCOLS.HTTP,
statusCode: response.statusCode,
responseTime: responseTime
}
Expand Down Expand Up @@ -103,7 +105,8 @@ function wrapListener (listener, agent, mustCollectStore) {
response.setHeader('x-parent', serviceKey)
}

response.setHeader('x-client-send', serverSendTime)
response.setHeader('x-server-send', serverSendTime)
response.setHeader('x-server-receive', serverRecieveTime)

if (spanId) {
debug('trace event (ss); request: %s, x-span-id header has been set to: %s', requestId, spanId)
Expand Down
16 changes: 10 additions & 6 deletions lib/instrumentations/core/http/server.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ describe('The http.Server.prototype wrapper module', function () {
host: 'localhost',
originTime: undefined,
parentId: undefined,
spanId: undefined
spanId: undefined,
protocol: 'http'
})

expect(agent.serverSend).to.be.calledWith({
Expand All @@ -149,10 +150,11 @@ describe('The http.Server.prototype wrapper module', function () {
statusCode: statusCode,
time: 12345678,
url: '/',
responseTime: 0
responseTime: 0,
protocol: 'http'
})

expect(setHeaderSpy).to.be.calledWith('x-client-send', 12345678)
expect(setHeaderSpy).to.be.calledWith('x-server-send', 12345678)
expect(setHeaderSpy).to.be.calledWith('x-parent', 0)
expect(writeHeadSpy).to.be.calledOnce
})
Expand Down Expand Up @@ -200,7 +202,8 @@ describe('The http.Server.prototype wrapper module', function () {
host: 'localhost',
originTime: undefined,
parentId: undefined,
spanId: spanId
spanId: spanId,
protocol: 'http'
})

expect(agent.serverSend).to.be.calledWith({
Expand All @@ -211,11 +214,12 @@ describe('The http.Server.prototype wrapper module', function () {
mustCollect: consts.MUST_COLLECT.ERROR,
time: 12345678,
url: '/',
responseTime: 0
responseTime: 0,
protocol: 'http'
})

expect(agent.setSpanId).to.be.calledWith(spanId)
expect(setHeaderSpy).to.be.calledWith('x-client-send', 12345678)
expect(setHeaderSpy).to.be.calledWith('x-server-send', 12345678)
expect(setHeaderSpy).to.be.calledWith('x-parent', 0)
expect(setHeaderSpy).to.be.calledWith('x-span-id', spanId)
expect(setHeaderSpy).to.be.calledWith('x-must-collect', '1')
Expand Down