Skip to content

Commit cb60d27

Browse files
authored
Merge branch 'main' into bug-3352/fix-transient-ci-git-errors
2 parents 5764d8b + 3c88163 commit cb60d27

File tree

8 files changed

+36
-6
lines changed

8 files changed

+36
-6
lines changed

.github/workflows/lint_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111

1212
env:
13-
CORE_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
13+
CORE_REPO_SHA: main
1414
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

.github/workflows/misc_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111

1212
env:
13-
CORE_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
13+
CORE_REPO_SHA: main
1414
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

.github/workflows/test_0.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111

1212
env:
13-
CORE_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
13+
CORE_REPO_SHA: main
1414
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

.github/workflows/test_1.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111

1212
env:
13-
CORE_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
13+
CORE_REPO_SHA: main
1414
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

.github/workflows/test_2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
pull_request:
1111

1212
env:
13-
CORE_REPO_SHA: opentelemetrybot/update-version-to-1.32.0.dev-0.53b0.dev
13+
CORE_REPO_SHA: main
1414
CONTRIB_REPO_SHA: main
1515
PIP_EXISTS_ACTION: w
1616

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4646
([#3249](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3249))
4747
- `opentelemetry-instrumentation-asyncpg` Fix fallback for empty queries.
4848
([#3253](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3253))
49+
- `opentelemetry-instrumentation` Fix a traceback in sqlcommenter when psycopg connection pooling is enabled.
50+
([#3309](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3309))
4951
- `opentelemetry-instrumentation-threading` Fix broken context typehints
5052
([#3322](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3322))
5153
- `opentelemetry-instrumentation-requests` always record span status code in duration metric

instrumentation/opentelemetry-instrumentation-django/tests/test_sqlcommenter.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,31 @@ def test_multiple_connection_support(self, query_wrapper):
146146

147147
# check if query_wrapper is added to the context for 2 databases
148148
self.assertEqual(query_wrapper.call_count, 2)
149+
150+
@patch(
151+
"opentelemetry.instrumentation.django.middleware.sqlcommenter_middleware._get_opentelemetry_values"
152+
)
153+
def test_empty_sql(self, trace_capture):
154+
requests_mock = MagicMock()
155+
requests_mock.resolver_match.view_name = "view"
156+
requests_mock.resolver_match.route = "route"
157+
requests_mock.resolver_match.app_name = "app"
158+
159+
trace_capture.return_value = {
160+
"traceparent": "*traceparent='00-000000000000000000000000deadbeef-000000000000beef-00"
161+
}
162+
qw_instance = _QueryWrapper(requests_mock)
163+
execute_mock_obj = MagicMock()
164+
qw_instance(
165+
execute_mock_obj,
166+
"",
167+
MagicMock("test"),
168+
MagicMock("test1"),
169+
MagicMock(),
170+
)
171+
output_sql = execute_mock_obj.call_args[0][0]
172+
self.assertEqual(
173+
output_sql,
174+
" /*app_name='app',controller='view',route='route',traceparent='%%2Atraceparent%%3D%%2700-0000000"
175+
"00000000000000000deadbeef-000000000000beef-00'*/",
176+
)

opentelemetry-instrumentation/src/opentelemetry/instrumentation/sqlcommenter_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _add_sql_comment(sql, **meta) -> str:
2323
meta.update(**_add_framework_tags())
2424
comment = _generate_sql_comment(**meta)
2525
sql = sql.rstrip()
26-
if sql[-1] == ";":
26+
if sql.endswith(";"):
2727
sql = sql[:-1] + comment + ";"
2828
else:
2929
sql = sql + comment

0 commit comments

Comments
 (0)