Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bug_fix(1477): type handling in _add_sql_comment #3113

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b75a977
bug_fix(1477): type handling in _add_sql_comment
aryabharat Dec 17, 2024
03561c8
bug_fix(1477): type handling in _add_sql_comment
aryabharat Dec 17, 2024
1d45193
Merge branch 'fix/1477' of https://github.com/aryabharat/opentelemetr…
aryabharat Jan 19, 2025
e90eefe
Merge branch 'main' into fix/1477
aryabharat Jan 19, 2025
ba3b51a
bug_fix(1477): type handling in _add_sql_comment
aryabharat Dec 17, 2024
cc7332d
Merge branch 'fix/1477' of https://github.com/aryabharat/opentelemetr…
aryabharat Jan 19, 2025
341899d
bug_fix(1477): updated type handling for _add_sql_comment
aryabharat Feb 4, 2025
a18df5e
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 11, 2025
226c8e6
bug_fix(1477): updated type handling for _add_sql_comment
aryabharat Feb 4, 2025
ce7f69a
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 15, 2025
14d0200
Merge branch 'fix/1477' of https://github.com/aryabharat/opentelemetr…
aryabharat Feb 15, 2025
2c8d008
bug_fix(1477): added unit tests
aryabharat Feb 15, 2025
1060c80
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 19, 2025
592903c
updated change log file
aryabharat Feb 19, 2025
79321ed
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 19, 2025
113222a
bug_fix(1477): updated change log.
aryabharat Feb 23, 2025
43750c0
Merge branch 'main' into fix/1477
tammy-baylis-swi Feb 25, 2025
7b4e3cb
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 27, 2025
44d9f8d
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Feb 28, 2025
0e1c38f
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Mar 2, 2025
e6c47ac
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Mar 3, 2025
3e80a2d
Merge branch 'open-telemetry:main' into fix/1477
aryabharat Mar 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def _add_sql_comment(sql, **meta) -> str:
"""
meta.update(**_add_framework_tags())
comment = _generate_sql_comment(**meta)
# converting to str to handle any type errors
sql = str(sql)
sql = sql.rstrip()
if sql[-1] == ";":
sql = sql[:-1] + comment + ";"
Expand Down
15 changes: 15 additions & 0 deletions opentelemetry-instrumentation/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ def test_add_sql_comments_without_comments(self):

self.assertEqual(commented_sql_without_semicolon, "Select 1")

def test_psycopg2_sql_composable(self):
"""Test handling of psycopg2.sql.Composable input"""
# Mock psycopg2.sql.Composable object
class MockComposable:
def __str__(self):
return "SELECT * FROM table_name"

sql_query = MockComposable()
comments = {"trace_id": "abc123"}

result = _add_sql_comment(sql_query, **comments)
expected = "SELECT * FROM table_name /*trace_id='abc123'*/"

self.assertEqual(result, expected)

def test_is_instrumentation_enabled_by_default(self):
self.assertTrue(is_instrumentation_enabled())
self.assertTrue(is_http_instrumentation_enabled())
Expand Down
Loading