forked from pinpoint-apm/pinpoint-node-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pinpoint-apm#140] Support nested async trace
- Loading branch information
Showing
2 changed files
with
64 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Pinpoint Node.js Agent | ||
* Copyright 2020-present NAVER Corp. | ||
* Apache License v2.0 | ||
*/ | ||
|
||
const test = require('tape') | ||
const agent = require('../../support/agent-singleton-mock') | ||
const express = require('express') | ||
const axios = require('axios') | ||
const MethodDescriptorBuilder = require('../../../lib/context/method-descriptor-builder') | ||
const apiMetaService = require('../../../lib/context/api-meta-service') | ||
const { expected } = require('../../fixtures/instrument-support') | ||
|
||
test(`nested mysql async query with express`, async (t) => { | ||
agent.bindHttpWithCallSite() | ||
|
||
const app = new express() | ||
app.get('/test1', (req, res) => { | ||
res.send('ok get') | ||
|
||
agent.callbackTraceClose((trace) => { | ||
const actualBuilder = new MethodDescriptorBuilder(expected('get', 'app.get')) | ||
.setClassName(expected('app', 'Function')) | ||
.setLineNumber(19) | ||
.setFileName('nested-async-trace.test.js') | ||
const actualMethodDescriptor = apiMetaService.cacheApiWithBuilder(actualBuilder) | ||
const actualSpanEvent = trace.span.spanEventList[0] | ||
t.equal(actualMethodDescriptor.apiId, actualSpanEvent.apiId, 'apiId is equal') | ||
}) | ||
}) | ||
|
||
const server = app.listen(5006, async () => { | ||
const result = await axios.get('http://localhost:5006/test1') | ||
t.equal(result.status, 200, 'status is 200') | ||
|
||
t.end() | ||
server.close() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters