Skip to content

Commit 1ee4d33

Browse files
add database as a dependency in asyncpg instrumentation (#1115)
* add database as a dependency in asyncpg instrumentation * fixed "black" code style issue Co-authored-by: Benjamin Wohlwend <beni@elastic.co>
1 parent 923a02a commit 1ee4d33

File tree

1 file changed

+7
-0
lines changed
  • elasticapm/instrumentation/packages/asyncio

1 file changed

+7
-0
lines changed

‎elasticapm/instrumentation/packages/asyncio/asyncpg.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from elasticapm.contrib.asyncio.traces import async_capture_span
3232
from elasticapm.instrumentation.packages.asyncio.base import AsyncAbstractInstrumentedModule
3333
from elasticapm.instrumentation.packages.dbapi2 import extract_signature
34+
from elasticapm.utils import default_ports
3435

3536

3637
class AsyncPGInstrumentation(AsyncAbstractInstrumentedModule):
@@ -56,6 +57,12 @@ async def call(self, module, method, wrapped, instance, args, kwargs):
5657
name = extract_signature(query)
5758
context = {"db": {"type": "sql", "statement": query}}
5859
action = "query"
60+
destination_info = {
61+
"address": kwargs.get("host", "localhost"),
62+
"port": int(kwargs.get("port", default_ports.get("postgresql"))),
63+
"service": {"name": "postgres", "resource": "postgres", "type": "db"},
64+
}
65+
context["destination"] = destination_info
5966
async with async_capture_span(
6067
name, leaf=True, span_type="db", span_subtype="postgres", span_action=action, extra=context
6168
):

0 commit comments

Comments
 (0)