Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix http plugin url tag and agent requests being traced #883

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/datadog-plugin-http/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ function patch (http, methodName, tracer, config) {
return request.apply(this, arguments)
}

const uri = args.uri
const options = args.options
const hostname = options.hostname || options.host || 'localhost'
const host = options.port ? `${hostname}:${options.port}` : hostname
const path = options.path ? options.path.split(/[?#]/)[0] : '/'
const uri = `${options.protocol}//${host}${path}`

let callback = args.callback

Expand Down Expand Up @@ -188,7 +191,7 @@ function patch (http, methodName, tracer, config) {
'localhost',
hash: url.hash,
search: url.search,
pathname: url.pathname || url.path || '/',
pathname: url.pathname,
path: `${url.pathname || ''}${url.search || ''}`,
href: url.href
}
Expand Down
4 changes: 2 additions & 2 deletions packages/datadog-plugin-http/test/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Plugin', () => {

describe('without configuration', () => {
beforeEach(() => {
return agent.load('http')
return agent.load('http', { server: false })
.then(() => {
http = require(protocol)
express = require('express')
Expand Down Expand Up @@ -131,7 +131,7 @@ describe('Plugin', () => {
protocol: `${protocol}:`,
hostname: 'localhost',
port,
pathname: '/user'
path: '/user'
}

appListener = server(app, port, () => {
Expand Down