Skip to content

Remove CAT#1489

Open
lrafeei wants to merge 135 commits intodevelop-v12.0.0from
remove_CAT
Open

Remove CAT#1489
lrafeei wants to merge 135 commits intodevelop-v12.0.0from
remove_CAT

Conversation

@lrafeei
Copy link
Contributor

@lrafeei lrafeei commented Sep 12, 2025

This PR removes Cross Application Tracing (CAT) from the agent

@lrafeei lrafeei changed the base branch from main to develop-11.0.0 September 12, 2025 02:16
@mergify mergify bot added the merge-conflicts Merge conflicts detected. label Sep 12, 2025
@github-actions
Copy link

github-actions bot commented Sep 12, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 1.11s
✅ MARKDOWN markdownlint 7 0 0 0 1.48s
✅ PYTHON ruff 961 0 0 0 1.15s
✅ PYTHON ruff-format 961 0 0 0 0.34s
✅ YAML prettier 15 0 0 0 1.66s
✅ YAML v8r 15 0 0 5.26s
✅ YAML yamllint 15 0 0 0.67s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Sep 12, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 92.53731% with 5 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (develop-v12.0.0@2c71e17). Learn more about missing BASE report.

Files with missing lines Patch % Lines
newrelic/hooks/framework_aiohttp.py 83.33% 3 Missing ⚠️
newrelic/hooks/framework_sanic.py 33.33% 2 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             develop-v12.0.0    #1489   +/-   ##
==================================================
  Coverage                   ?   81.74%           
==================================================
  Files                      ?      210           
  Lines                      ?    24361           
  Branches                   ?     3824           
==================================================
  Hits                       ?    19913           
  Misses                     ?     3144           
  Partials                   ?     1304           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot removed the merge-conflicts Merge conflicts detected. label Sep 12, 2025
@mergify mergify bot removed the tests-failing Tests failing in CI. label Oct 24, 2025
mergify bot and others added 3 commits October 24, 2025 05:05
Good call--this is still needed for synthetics

Co-authored-by: Hannah Stepanek <hstepanek@newrelic.com>
@mergify mergify bot added the tests-failing Tests failing in CI. label Nov 18, 2025
@TimPansino TimPansino self-assigned this Nov 24, 2025
Comment on lines -79 to -82
def _nr_process_response(response, transaction):
nr_headers = transaction.process_response(response.status, response.headers)

response._headers.update(nr_headers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of instrumentation removed from this file, but we still need it. We should be calling process_response to capture the status code for web transactions and the headers as agent attributes.

# limitations under the License.

import asyncio

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably rename this file to just test_client.py now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we have a test_server_dt.py but no corresponding tests for outbound DT headers in the aiohttp client. We should add tests from this, as we've just removed the test_client_cat.py file that has the only thing remotely resembling tests for this.

@@ -52,7 +51,8 @@ def task(loop, method, exc_expected, url):
assert isinstance(text_list[0], _expected_error_class), text_list[0].__class__
assert isinstance(text_list[1], _expected_error_class), text_list[1].__class__
else:
assert text_list[0] == text_list[1], text_list
assert text_list[0]
Copy link
Contributor

@TimPansino TimPansino Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this fine? Shouldn't we be keeping the behavior of these assertions? (Context: #1489 (comment))

@@ -381,9 +356,6 @@ async def _coro(*_args, **_kwargs):

def instrument_aiohttp_web(module):
global _nr_process_response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
global _nr_process_response

Comment on lines 262 to 274
@@ -279,16 +263,13 @@ async def _coro():
response = await wrapped(*args, **kwargs)

try:
trace.process_response_headers(response.headers.items())
trace.process_response(status_code=response.status)
except:
pass

return response
except Exception as e:
try:
trace.process_response_headers(e.headers.items())
except:
pass
except Exception:
notice_error()

raise
Copy link
Contributor

@TimPansino TimPansino Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to call notice_error here necessarily, it's not equivalent to what we had before. I think this outer try/except can be deleted and we end up with just the success case.

response = await wrapped(*args, **kwargs)

try:
    trace.process_response(status_code=response.status)
except:
    pass

return response

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lrafeei Github was fighting me trying to suggest too many things so I pushed it as a commit, see if you agree with everything here. ad3d4e6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any issues with that commit


flat_event = _flatten(event)

assert "nr.guid" in flat_event, f"name=nr.guid, event={flat_event!r}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be deleted


apdex_perf_zone = self.apdex_perf_zone()
_add_if_not_empty("apdexPerfZone", apdex_perf_zone)
_add_if_not_empty("nr.apdexPerfZone", apdex_perf_zone)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we confident this isn't used in the UI anywhere?

Comment on lines 3119 to 3124
_process_module_definition(
"aiohttp.web_reqrep", "newrelic.hooks.framework_aiohttp", "instrument_aiohttp_web_response"
)
_process_module_definition(
"aiohttp.web_response", "newrelic.hooks.framework_aiohttp", "instrument_aiohttp_web_response"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we still need these?

assert intrinsics["error.class"] == required_attrs["error.class"]
assert intrinsics["error.message"].startswith(required_attrs["error.message"])
assert intrinsics["error.expected"] == required_attrs["error.expected"]
assert intrinsics["nr.transactionGuid"] is not None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell this still exists and we need this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Even though this was initially a CAT attribute, it is also used for error events.

# Test default settings.

_expected_attributes = {"agent": TRACE_ERROR_AGENT_KEYS, "user": ERROR_USER_ATTRS, "intrinsic": ["trip_id"]}
_expected_attributes = {"agent": TRACE_ERROR_AGENT_KEYS, "user": ERROR_USER_ATTRS, "intrinsic": ["guid"]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these changes where we deleted trip_id are breaking this file, it's supposed to test for the behavior of intrinsics. I replaced them all with guid and that should solve all those issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests-failing Tests failing in CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants