Skip to content

Commit 08e0c50

Browse files
committed
* Contribute.MD should point out that manually running black must use --config parameter pointing to the pyproject.toml as tests will fail upstream otherwise.
1 parent 6025de9 commit 08e0c50

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@
109109
from psycopg import ( # pylint: disable=import-self,no-name-in-module
110110
AsyncCursor as pg_async_cursor,
111111
)
112-
from psycopg import Cursor as pg_cursor # pylint: disable=no-name-in-module,import-self
112+
from psycopg import ( # pylint: disable=no-name-in-module,import-self
113+
Cursor as pg_cursor,
114+
)
113115
from psycopg.sql import Composed # pylint: disable=no-name-in-module
114116

115117
from opentelemetry.instrumentation import dbapi
@@ -182,7 +184,9 @@ def _instrument(self, **kwargs):
182184
def _uninstrument(self, **kwargs):
183185
""" "Disable Psycopg instrumentation"""
184186
dbapi.unwrap_connect(psycopg, "connect") # pylint: disable=no-member
185-
dbapi.unwrap_connect(psycopg.Connection, "connect") # pylint: disable=no-member
187+
dbapi.unwrap_connect(
188+
psycopg.Connection, "connect" # pylint: disable=no-member
189+
)
186190
dbapi.unwrap_connect(
187191
psycopg.AsyncConnection, "connect" # pylint: disable=no-member
188192
)
@@ -194,7 +198,9 @@ def instrument_connection(connection, tracer_provider=None):
194198
connection._is_instrumented_by_opentelemetry = False
195199

196200
if not connection._is_instrumented_by_opentelemetry:
197-
setattr(connection, _OTEL_CURSOR_FACTORY_KEY, connection.cursor_factory)
201+
setattr(
202+
connection, _OTEL_CURSOR_FACTORY_KEY, connection.cursor_factory
203+
)
198204
connection.cursor_factory = _new_cursor_factory(
199205
tracer_provider=tracer_provider
200206
)
@@ -208,7 +214,9 @@ def instrument_connection(connection, tracer_provider=None):
208214
# TODO(owais): check if core dbapi can do this for all dbapi implementations e.g, pymysql and mysql
209215
@staticmethod
210216
def uninstrument_connection(connection):
211-
connection.cursor_factory = getattr(connection, _OTEL_CURSOR_FACTORY_KEY, None)
217+
connection.cursor_factory = getattr(
218+
connection, _OTEL_CURSOR_FACTORY_KEY, None
219+
)
212220

213221
return connection
214222

@@ -244,7 +252,9 @@ async def wrapped_connection(
244252
new_factory_kwargs = {"db_api": self}
245253
if base_cursor_factory:
246254
new_factory_kwargs["base_factory"] = base_cursor_factory
247-
kwargs["cursor_factory"] = _new_cursor_async_factory(**new_factory_kwargs)
255+
kwargs["cursor_factory"] = _new_cursor_async_factory(
256+
**new_factory_kwargs
257+
)
248258
connection = await connect_method(*args, **kwargs)
249259
self.get_connection_attributes(connection)
250260
return connection
@@ -307,7 +317,9 @@ def callproc(self, *args, **kwargs):
307317
return TracedCursorFactory
308318

309319

310-
def _new_cursor_async_factory(db_api=None, base_factory=None, tracer_provider=None):
320+
def _new_cursor_async_factory(
321+
db_api=None, base_factory=None, tracer_provider=None
322+
):
311323
if not db_api:
312324
db_api = DatabaseApiAsyncIntegration(
313325
__name__,

instrumentation/opentelemetry-instrumentation-psycopg/tests/test_psycopg_integration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ async def test_span_name_async(self):
314314
)
315315
await cursor.execute("tab\tseparated query")
316316
await cursor.execute("/* leading comment */ query")
317-
await cursor.execute("/* leading comment */ query /* trailing comment */")
317+
await cursor.execute(
318+
"/* leading comment */ query /* trailing comment */"
319+
)
318320
await cursor.execute("query /* trailing comment */")
319321

320322
spans_list = self.memory_exporter.get_finished_spans()

0 commit comments

Comments
 (0)