forked from elastic/apm-agent-nodejs
-
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.
…2126) * Fix elastic#1770 support for proxies in destination context Fix for elastic#1770, ensures only a single url is set
- Loading branch information
1 parent
5ba5bb0
commit 49f48e6
Showing
3 changed files
with
54 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const agent = require('../..').start({ | ||
serviceName: 'test', | ||
secretToken: 'test', | ||
centralConfig: false, | ||
metricsInterval: 0 | ||
}) | ||
|
||
const tape = require('tape') | ||
const http = require('http') | ||
const mockClient = require('../_mock_http_client') | ||
|
||
function resetAgent (cb) { | ||
agent._transport = mockClient(3, cb) | ||
} | ||
|
||
tape.test('span url contains single url', function (t) { | ||
resetAgent(function (results) { | ||
t.equals(results.spans.length, 1, 'one span') | ||
|
||
const span = results.spans.pop() | ||
const url = span.context.http.url | ||
|
||
// ensure url is not in the form | ||
// http://127.0.0.1:59281http://127.0.0.1/foo | ||
t.equals(url, 'http://127.0.0.1/foo', 'records single url only') | ||
t.end() | ||
}) | ||
const server = http.createServer(function (req, res) { | ||
res.end('hello') | ||
}) | ||
server.unref() | ||
server.listen(0, '0.0.0.0', () => { | ||
const port = server.address().port | ||
agent.startTransaction() | ||
const opts = { | ||
host: '127.0.0.1', | ||
port, | ||
method: 'GET', | ||
path: 'http://127.0.0.1/foo' | ||
} | ||
const client = http.request(opts) | ||
client.end() | ||
agent.endTransaction() | ||
}) | ||
}) |