This repository has been archived by the owner on Aug 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
16 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
42 changes: 42 additions & 0 deletions
42
packages/hook/test/fixtures/http-when-request-abort/index.ts
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,42 @@ | ||
import { RunUtil } from '../../RunUtil'; | ||
import * as assert from 'assert'; | ||
import { HttpServerPatcher } from '../../../src/patch/HttpServer'; | ||
|
||
const httpServerPatcher = new HttpServerPatcher(); | ||
|
||
RunUtil.run(function(done) { | ||
httpServerPatcher.run(); | ||
const http = require('http'); | ||
const httpclient = require('urllib').create(); | ||
|
||
process.on(<any> 'PANDORA_PROCESS_MESSAGE_TRACE', (report: any) => { | ||
assert(report.name === 'HTTP-GET:/'); | ||
assert(report.spans.length === 1); | ||
assert(report.duration <= 1000); | ||
const span = report.spans[0]; | ||
const tag = span.tags['http.aborted']; | ||
assert(tag.value); | ||
|
||
done(); | ||
}); | ||
|
||
const server = http.createServer((req, res) => { | ||
|
||
setTimeout(function() { | ||
res.end('hello'); | ||
}, 3000); | ||
|
||
}); | ||
|
||
server.listen(0, () => { | ||
const port = server.address().port; | ||
|
||
const req = httpclient.request(`http://localhost:${port}`, function(err, body) { | ||
console.log('body size: %d', body.length); | ||
}); | ||
|
||
setTimeout(function() { | ||
req.abort(); | ||
}, 1000); | ||
}); | ||
}); |
8 changes: 8 additions & 0 deletions
8
packages/hook/test/fixtures/http-when-request-abort/package.json
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,8 @@ | ||
{ | ||
"name": "http-trace-test", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"dependencies": { | ||
"urllib": "^2.25.1" | ||
} | ||
} |
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
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