Skip to content

Commit

Permalink
Merge branch 'main' into psycopg3-instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen committed Mar 14, 2024
2 parents 09890a4 + 717d107 commit dca2adb
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 27 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- `opentelemetry-instrumentation-celery` Allow Celery instrumentation to be installed multiple times
([#2342](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2342))
- Align gRPC span status codes to OTEL specification ([#1756](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1756))
- Align gRPC span status codes to OTEL specification
([#1756](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1756))
- `opentelemetry-instrumentation-flask` Add importlib metadata default for deprecation warning flask version
([#2297](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2297))

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

- Drop support for 3.7
- Drop uspport for 3.7
([#2151](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2151))
- `opentelemetry-resource-detector-azure` Added 10s timeout to VM Resource Detector
([#2119](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2119))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

PROM_VERSION=v2.39.0
PROTO_VERSION=v1.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ def _test_publish(self, exchange_type: Type[Exchange]):
with mock.patch.object(
PublishDecorator, "_get_publish_span"
) as mock_get_publish_span:
with mock.patch.object(
Exchange, "publish", return_value=asyncio.sleep(0)
) as mock_publish:
with mock.patch.object(Exchange, "publish") as mock_publish:
decorated_publish = PublishDecorator(
self.tracer, exchange
).decorate(mock_publish)
Expand All @@ -101,9 +99,7 @@ def _test_publish_works_with_not_recording_span(self, exchange_type):
mocked_not_recording_span = MagicMock()
mocked_not_recording_span.is_recording.return_value = False
mock_get_publish_span.return_value = mocked_not_recording_span
with mock.patch.object(
Exchange, "publish", return_value=asyncio.sleep(0)
) as mock_publish:
with mock.patch.object(Exchange, "publish") as mock_publish:
with mock.patch(
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
) as mock_inject:
Expand Down Expand Up @@ -158,9 +154,7 @@ def _test_publish(self, exchange_type: Type[Exchange]):
with mock.patch.object(
PublishDecorator, "_get_publish_span"
) as mock_get_publish_span:
with mock.patch.object(
Exchange, "publish", return_value=asyncio.sleep(0)
) as mock_publish:
with mock.patch.object(Exchange, "publish") as mock_publish:
decorated_publish = PublishDecorator(
self.tracer, exchange
).decorate(mock_publish)
Expand All @@ -184,9 +178,7 @@ def _test_publish_works_with_not_recording_span(self, exchange_type):
mocked_not_recording_span = MagicMock()
mocked_not_recording_span.is_recording.return_value = False
mock_get_publish_span.return_value = mocked_not_recording_span
with mock.patch.object(
Exchange, "publish", return_value=asyncio.sleep(0)
) as mock_publish:
with mock.patch.object(Exchange, "publish") as mock_publish:
with mock.patch(
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
) as mock_inject:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_instrumentor_connect(self):
cnx = async_call(aiopg.connect(database="test"))
cursor = async_call(cnx.cursor())
query = "SELECT * FROM test"
cursor.execute(query)
async_call(cursor.execute(query))

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 1)
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_instrumentor_create_pool(self):
cnx = async_call(pool.acquire())
cursor = async_call(cnx.cursor())
query = "SELECT * FROM test"
cursor.execute(query)
async_call(cursor.execute(query))

spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies = [
"opentelemetry-semantic-conventions == 0.45b0.dev",
"opentelemetry-util-http == 0.45b0.dev",
"packaging >= 21.0",
"importlib-metadata >= 4.0",
]

[project.optional-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,13 @@ def response_hook(span: Span, status: str, response_headers: List):
from typing import Collection

import flask
import importlib_metadata as metadata
from packaging import version as package_version

import opentelemetry.instrumentation.wsgi as otel_wsgi
from opentelemetry import context, trace
from opentelemetry.instrumentation.flask.package import _instruments
from opentelemetry.instrumentation.flask.version import __version__

try:
flask_version = flask.__version__
except AttributeError:
try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata
flask_version = metadata.version("flask")

from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
from opentelemetry.instrumentation.propagators import (
get_global_response_propagator,
Expand All @@ -281,6 +272,8 @@ def response_hook(span: Span, status: str, response_headers: List):

_excluded_urls_from_env = get_excluded_urls("FLASK")

flask_version = metadata.version("flask")

if package_version.parse(flask_version) >= package_version.parse("2.2.0"):

def _request_ctx_ref() -> weakref.ReferenceType:
Expand Down
3 changes: 2 additions & 1 deletion scripts/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
#
set -e

# This script:
# 1. parses the version number from the branch name
# 2. updates version.py files to match that version
Expand Down

0 comments on commit dca2adb

Please sign in to comment.