Skip to content

Commit dca2adb

Browse files
authored
Merge branch 'main' into psycopg3-instrumentation
2 parents 09890a4 + 717d107 commit dca2adb

File tree

7 files changed

+18
-27
lines changed

7 files changed

+18
-27
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Fixed
1414
- `opentelemetry-instrumentation-celery` Allow Celery instrumentation to be installed multiple times
1515
([#2342](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2342))
16-
- Align gRPC span status codes to OTEL specification ([#1756](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1756))
16+
- Align gRPC span status codes to OTEL specification
17+
([#1756](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1756))
18+
- `opentelemetry-instrumentation-flask` Add importlib metadata default for deprecation warning flask version
19+
([#2297](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2297))
1720

1821
## Version 1.23.0/0.44b0 (2024-02-23)
1922

20-
- Drop support for 3.7
23+
- Drop uspport for 3.7
2124
([#2151](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2151))
2225
- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
2326
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))

exporter/opentelemetry-exporter-prometheus-remote-write/proto/generate-proto-py.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
PROM_VERSION=v2.39.0
45
PROTO_VERSION=v1.3.2

instrumentation/opentelemetry-instrumentation-aio-pika/tests/test_publish_decorator.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ def _test_publish(self, exchange_type: Type[Exchange]):
7575
with mock.patch.object(
7676
PublishDecorator, "_get_publish_span"
7777
) as mock_get_publish_span:
78-
with mock.patch.object(
79-
Exchange, "publish", return_value=asyncio.sleep(0)
80-
) as mock_publish:
78+
with mock.patch.object(Exchange, "publish") as mock_publish:
8179
decorated_publish = PublishDecorator(
8280
self.tracer, exchange
8381
).decorate(mock_publish)
@@ -101,9 +99,7 @@ def _test_publish_works_with_not_recording_span(self, exchange_type):
10199
mocked_not_recording_span = MagicMock()
102100
mocked_not_recording_span.is_recording.return_value = False
103101
mock_get_publish_span.return_value = mocked_not_recording_span
104-
with mock.patch.object(
105-
Exchange, "publish", return_value=asyncio.sleep(0)
106-
) as mock_publish:
102+
with mock.patch.object(Exchange, "publish") as mock_publish:
107103
with mock.patch(
108104
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
109105
) as mock_inject:
@@ -158,9 +154,7 @@ def _test_publish(self, exchange_type: Type[Exchange]):
158154
with mock.patch.object(
159155
PublishDecorator, "_get_publish_span"
160156
) as mock_get_publish_span:
161-
with mock.patch.object(
162-
Exchange, "publish", return_value=asyncio.sleep(0)
163-
) as mock_publish:
157+
with mock.patch.object(Exchange, "publish") as mock_publish:
164158
decorated_publish = PublishDecorator(
165159
self.tracer, exchange
166160
).decorate(mock_publish)
@@ -184,9 +178,7 @@ def _test_publish_works_with_not_recording_span(self, exchange_type):
184178
mocked_not_recording_span = MagicMock()
185179
mocked_not_recording_span.is_recording.return_value = False
186180
mock_get_publish_span.return_value = mocked_not_recording_span
187-
with mock.patch.object(
188-
Exchange, "publish", return_value=asyncio.sleep(0)
189-
) as mock_publish:
181+
with mock.patch.object(Exchange, "publish") as mock_publish:
190182
with mock.patch(
191183
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
192184
) as mock_inject:

instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_instrumentor_connect(self):
7676
cnx = async_call(aiopg.connect(database="test"))
7777
cursor = async_call(cnx.cursor())
7878
query = "SELECT * FROM test"
79-
cursor.execute(query)
79+
async_call(cursor.execute(query))
8080

8181
spans_list = self.memory_exporter.get_finished_spans()
8282
self.assertEqual(len(spans_list), 1)
@@ -127,7 +127,7 @@ def test_instrumentor_create_pool(self):
127127
cnx = async_call(pool.acquire())
128128
cursor = async_call(cnx.cursor())
129129
query = "SELECT * FROM test"
130-
cursor.execute(query)
130+
async_call(cursor.execute(query))
131131

132132
spans_list = self.memory_exporter.get_finished_spans()
133133
self.assertEqual(len(spans_list), 1)

instrumentation/opentelemetry-instrumentation-flask/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dependencies = [
3030
"opentelemetry-semantic-conventions == 0.45b0.dev",
3131
"opentelemetry-util-http == 0.45b0.dev",
3232
"packaging >= 21.0",
33+
"importlib-metadata >= 4.0",
3334
]
3435

3536
[project.optional-dependencies]

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -245,22 +245,13 @@ def response_hook(span: Span, status: str, response_headers: List):
245245
from typing import Collection
246246

247247
import flask
248+
import importlib_metadata as metadata
248249
from packaging import version as package_version
249250

250251
import opentelemetry.instrumentation.wsgi as otel_wsgi
251252
from opentelemetry import context, trace
252253
from opentelemetry.instrumentation.flask.package import _instruments
253254
from opentelemetry.instrumentation.flask.version import __version__
254-
255-
try:
256-
flask_version = flask.__version__
257-
except AttributeError:
258-
try:
259-
from importlib import metadata
260-
except ImportError:
261-
import importlib_metadata as metadata
262-
flask_version = metadata.version("flask")
263-
264255
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
265256
from opentelemetry.instrumentation.propagators import (
266257
get_global_response_propagator,
@@ -281,6 +272,8 @@ def response_hook(span: Span, status: str, response_headers: List):
281272

282273
_excluded_urls_from_env = get_excluded_urls("FLASK")
283274

275+
flask_version = metadata.version("flask")
276+
284277
if package_version.parse(flask_version) >= package_version.parse("2.2.0"):
285278

286279
def _request_ctx_ref() -> weakref.ReferenceType:

scripts/prepare_release.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
#
2+
set -e
3+
34
# This script:
45
# 1. parses the version number from the branch name
56
# 2. updates version.py files to match that version

0 commit comments

Comments
 (0)