Skip to content

Commit

Permalink
Merge branch 'main' into uv
Browse files Browse the repository at this point in the history
  • Loading branch information
emdneto authored Jul 12, 2024
2 parents dba54a3 + 43dfc73 commit 209ca6a
Show file tree
Hide file tree
Showing 86 changed files with 153 additions and 127 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ Below is a checklist of things to be mindful of when implementing a new instrume
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L234>
- Appropriate error handling
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L220>
- Isolate sync and async test
- For synchronous tests, the typical test case class is inherited from `opentelemetry.test.test_base.TestBase`. However, if you want to write asynchronous tests, the test case class should inherit also from `IsolatedAsyncioTestCase`. Adding asynchronous tests to a common test class can lead to tests passing without actually running, which can be misleading.
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/60fb936b7e5371b3e5587074906c49fb873cbd76/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py#L84>

## Expectations from contributors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
asgiref==3.7.2
certifi==2024.2.2
charset-normalizer==3.3.2
cramjam==2.8.1
# We can drop this after bumping baseline to pypy-39
cramjam==2.1.0; platform_python_implementation == "PyPy"
cramjam==2.8.1; platform_python_implementation != "PyPy"
Deprecated==1.2.14
idna==3.7
importlib-metadata==6.11.0
Expand All @@ -17,5 +19,5 @@ tomli==2.0.1
typing_extensions==4.10.0
urllib3==2.2.2
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e exporter/opentelemetry-exporter-prometheus-remote-write
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ rich==13.7.1
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e exporter/opentelemetry-exporter-richconsole
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-aio-pika
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-aio-pika
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-aio-pika
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-aio-pika
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ aiosignal==1.3.1
asgiref==3.7.2
async-timeout==4.0.3
blinker==1.7.0
certifi==2024.2.2
certifi==2024.7.4
charset-normalizer==3.3.2
click==8.1.7
Deprecated==1.2.14
Expand All @@ -28,7 +28,7 @@ urllib3==2.2.2
Werkzeug==3.0.3
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e util/opentelemetry-util-http
-e instrumentation/opentelemetry-instrumentation-aiohttp-client
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
yarl==1.9.4
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e util/opentelemetry-util-http
-e instrumentation/opentelemetry-instrumentation-aiohttp-server
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-dbapi
-e instrumentation/opentelemetry-instrumentation-aiopg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e util/opentelemetry-util-http
-e instrumentation/opentelemetry-instrumentation-asgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pytest-asyncio==0.23.5
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-asyncio
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import asyncio
import sys
from unittest import skipIf
from unittest.mock import patch

# pylint: disable=no-name-in-module
Expand Down Expand Up @@ -41,6 +43,9 @@ def tearDown(self):

# Asyncio anext() does not have __name__ attribute, which is used to determine if the coroutine should be traced.
# This test is to ensure that the instrumentation does not break when the coroutine does not have __name__ attribute.
@skipIf(
sys.version_info < (3, 10), "anext is only available in Python 3.10+"
)
def test_asyncio_anext(self):
async def main():
async def async_gen():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def tearDown(self):

def test_cancel(self):
with self._tracer.start_as_current_span("root", kind=SpanKind.SERVER):
asyncio.run(cancellation_create_task())
try:
asyncio.run(cancellation_create_task())
except asyncio.CancelledError:
pass
spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 3)
self.assertEqual(spans[0].context.trace_id, spans[1].context.trace_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import asyncio
import sys
from unittest import skipIf
from unittest.mock import patch

# pylint: disable=no-name-in-module
Expand All @@ -25,10 +26,6 @@

from .common_test_func import async_func

py11 = False
if sys.version_info >= (3, 11):
py11 = True


class TestAsyncioTaskgroup(TestBase):
@patch.dict(
Expand All @@ -46,11 +43,11 @@ def tearDown(self):
super().tearDown()
AsyncioInstrumentor().uninstrument()

@skipIf(
sys.version_info < (3, 11),
"TaskGroup is only available in Python 3.11+",
)
def test_task_group_create_task(self):
# TaskGroup is only available in Python 3.11+
if not py11:
return

async def main():
async with asyncio.TaskGroup() as tg: # pylint: disable=no-member
for _ in range(10):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import asyncio
import sys
from unittest import skipIf
from unittest.mock import patch

# pylint: disable=no-name-in-module
Expand Down Expand Up @@ -40,34 +41,34 @@ def tearDown(self):
super().tearDown()
AsyncioInstrumentor().uninstrument()

@skipIf(
sys.version_info < (3, 9), "to_thread is only available in Python 3.9+"
)
def test_to_thread(self):
# to_thread is only available in Python 3.9+
if sys.version_info >= (3, 9):

def multiply(x, y):
return x * y
def multiply(x, y):
return x * y

async def to_thread():
result = await asyncio.to_thread(multiply, 2, 3)
assert result == 6
async def to_thread():
result = await asyncio.to_thread(multiply, 2, 3)
assert result == 6

with self._tracer.start_as_current_span("root"):
asyncio.run(to_thread())
spans = self.memory_exporter.get_finished_spans()
with self._tracer.start_as_current_span("root"):
asyncio.run(to_thread())
spans = self.memory_exporter.get_finished_spans()

self.assertEqual(len(spans), 2)
assert spans[0].name == "asyncio to_thread-multiply"
for metric in (
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics
):
if metric.name == "asyncio.process.duration":
for point in metric.data.data_points:
self.assertEqual(point.attributes["type"], "to_thread")
self.assertEqual(point.attributes["name"], "multiply")
if metric.name == "asyncio.process.created":
for point in metric.data.data_points:
self.assertEqual(point.attributes["type"], "to_thread")
self.assertEqual(point.attributes["name"], "multiply")
self.assertEqual(len(spans), 2)
assert spans[0].name == "asyncio to_thread-multiply"
for metric in (
self.memory_metrics_reader.get_metrics_data()
.resource_metrics[0]
.scope_metrics[0]
.metrics
):
if metric.name == "asyncio.process.duration":
for point in metric.data.data_points:
self.assertEqual(point.attributes["type"], "to_thread")
self.assertEqual(point.attributes["name"], "multiply")
if metric.name == "asyncio.process.created":
for point in metric.data.data_points:
self.assertEqual(point.attributes["type"], "to_thread")
self.assertEqual(point.attributes["name"], "multiply")
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-asyncpg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e propagator/opentelemetry-propagator-aws-xray
-e instrumentation/opentelemetry-instrumentation-aws-lambda
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ asgiref==3.7.2
boto==2.49.0
boto3==1.34.44
botocore==1.34.44
certifi==2024.2.2
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.5
Expand Down Expand Up @@ -33,6 +33,6 @@ urllib3==1.26.19
Werkzeug==2.3.8
wrapt==1.16.0
xmltodict==0.13.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-boto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ tomli==2.0.1
typing_extensions==4.9.0
urllib3==1.26.19
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-boto3sqs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ asgiref==3.7.2
aws-xray-sdk==2.12.1
boto3==1.28.80
botocore==1.31.80
certifi==2024.2.2
certifi==2024.7.4
cffi==1.16.0
charset-normalizer==3.3.2
cryptography==42.0.5
Expand Down Expand Up @@ -33,7 +33,7 @@ urllib3==1.26.19
Werkzeug==3.0.3
wrapt==1.16.0
xmltodict==0.13.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e propagator/opentelemetry-propagator-aws-xray
-e instrumentation/opentelemetry-instrumentation-botocore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ six==1.16.0
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-cassandra
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ tzdata==2024.1
vine==5.1.0
wcwidth==0.2.13
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-celery
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ tzdata==2024.1
vine==5.1.0
wcwidth==0.2.13
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-celery
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-confluent-kafka
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ pytest==7.4.4
tomli==2.0.1
typing_extensions==4.9.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-dbapi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sqlparse==0.5.0
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-wsgi
-e util/opentelemetry-util-http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sqlparse==0.5.0
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-wsgi
-e instrumentation/opentelemetry-instrumentation-asgi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sqlparse==0.5.0
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-wsgi
-e instrumentation/opentelemetry-instrumentation-asgi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ sqlparse==0.5.0
tomli==2.0.1
typing_extensions==4.10.0
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-wsgi
-e instrumentation/opentelemetry-instrumentation-asgi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ tomli==2.0.1
typing_extensions==4.10.0
urllib3==1.26.19
wrapt==1.16.0
zipp==3.17.0
zipp==3.19.2
-e opentelemetry-instrumentation
-e instrumentation/opentelemetry-instrumentation-elasticsearch
Loading

0 comments on commit 209ca6a

Please sign in to comment.