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

dbapi2 fails to extract table name when using square brackets #1929

Closed
anderssonjohan opened this issue Oct 31, 2023 · 2 comments · Fixed by #1947
Closed

dbapi2 fails to extract table name when using square brackets #1929

anderssonjohan opened this issue Oct 31, 2023 · 2 comments · Fixed by #1947
Labels

Comments

@anderssonjohan
Copy link
Contributor

Describe the bug: ...

Queries made to tables which requires escaping end up with the wrong span name.

The following spans are SELECTs from four different tables, but only two unique span names appear.
Screenshot 2023-10-31 at 19 13 46

To Reproduce

Import package and call extract_signature:

>>> from elasticapm.instrumentation.packages import dbapi2
>>> dbapi2.extract_signature("SELECT username FROM user")
'SELECT FROM user'
>>> dbapi2.extract_signature("SELECT username FROM [user]")
'SELECT FROM ['

Environment (please complete the following information)

  • OS: [e.g. Linux]
  • Python version:
  • Framework and version [e.g. Django 2.1]:
  • APM Server version:
  • Agent version:

Additional context

Add any other context about the problem here.

  • Agent config options

    Click to expand
    replace this line with your agent config options
    remember to mask any sensitive fields like tokens
    
  • requirements.txt:

    Click to expand
    replace this line with your `requirements.txt`
    
@github-actions github-actions bot added agent-python community Issues opened by the community triage Issues awaiting triage labels Oct 31, 2023
@basepi basepi added bug good first issue and removed triage Issues awaiting triage labels Oct 31, 2023
@aless10
Copy link
Contributor

aless10 commented Nov 24, 2023

Hi, I would like to contribute and give it a try to fix this

@anderssonjohan
Copy link
Contributor Author

@aless10 I'm touching the same thing in this PR. Perhaps you will find my parameterized test useful as boiler-plate code here: https://github.com/elastic/apm-agent-python/pull/1938/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants