open-telemetry / opentelemetry-ruby-contrib

Contrib Packages for the OpenTelemetry Ruby API and SDK implementation.
https://opentelemetry.io
Apache License 2.0
86 stars 174 forks source link

fix: get correct table name if table name is quoted #1234

Closed HielkeJ closed 4 days ago

HielkeJ commented 3 weeks ago

TABLE_NAME is extracted if the table name is quoted. Should fix #1173

hannahramadan commented 2 weeks ago

Thanks @HielkeJ!

I'm wondering if we should remove the single quotes from the regex. @mostfunkyduck pointed out that single quotes are for string literals, not identifiers. What do you think @arielvalentin @scbjans

New Relic does not have this implemented and I didn't see others who did, so unfortunately not a lot to compare to.

scbjans commented 2 weeks ago

Thanks for pointing that out, I somehow read past that. After reading those docs, I agree that the single quotes should be removed from the regex, since those aren't for identifiers.

HielkeJ commented 2 weeks ago

I did a small update in the PR @hannahramadan. If I try in Postgres to to a select SELECT * FROM 'table', it returns a syntax error. I didn't test if it fails in opentelemetry-ruby-contrib as well with a syntax error, but at least in shouldn't run the query.

arielvalentin commented 2 weeks ago

Given this new information I'm going to rescind my approval and scrutinize this a little more.

I'll leave the final approval to some other folks.