Skip to content

APM crashes when postgres is configured with multiple hosts / ports in Django #1383

Description

@azlev

Hello.

I'm using multiple postgresql hosts (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING section 34.1.1.3).

The APM crashes trying to convert comma separated list of ports in a int:

  File "/usr/local/lib/python3.7/site-packages/elasticapm/instrumentation/packages/psycopg2.py", line 86, in call
    if int(port) != default_ports.get("postgresql"):
ValueError: invalid literal for int() with base 10: '5432,5433'

To Reproduce

  1. Configure multiple hosts in postgres config (more than 1 host and port)
  2. Start the app
  3. crashes with the exception:
  File "/usr/local/lib/python3.7/site-packages/elasticapm/instrumentation/packages/psycopg2.py", line 86, in call
    if int(port) != default_ports.get("postgresql"):
ValueError: invalid literal for int() with base 10: '5432,5433'

Environment (please complete the following information)

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

Additional context

https://github.com/elastic/apm-agent-python/blob/master/elasticapm/instrumentation/packages/psycopg2.py#L86

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions