Skip to content

Commit 396464b

Browse files
Merge pull request #3103 from newrelic/request-uri
Add request.uri to transaction events
2 parents 64a5e3f + bd09592 commit 396464b

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# New Relic Ruby Agent Release Notes
22

3+
## dev
4+
5+
- **Bugfix: Include request.uri in Transaction events by default**
6+
7+
[The New Relic data dictionary expects Transaction events to have the `request.uri` attribute.](https://docs.newrelic.com/attribute-dictionary/?event=Transaction&attribute=request.uri) The Ruby agent now fulfills this expectation. If you would like to exclude `request.uri` from Transaction events, you can do so by setting `transaction_events.attributes.exclude` to `'request.uri'`. [PR#3103](https://github.com/newrelic/newrelic-ruby-agent/pull/3103)
8+
39
## v9.18.0
410

511
- **Feature: Add elasticsearch.capture_cluster_name configuration option**

lib/new_relic/agent/transaction/request_attributes.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ def assign_agent_attributes(txn)
4343
end
4444

4545
if request_path
46-
destinations = if allow_other_headers?
47-
default_destinations
48-
else
49-
AttributeFilter::DST_TRANSACTION_TRACER | AttributeFilter::DST_ERROR_COLLECTOR
50-
end
51-
txn.add_agent_attribute(:'request.uri', request_path, destinations)
46+
txn.add_agent_attribute(:'request.uri', request_path, default_destinations)
5247
end
5348

5449
if accept

test/multiverse/suites/agent_only/agent_attributes_test.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_request_uri_collected_on_default_destinations
226226
assert_transaction_trace_has_agent_attribute('request.uri', '/foobar')
227227

228228
assert_error_has_agent_attribute('request.uri', '/foobar')
229-
refute_event_has_agent_attribute('request.uri')
229+
assert_event_has_agent_attribute('request.uri', '/foobar')
230230
refute_browser_monitoring_has_agent_attribute('request.uri')
231231
end
232232

@@ -242,8 +242,8 @@ def test_request_uri_can_be_disabled_on_tts
242242
refute last_transaction_trace.uri
243243

244244
assert_error_has_agent_attribute('request.uri', '/foobar')
245+
assert_event_has_agent_attribute('request.uri', '/foobar')
245246
refute_transaction_trace_has_agent_attribute('request.uri')
246-
refute_event_has_agent_attribute('request.uri')
247247
refute_browser_monitoring_has_agent_attribute('request.uri')
248248
end
249249

@@ -259,8 +259,8 @@ def test_request_uri_can_be_disabled_on_error_traces
259259
refute last_error_trace.params['agentAttributes']['request.uri']
260260

261261
assert_transaction_trace_has_agent_attribute('request.uri', '/foobar')
262+
assert_event_has_agent_attribute('request.uri', '/foobar')
262263
refute_error_has_agent_attribute('request.uri')
263-
refute_event_has_agent_attribute('request.uri')
264264
refute_browser_monitoring_has_agent_attribute('request.uri')
265265
end
266266

test/multiverse/suites/grape/grape_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def test_request_and_response_attributes_recorded_as_agent_attributes
222222
'request.headers.contentLength' => last_request.content_length.to_i,
223223
'request.headers.contentType' => last_request.content_type,
224224
'request.headers.host' => last_request.host,
225-
'request.method' => last_request.request_method
225+
'request.method' => last_request.request_method,
226+
'request.uri' => last_request.path_info
226227
}
227228
actual = agent_attributes_for_single_event_posted_without_ignored_attributes
228229

test/multiverse/suites/rails/parameter_capture_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ def test_request_and_response_attributes_recorded_as_agent_attributes
257257
'response.headers.contentType' => "#{response.content_type}; charset=#{response.charset}",
258258
'request.headers.contentLength' => request.content_length.to_i,
259259
'request.headers.host' => request.host,
260-
'request.headers.accept' => request.accept
260+
'request.headers.accept' => request.accept,
261+
'request.uri' => request.path_info
261262
}
262263

263264
if request.content_type

test/multiverse/suites/sinatra/sinatra_parameter_capture_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def test_request_and_response_attributes_recorded_as_agent_attributes
7373
'request.headers.contentLength' => last_request.content_length.to_i,
7474
'request.headers.contentType' => last_request.content_type,
7575
'request.headers.host' => last_request.host,
76-
'request.method' => last_request.request_method
76+
'request.method' => last_request.request_method,
77+
'request.uri' => last_request.path_info
7778
}
7879
actual = agent_attributes_for_single_event_posted_without_ignored_attributes
7980

0 commit comments

Comments
 (0)