Skip to content

Commit

Permalink
#87 HTTP param annotation key
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed May 27, 2021
1 parent 7ee0ed7 commit f7a2cda
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions lib/instrumentation/request-header-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TransactionId = require('../context/transaction-id')
const samplingFlag = require('../sampler/sampling-flag')

class RequestHeaderUtils {
static read (request) {
static read(request) {
if (!request) {
return null
}
Expand All @@ -35,19 +35,19 @@ class RequestHeaderUtils {
return requestData
}

static readPinpointHeader (request, requestData) {
static readPinpointHeader(request, requestData) {
requestData.transactionId = TransactionId.toTransactionId(this.getHeader(request, PinpointHeader.HTTP_TRACE_ID))
if (requestData.transactionId) {
const spanId = this.getHeader(request, PinpointHeader.HTTP_SPAN_ID);
const spanId = this.getHeader(request, PinpointHeader.HTTP_SPAN_ID)
if (spanId) {
requestData.spanId = spanId
}

const parentSpanId = this.getHeader(request, PinpointHeader.HTTP_PARENT_SPAN_ID);
const parentSpanId = this.getHeader(request, PinpointHeader.HTTP_PARENT_SPAN_ID)
if (parentSpanId) {
requestData.parentSpanId = parentSpanId
}

requestData.parentApplicationName = this.getHeader(request, PinpointHeader.HTTP_PARENT_APPLICATION_NAME)
requestData.parentApplicationType = Number(this.getHeader(request, PinpointHeader.HTTP_PARENT_APPLICATION_TYPE))
requestData.flags = Number(this.getHeader(request, PinpointHeader.HTTP_FLAGS))
Expand All @@ -58,7 +58,7 @@ class RequestHeaderUtils {
return requestData
}

static getHeader (request, name) {
static getHeader(request, name) {
if (request.getHeader) {
return request.getHeader(name.toLowerCase())
}
Expand All @@ -69,7 +69,7 @@ class RequestHeaderUtils {
this.setHeader(request, PinpointHeader.HTTP_SAMPLED, samplingFlag.samplingRateFalse())
}

static write (request, agent, nextSpanId, host) {
static write(request, agent, nextSpanId, host) {
if (!agent) {
return
}
Expand All @@ -88,7 +88,7 @@ class RequestHeaderUtils {
return request
}

static setHeader (request, name, value) {
static setHeader(request, name, value) {
if (request.setHeader) {
request.setHeader(name, value)
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/instrumentation/module/express.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test(`${testName1} Should record request in basic route`, function (t) {
})

const server = app.listen(TEST_ENV.port, async function () {
const result1 = await axios.get(getServerUrl(PATH))
const result1 = await axios.get(getServerUrl(PATH) + '?api=test&test1=test')
t.ok(result1.status, 200)

const result2 = await axios.post(getServerUrl(PATH))
Expand Down

0 comments on commit f7a2cda

Please sign in to comment.