Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In cases where a SQL query does not contain an explicit FROM clause, table name appears as 'unknown' #1788

Open
JesseLaughlin opened this issue Sep 27, 2023 · 4 comments

Comments

@JesseLaughlin
Copy link

Is your feature request related to a problem? Please describe.

The issue seems to be rooted in the NodeJs agent's parsing of the SQL statement.

This line:
https://github.com/newrelic/node-newrelic/blob/main/lib/db/query-parsers/sql.js#L15
shows that the query parsing for SELECT requires a FROM clause to be included in the query.

However, it is possible to run a SELECT query without a FROM clause. For example, when using the pattern SELECT schema.FunctionName(arg1, arg2) to return a value (integer, varchar, jsonb, etc-- not a "table"), as shown here:

https://www.postgresql.org/docs/current/sql-syntax-calling-funcs.html

In this use case, the query appears in APM as "Postgres unknown select", even though the table name is visible in the query details.

This appears to have been missed in our integration tests, which all include an explicit FROM clause:

{"input":"SELECT * FROM `database`.foobar WHERE x > y", "operation":"select", "table":"foobar"},

Feature Description

We would like to see the agent's SQL regex parsing updated to handle SELECT queries without a FROM clause. We would like the table name to be displayed in the Datastore metric name, rather than unknown.

@workato-integration
Copy link

@mrickard
Copy link
Member

Thank you for the feature request, @JesseLaughlin!

@workato-integration
Copy link

@bizob2828
Copy link
Member

Internal: Sync up with .net agent. They had a community PR that allowed customers to replace the parsed collection with a sql comment for cases like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Triage Needed: Unprioritized Features
Development

No branches or pull requests

3 participants