Skip to content

Commit

Permalink
[#104] koa module MethodDescriptorBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Feb 11, 2022
1 parent 0c15fab commit c3ee77b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions test/instrumentation/module/koa.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ test(`${testName1} Should record request in basic route koa.test.js`, function (
router.get(PATH, async (ctx, next) => {
ctx.body = 'ok. get'

const trace = agent.traceContext.currentTraceObject()
setImmediate(() => {
agent.callbackTraceClose((trace) => {
let actualBuilder = new MethodDescriptorBuilder('koa', 'get')
.setParameterDescriptor('(ctx, next)')
.setLineNumber(34)
.setLineNumber(35)
.setFileName('koa.test.js')
const actualMethodDescriptor = apiMetaService.cacheApiWithBuilder(actualBuilder)
let spanEvent = trace.storage.storage[0]
})
})
router.post(PATH, async (ctx, next) => {
Expand Down
10 changes: 8 additions & 2 deletions test/support/agent-singleton-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ class MockAgent extends Agent {
shimmer.unwrap(http, 'request')
}

resetAgent(callback) {
this.pinpointClient = new MockPinpointClient(this.config, this.agentInfo, this.dataSender)
callbackTraceClose(callback) {
const trace = this.traceContext.currentTraceObject()
const origin = trace.close
trace.close = () => {
callback(trace)
origin.apply(trace, arguments)
}
}

}

const agent = new MockAgent(fixture.config)
Expand Down

0 comments on commit c3ee77b

Please sign in to comment.