r/SQLServer • u/downshiftdata • Feb 23 '26
Question Datadog Config Question
Does anyone know if you can configure Datadog to not strip comments from queries from SQL Server that show up in the Query Metrics view? My pattern with ad hoc inside stored procedures is to prepend it with a comment containing the name of the stored procedure that generated it, and this info is lost by the time I can see it in Datadog.
4
Upvotes
•
u/AutoModerator Feb 23 '26
After your question has been solved /u/downshiftdata, please reply to the helpful user's comment with the phrase "Solution verified".
This will not only award a point to the contributor for their assistance but also update the post's flair to "Solved".
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/VladDBA Microsoft MVP Feb 23 '26 edited Feb 23 '26
Sounds like a Datadog issue. DMVs store comments as part of the query text for both ad-hoc queries and queries comming from stored procedures and functions.
Edited to add:
You can use stored procedures like sp_BlitzCache (to pull stuff from the plan cache) or sp_QuickieStore (to pull data from the Query Store) and they'll return query text intact with comments.
And then match that info with what you see in Datadog (which kinda defeats the purpose, but if Datadog won't fix their stuff...)
Just note that for sp_BlitzCache you'll have to specify KeepCRLF = 1 to retain new lines in case you have single line comments (--) instead of block comments (/* something */).
3
u/razzledazzled Feb 23 '26
I haven’t had success. It sucks because one of the chief complaints from the dba team is that the Entity Framework generated queries are difficult to understand once they reach a threshold of complexity. So to help with this I wanted to try and “tag” important EF queries with a string comment to tie back to the code base Linq query that spawns it… but wasn’t able to get it working
1
u/turimbar1 Feb 23 '26
It probably gathers the queries from the DMV's which strip most comments
1
u/Black_Magic100 Feb 24 '26
OP, when you say "adhoc inside stored procedure" I'm assuming you are referring to Dynamic SQL? If so, you may need to string build the comment into the 2nd line of the dynamic SQL.
-2
u/B1zmark 1 Feb 23 '26
Comments aren't parsed, that's the point. They are ignored entirely. If the weren't ignored they wouldn't be code comments. They would be code. And the engine would need to process it to understand if it needs to take action or not.