From 7b3b244289945aecd9ae1456449611f9b0274f9f Mon Sep 17 00:00:00 2001 From: krnr Date: Sun, 11 Sep 2022 14:11:10 +0300 Subject: [PATCH] asyncpg: Use only the first word from query as a span name --- CHANGELOG.md | 2 ++ .../src/opentelemetry/instrumentation/asyncpg/__init__.py | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a2b306157..754445f90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1208](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1208)) - `opentelemetry-instrumentation-aiohttp-client` Fix producing additional spans with each newly created ClientSession - ([#1246](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1246)) +- `opentelemetry-instrumentation-asyncpg` Fix high cardinality in the span name +- ([#1170](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1324)) ## [1.12.0-0.33b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0-0.33b0) - 2022-08-08 diff --git a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py index b66168f4d0..80fd32b7d9 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py @@ -133,6 +133,7 @@ async def _do_execute(self, func, instance, args, kwargs): exception = None params = getattr(instance, "_params", {}) name = args[0] if args[0] else params.get("database", "postgresql") + name = name.split()[0] with self._tracer.start_as_current_span( name, kind=SpanKind.CLIENT