Skip to content

Commit 8adb093

Browse files
committed
fix ruff and linting issues
1 parent a0b0cb3 commit 8adb093

File tree

8 files changed

+37
-42
lines changed
  • instrumentation
    • opentelemetry-instrumentation-aiopg/src/opentelemetry/instrumentation/aiopg
    • opentelemetry-instrumentation-mysqlclient/src/opentelemetry/instrumentation/mysqlclient
    • opentelemetry-instrumentation-mysql/src/opentelemetry/instrumentation/mysql
    • opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2
    • opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg
    • opentelemetry-instrumentation-pymysql/src/opentelemetry/instrumentation/pymysql
    • opentelemetry-instrumentation-sqlite3

8 files changed

+37
-42
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@
3535
cnx.close()
3636
3737
pool = await aiopg.create_pool(database='Database')
38-
38+
3939
cnx = await pool.acquire()
4040
cursor = await cnx.cursor()
4141
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
4242
cursor.close()
4343
cnx.close()
44-
44+
4545
cnx = AiopgInstrumentor().instrument_connection(cnx)
4646
cursor = await cnx.cursor()
4747
await cursor.execute("INSERT INTO test (testField) VALUES (123)")
4848
cursor.close()
4949
cnx.close()
50-
50+
5151
API
5252
---
5353
"""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
cursor.execute("INSERT INTO test (testField) VALUES (123)")
3434
cursor.close()
3535
cnx.close()
36-
36+
3737
cnx = MySQLInstrumentor().instrument_connection(cnx)
3838
cursor = cnx.cursor()
3939
cursor.execute("INSERT INTO test (testField) VALUES (123)")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
cnx.commit()
5656
cursor.close()
5757
cnx.close()
58-
58+
5959
instrumented_cnx = MySQLClientInstrumentor.instrument_connection(
6060
cnx,
6161
enable_commenter=True,
@@ -197,7 +197,7 @@ def instrument_connection(
197197
- `driver_paramstyle`: Adds the parameter style.
198198
- `opentelemetry_values`: Includes traceparent values.
199199
Refer to *SQLCommenter Configurations* above for more information
200-
200+
201201
Returns:
202202
An instrumented MySQL connection with OpenTelemetry support enabled.
203203
"""

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@
9292
PsycopgInstrumentor().instrument()
9393
9494
cnx = psycopg.connect(database='Database')
95-
95+
9696
cursor = cnx.cursor()
9797
cursor.execute("INSERT INTO test (testField) VALUES (123)")
9898
cursor.close()
9999
cnx.close()
100-
100+
101101
instrumented_cnx = instrument_connection(cnx)
102102
cursor = instrumented_cnx.cursor()
103103
cursor.execute("INSERT INTO test (testField) VALUES (123)")
104104
cursor.close()
105105
instrumented_cnx.close()
106-
106+
107107
API
108108
---
109109
"""
@@ -205,15 +205,15 @@ def _uninstrument(self, **kwargs):
205205
def instrument_connection(connection, tracer_provider=None):
206206
"""Enable instrumentation in a psycopg connection.
207207
208-
Args:
209-
connection: psycopg.Connection
210-
The psycopg connection object to be instrumented.
211-
tracer_provider: opentelemetry.trace.TracerProvider, optional
212-
The TracerProvider to use for instrumentation. If not provided,
213-
the global TracerProvider will be used.
208+
Args:
209+
connection: psycopg.Connection
210+
The psycopg connection object to be instrumented.
211+
tracer_provider: opentelemetry.trace.TracerProvider, optional
212+
The TracerProvider to use for instrumentation. If not provided,
213+
the global TracerProvider will be used.
214214
215-
Returns:
216-
An instrumented psycopg connection object.
215+
Returns:
216+
An instrumented psycopg connection object.
217217
"""
218218
if not hasattr(connection, "_is_instrumented_by_opentelemetry"):
219219
connection._is_instrumented_by_opentelemetry = False

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
Psycopg2Instrumentor().instrument()
9393
9494
cnx = psycopg2.connect(database='Database')
95-
95+
9696
cursor = cnx.cursor()
9797
cursor.execute("INSERT INTO test (testField) VALUES (123)")
9898
cursor.close()
@@ -168,17 +168,17 @@ def _uninstrument(self, **kwargs):
168168
def instrument_connection(connection, tracer_provider=None):
169169
"""Enable instrumentation in a psycopg2 connection.
170170
171-
Args:
172-
connection: psycopg2.extensions.connection
173-
The psycopg2 connection object to be instrumented.
174-
tracer_provider: opentelemetry.trace.TracerProvider, optional
175-
The TracerProvider to use for instrumentation. If not specified,
176-
the global TracerProvider will be used.
171+
Args:
172+
connection: psycopg2.extensions.connection
173+
The psycopg2 connection object to be instrumented.
174+
tracer_provider: opentelemetry.trace.TracerProvider, optional
175+
The TracerProvider to use for instrumentation. If not specified,
176+
the global TracerProvider will be used.
177177
178-
Returns:
179-
An instrumented psycopg2 connection object.
178+
Returns:
179+
An instrumented psycopg2 connection object.
180180
"""
181-
181+
182182
if not hasattr(connection, "_is_instrumented_by_opentelemetry"):
183183
connection._is_instrumented_by_opentelemetry = False
184184

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
cnx.commit()
5757
cursor.close()
5858
cnx.close()
59-
59+
6060
instrumented_cnx = PyMySQLInstrumentor().instrument_connection(
6161
cnx,
6262
enable_commenter=True,
6363
commenter_options={
64-
"db_driver": True,
64+
"db_driver": True,
6565
"mysql_client_version": True
6666
}
6767
)

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,19 @@
3131
SQLite3Instrumentor().instrument()
3232
3333
cnx = sqlite3.connect(':memory:')
34-
3534
cursor = cnx.cursor()
3635
cursor.execute("CREATE TABLE test (testField INTEGER)")
3736
cursor.execute("INSERT INTO test (testField) VALUES (123)")
3837
cursor.close()
3938
cnx.close()
40-
4139
conn = sqlite3.connect(":memory:")
42-
4340
instrumented_connection = SQLite3Instrumentor.instrument_connection(conn)
4441
cursor = instrumented_connection.cursor()
4542
cursor.execute("CREATE TABLE test (testField INTEGER)")
4643
cursor.execute("INSERT INTO test (testField) VALUES (123)")
47-
cursor.execute("SELECT * FROM test")
44+
cursor.execute("SELECT * FROM test")
4845
cursor.close()
4946
instrumented_connection.close()
50-
5147
API
5248
---
5349
"""
@@ -119,11 +115,10 @@ def instrument_connection(
119115
telemetry for tracing database operations.
120116
121117
Notes:
122-
- Instrumentation must be explicitly applied to the connection object
123-
for tracing to work. This is not done automatically by simply calling
118+
- Instrumentation must be explicitly applied to the connection object
119+
for tracing to work. This is not done automatically by simply calling
124120
`SQLite3Instrumentor().instrument()`.
125121
"""
126-
127122
return dbapi.instrument_connection(
128123
__name__,
129124
connection,
@@ -146,4 +141,3 @@ def uninstrument_connection(
146141
An uninstrumented connection.
147142
"""
148143
return dbapi.uninstrument_connection(connection)
149-

instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def setUp(self):
2929
self._cursor = self._connection.cursor()
3030
self._connection2 = dbapi2.connect(":memory:")
3131
self._cursor2 = self._connection2.cursor()
32-
self._connection3 = SQLite3Instrumentor.instrument_connection(dbapi2.connect(":memory:"))
32+
self._connection3 = SQLite3Instrumentor.instrument_connection(
33+
dbapi2.connect(":memory:")
34+
)
3335
self._cursor3 = self._connection3.cursor()
3436

3537
def tearDown(self):
@@ -84,7 +86,7 @@ def test_execute(self):
8486
with self._tracer.start_as_current_span("rootSpan"):
8587
self._cursor2.execute(stmt)
8688
self.validate_spans("CREATE")
87-
89+
8890
with self._tracer.start_as_current_span("rootSpan"):
8991
self._cursor3.execute(stmt)
9092
self.validate_spans("CREATE")
@@ -107,12 +109,11 @@ def test_executemany(self):
107109
with self._tracer.start_as_current_span("rootSpan"):
108110
self._cursor3.executemany(stmt, data)
109111
self.validate_spans("INSERT")
110-
112+
111113
def test_callproc(self):
112114
"""Should create a child span for callproc"""
113115
with self._tracer.start_as_current_span("rootSpan"), self.assertRaises(
114116
Exception
115117
):
116118
self._cursor.callproc("test", ())
117119
self.validate_spans("test")
118-

0 commit comments

Comments
 (0)