newrelic-dotnet-agent icon indicating copy to clipboard operation
newrelic-dotnet-agent copied to clipboard

SQL Parsing: Prioritize nested FROM dbo.spStoredProcedure from compound statement

Open rdhar opened this issue 4 years ago • 2 comments
trafficstars

Description

For nested/compound SQL statements, these are reported as "other" instead of the DB name called. This follows on from @elucus's #224 that was resolved by @nr-ahemsath in #370, and has been greatly appreciated by my organization as we can finally see most calls reporting to the actual table (thank you!).

Expected Behaviour

For example, here's one of our real examples which reports as "other" instead of "dbo.spStoredProcedure".

SET NOCOUNT ON; SET CONTEXT_INFO @ContextInfo; WITH T AS (SELECT [Status], row_number() over (ORDER BY [Description] asc) as row_asc FROM dbo.spStoredProcedure WHERE [Status] = @0), TWithRow as (SELECT *, row_number() over (ORDER BY row_asc DESC) as row_dsc FROM T) SELECT * FROM TWithRow WHERE row_asc between @MinRow and @MaxRow;

Additional Context

This was discovered with .NET agent v8.39.2.0. Happy to share more details about our environment, as required.

Thank you for your time.

rdhar avatar Jul 17 '21 14:07 rdhar

Hey @rdhar, thanks for report!

It does seem like the Agent could feasibly support these WITH CTE commands, instead pulling out the query itself to parse that, though it will take a little doing on our part.

I've added this to our backlog - I'd advise anyone interested in this feature giving it a 👍 to help us prioritize it accordingly!

tehbio avatar Jul 20 '21 22:07 tehbio

Thanks for the follow-up, @tehbio, I wasn't aware that common_table_expression could help support parsing of these kinds of queries. 👍

rdhar avatar Jul 23 '21 09:07 rdhar

https://issues.newrelic.com/browse/NEWRELIC-8441

This issue won't be actioned.