Skip to content

Commit

Permalink
fix: Dropped query params when obfuscating (#1719)
Browse files Browse the repository at this point in the history
Signed-off-by: mrickard <maurice@mauricerickard.com>
  • Loading branch information
mrickard committed Jul 12, 2023
1 parent 20442c6 commit 76112a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/instrumentation/core/http.js
Expand Up @@ -86,7 +86,7 @@ function wrapEmitWithTransaction(agent, emit, isHTTPS) {

// the error tracer needs a URL for tracing, even though naming overwrites
transaction.parsedUrl = url.parse(request.url, true)
transaction.url = urltils.obfuscatePath(agent.config, transaction.parsedUrl.path)
transaction.url = urltils.obfuscatePath(agent.config, transaction.parsedUrl.pathname)
transaction.verb = request.method

// URL is sent as an agent attribute with transaction events
Expand Down
22 changes: 22 additions & 0 deletions test/unit/instrumentation/http/http.test.js
Expand Up @@ -351,6 +351,28 @@ test('built-in http module instrumentation', (t) => {
}
})

t.test('request.uri should not contain request params', (t) => {
transaction = null
makeRequest(
{
port: 8123,
host: 'localhost',
path: '/foo5/bar5?region=here&auth=secretString',
method: 'GET'
},
finish
)

function finish() {
const segment = transaction.baseSegment
const spanAttributes = segment.attributes.get(DESTINATIONS.SPAN_EVENT)

t.equal(spanAttributes['request.uri'], '/foo5/bar5')

t.end()
}
})

t.test('successful request', (t) => {
transaction = null
const refererUrl = 'https://www.google.com/search/cats?scrubbed=false'
Expand Down

0 comments on commit 76112a6

Please sign in to comment.