Skip to content

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

@anderssonjohan

Description

@anderssonjohan

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` 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions