Skip to content

Commit edd0ad7

Browse files
Merge branch 'main' into feature/http-route-in-metric
2 parents b83d7ed + 43dfc73 commit edd0ad7

File tree

95 files changed

+173
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+173
-189
lines changed

.github/workflows/instrumentations_0.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,5 @@ jobs:
126126
.tox
127127
~/.cache/pip
128128
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
129-
- name: run pytest without --benchmark-skip
129+
- name: run tox
130130
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra

.github/workflows/instrumentations_1.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ jobs:
2525
matrix:
2626
python-version: [py38, py39, py310, py311, py312, pypy3]
2727
package:
28-
# Only add here packages that do not have benchmark tests
2928
- "urllib"
3029
- "urllib3"
3130
- "wsgi"
3231
- "distro"
3332
- "richconsole"
3433
- "psycopg"
3534
- "prometheus-remote-write"
35+
- "sdk-extension-aws"
36+
- "propagator-aws-xray"
3637
- "propagator-ot-trace"
3738
- "resource-detector-azure"
3839
- "resource-detector-container"
@@ -58,5 +59,5 @@ jobs:
5859
.tox
5960
~/.cache/pip
6061
key: v7-build-tox-cache-${{ env.RUN_MATRIX_COMBINATION }}-${{ hashFiles('tox.ini', 'gen-requirements.txt', 'dev-requirements.txt') }}
61-
- name: run pytest without --benchmark-skip
62+
- name: run tox
6263
run: tox -f ${{ matrix.python-version }}-${{ matrix.package }} -- -ra

.github/workflows/instrumentations_2.yml

-50
This file was deleted.

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ _build/
5858
# mypy
5959
.mypy_cache/
6060
target
61+
62+
# Benchmark result files
63+
*-benchmark.json

CHANGELOG.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
([#2501](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2501))
2929
- `opentelemetry-instrumentation-confluent-kafka` Add support for produce purge
3030
([#2638](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2638))
31+
- `opentelemetry-instrumentation-asgi` Implement new semantic convention opt-in with stable http semantic conventions
32+
([#2610](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2610))
3133
- `opentelemetry-instrumentation-httpx` Implement new semantic convention opt-in migration with stable http semantic conventions
3234
([#2631](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2631))
3335
- `opentelemetry-instrumentation-system-metrics` Permit to use psutil 6.0+.
@@ -42,10 +44,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4244
- Populate `{method}` as `HTTP` on `_OTHER` methods from scope
4345
([#2610](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2610))
4446

45-
### Added
46-
47-
- `opentelemetry-instrumentation-asgi` Implement new semantic convention opt-in with stable http semantic conventions
48-
([#2610](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2610))
4947

5048
### Fixed
5149

CONTRIBUTING.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ for more detail on available tox commands.
9696
9797
### Benchmarks
9898

99-
Performance progression of benchmarks for packages distributed by OpenTelemetry Python can be viewed as a [graph of throughput vs commit history](https://opentelemetry-python-contrib.readthedocs.io/en/latest/performance/benchmarks.html). From the linked page, you can download a JSON file with the performance results.
100-
101-
Running the `tox` tests also runs the performance tests if any are available. Benchmarking tests are done with `pytest-benchmark` and they output a table with results to the console.
99+
Some packages have benchmark tests. To run them, run `tox -f benchmark`. Benchmark tests use `pytest-benchmark` and they output a table with results to the console.
102100

103101
To write benchmarks, simply use the [pytest benchmark fixture](https://pytest-benchmark.readthedocs.io/en/latest/usage.html#usage) like the following:
104102

@@ -114,10 +112,10 @@ def test_simple_start_span(benchmark):
114112
benchmark(benchmark_start_as_current_span, "benchmarkedSpan", 42)
115113
```
116114

117-
Make sure the test file is under the `tests/performance/benchmarks/` folder of
115+
Make sure the test file is under the `benchmarks/` folder of
118116
the package it is benchmarking and further has a path that corresponds to the
119117
file in the package it is testing. Make sure that the file name begins with
120-
`test_benchmark_`. (e.g. `propagator/opentelemetry-propagator-aws-xray/tests/performance/benchmarks/trace/propagation/test_benchmark_aws_xray_propagator.py`)
118+
`test_benchmark_`. (e.g. `propagator/opentelemetry-propagator-aws-xray/benchmarks/trace/propagation/test_benchmark_aws_xray_propagator.py`)
121119

122120
## Pull Requests
123121

@@ -271,6 +269,9 @@ Below is a checklist of things to be mindful of when implementing a new instrume
271269
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L234>
272270
- Appropriate error handling
273271
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L220>
272+
- Isolate sync and async test
273+
- 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.
274+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/60fb936b7e5371b3e5587074906c49fb873cbd76/instrumentation/opentelemetry-instrumentation-grpc/tests/test_aio_server_interceptor.py#L84>
274275

275276
## Expectations from contributors
276277

exporter/opentelemetry-exporter-prometheus-remote-write/test-requirements.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
asgiref==3.7.2
22
certifi==2024.2.2
33
charset-normalizer==3.3.2
4-
cramjam==2.8.1
4+
# We can drop this after bumping baseline to pypy-39
5+
cramjam==2.1.0; platform_python_implementation == "PyPy"
6+
cramjam==2.8.1; platform_python_implementation != "PyPy"
57
Deprecated==1.2.14
68
idna==3.7
79
importlib-metadata==6.11.0
@@ -17,5 +19,5 @@ tomli==2.0.1
1719
typing_extensions==4.10.0
1820
urllib3==2.2.2
1921
wrapt==1.16.0
20-
zipp==3.17.0
22+
zipp==3.19.2
2123
-e exporter/opentelemetry-exporter-prometheus-remote-write

exporter/opentelemetry-exporter-richconsole/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ rich==13.7.1
1414
tomli==2.0.1
1515
typing_extensions==4.10.0
1616
wrapt==1.16.0
17-
zipp==3.17.0
17+
zipp==3.19.2
1818
-e exporter/opentelemetry-exporter-richconsole

instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ tomli==2.0.1
1515
typing_extensions==4.9.0
1616
wrapt==1.16.0
1717
yarl==1.9.4
18-
zipp==3.17.0
18+
zipp==3.19.2
1919
-e opentelemetry-instrumentation
2020
-e instrumentation/opentelemetry-instrumentation-aio-pika

instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ tomli==2.0.1
1515
typing_extensions==4.9.0
1616
wrapt==1.16.0
1717
yarl==1.9.4
18-
zipp==3.17.0
18+
zipp==3.19.2
1919
-e opentelemetry-instrumentation
2020
-e instrumentation/opentelemetry-instrumentation-aio-pika

instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-2.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ tomli==2.0.1
1515
typing_extensions==4.9.0
1616
wrapt==1.16.0
1717
yarl==1.9.4
18-
zipp==3.17.0
18+
zipp==3.19.2
1919
-e opentelemetry-instrumentation
2020
-e instrumentation/opentelemetry-instrumentation-aio-pika

instrumentation/opentelemetry-instrumentation-aio-pika/test-requirements-3.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ tomli==2.0.1
1515
typing_extensions==4.9.0
1616
wrapt==1.16.0
1717
yarl==1.9.4
18-
zipp==3.17.0
18+
zipp==3.19.2
1919
-e opentelemetry-instrumentation
2020
-e instrumentation/opentelemetry-instrumentation-aio-pika

instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ aiosignal==1.3.1
33
asgiref==3.7.2
44
async-timeout==4.0.3
55
blinker==1.7.0
6-
certifi==2024.2.2
6+
certifi==2024.7.4
77
charset-normalizer==3.3.2
88
click==8.1.7
99
Deprecated==1.2.14
@@ -28,7 +28,7 @@ urllib3==2.2.2
2828
Werkzeug==3.0.3
2929
wrapt==1.16.0
3030
yarl==1.9.4
31-
zipp==3.17.0
31+
zipp==3.19.2
3232
-e opentelemetry-instrumentation
3333
-e util/opentelemetry-util-http
3434
-e instrumentation/opentelemetry-instrumentation-aiohttp-client

instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tomli==2.0.1
1818
typing_extensions==4.10.0
1919
wrapt==1.16.0
2020
yarl==1.9.4
21-
zipp==3.17.0
21+
zipp==3.19.2
2222
-e opentelemetry-instrumentation
2323
-e util/opentelemetry-util-http
2424
-e instrumentation/opentelemetry-instrumentation-aiohttp-server

instrumentation/opentelemetry-instrumentation-aiopg/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pytest==7.4.4
1313
tomli==2.0.1
1414
typing_extensions==4.10.0
1515
wrapt==1.16.0
16-
zipp==3.17.0
16+
zipp==3.19.2
1717
-e opentelemetry-instrumentation
1818
-e instrumentation/opentelemetry-instrumentation-dbapi
1919
-e instrumentation/opentelemetry-instrumentation-aiopg

instrumentation/opentelemetry-instrumentation-asgi/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pytest==7.4.4
99
tomli==2.0.1
1010
typing_extensions==4.9.0
1111
wrapt==1.16.0
12-
zipp==3.17.0
12+
zipp==3.19.2
1313
-e opentelemetry-instrumentation
1414
-e util/opentelemetry-util-http
1515
-e instrumentation/opentelemetry-instrumentation-asgi

instrumentation/opentelemetry-instrumentation-asyncio/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ pytest-asyncio==0.23.5
1010
tomli==2.0.1
1111
typing_extensions==4.9.0
1212
wrapt==1.16.0
13-
zipp==3.17.0
13+
zipp==3.19.2
1414
-e opentelemetry-instrumentation
1515
-e instrumentation/opentelemetry-instrumentation-asyncio

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import asyncio
15+
import sys
16+
from unittest import skipIf
1517
from unittest.mock import patch
1618

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

4244
# Asyncio anext() does not have __name__ attribute, which is used to determine if the coroutine should be traced.
4345
# This test is to ensure that the instrumentation does not break when the coroutine does not have __name__ attribute.
46+
@skipIf(
47+
sys.version_info < (3, 10), "anext is only available in Python 3.10+"
48+
)
4449
def test_asyncio_anext(self):
4550
async def main():
4651
async def async_gen():

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_cancellation.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ def tearDown(self):
4545

4646
def test_cancel(self):
4747
with self._tracer.start_as_current_span("root", kind=SpanKind.SERVER):
48-
asyncio.run(cancellation_create_task())
48+
try:
49+
asyncio.run(cancellation_create_task())
50+
except asyncio.CancelledError:
51+
pass
4952
spans = self.memory_exporter.get_finished_spans()
5053
self.assertEqual(len(spans), 3)
5154
self.assertEqual(spans[0].context.trace_id, spans[1].context.trace_id)

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_taskgroup.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import asyncio
1515
import sys
16+
from unittest import skipIf
1617
from unittest.mock import patch
1718

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

2627
from .common_test_func import async_func
2728

28-
py11 = False
29-
if sys.version_info >= (3, 11):
30-
py11 = True
31-
3229

3330
class TestAsyncioTaskgroup(TestBase):
3431
@patch.dict(
@@ -46,11 +43,11 @@ def tearDown(self):
4643
super().tearDown()
4744
AsyncioInstrumentor().uninstrument()
4845

46+
@skipIf(
47+
sys.version_info < (3, 11),
48+
"TaskGroup is only available in Python 3.11+",
49+
)
4950
def test_task_group_create_task(self):
50-
# TaskGroup is only available in Python 3.11+
51-
if not py11:
52-
return
53-
5451
async def main():
5552
async with asyncio.TaskGroup() as tg: # pylint: disable=no-member
5653
for _ in range(10):

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_to_thread.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import asyncio
1515
import sys
16+
from unittest import skipIf
1617
from unittest.mock import patch
1718

1819
# pylint: disable=no-name-in-module
@@ -40,34 +41,34 @@ def tearDown(self):
4041
super().tearDown()
4142
AsyncioInstrumentor().uninstrument()
4243

44+
@skipIf(
45+
sys.version_info < (3, 9), "to_thread is only available in Python 3.9+"
46+
)
4347
def test_to_thread(self):
44-
# to_thread is only available in Python 3.9+
45-
if sys.version_info >= (3, 9):
46-
47-
def multiply(x, y):
48-
return x * y
48+
def multiply(x, y):
49+
return x * y
4950

50-
async def to_thread():
51-
result = await asyncio.to_thread(multiply, 2, 3)
52-
assert result == 6
51+
async def to_thread():
52+
result = await asyncio.to_thread(multiply, 2, 3)
53+
assert result == 6
5354

54-
with self._tracer.start_as_current_span("root"):
55-
asyncio.run(to_thread())
56-
spans = self.memory_exporter.get_finished_spans()
55+
with self._tracer.start_as_current_span("root"):
56+
asyncio.run(to_thread())
57+
spans = self.memory_exporter.get_finished_spans()
5758

58-
self.assertEqual(len(spans), 2)
59-
assert spans[0].name == "asyncio to_thread-multiply"
60-
for metric in (
61-
self.memory_metrics_reader.get_metrics_data()
62-
.resource_metrics[0]
63-
.scope_metrics[0]
64-
.metrics
65-
):
66-
if metric.name == "asyncio.process.duration":
67-
for point in metric.data.data_points:
68-
self.assertEqual(point.attributes["type"], "to_thread")
69-
self.assertEqual(point.attributes["name"], "multiply")
70-
if metric.name == "asyncio.process.created":
71-
for point in metric.data.data_points:
72-
self.assertEqual(point.attributes["type"], "to_thread")
73-
self.assertEqual(point.attributes["name"], "multiply")
59+
self.assertEqual(len(spans), 2)
60+
assert spans[0].name == "asyncio to_thread-multiply"
61+
for metric in (
62+
self.memory_metrics_reader.get_metrics_data()
63+
.resource_metrics[0]
64+
.scope_metrics[0]
65+
.metrics
66+
):
67+
if metric.name == "asyncio.process.duration":
68+
for point in metric.data.data_points:
69+
self.assertEqual(point.attributes["type"], "to_thread")
70+
self.assertEqual(point.attributes["name"], "multiply")
71+
if metric.name == "asyncio.process.created":
72+
for point in metric.data.data_points:
73+
self.assertEqual(point.attributes["type"], "to_thread")
74+
self.assertEqual(point.attributes["name"], "multiply")

instrumentation/opentelemetry-instrumentation-asyncpg/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ pytest==7.4.4
1111
tomli==2.0.1
1212
typing_extensions==4.9.0
1313
wrapt==1.16.0
14-
zipp==3.17.0
14+
zipp==3.19.2
1515
-e opentelemetry-instrumentation
1616
-e instrumentation/opentelemetry-instrumentation-asyncpg

0 commit comments

Comments
 (0)