Skip to content

Commit d31b2b6

Browse files
authored
Merge branch 'main' into main
2 parents 856ba3e + 7c12ad9 commit d31b2b6

File tree

201 files changed

+1911
-1080
lines changed

Some content is hidden

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

201 files changed

+1911
-1080
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'release/*'
77
pull_request:
88
env:
9-
CORE_REPO_SHA: 9831afaff5b4d371fd9a14266ab47884546bd971
9+
CORE_REPO_SHA: 84c0e4f38d4fcdb8c13fd3988469fbb8cda28150
1010

1111
jobs:
1212
build:

.pylintrc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# A comma-separated list of package or module names from where C extensions may
44
# be loaded. Extensions are loading into the active Python interpreter and may
55
# run arbitrary code.
6-
extension-pkg-whitelist=
6+
extension-pkg-whitelist=cassandra
77

88
# Add list of files or directories to be excluded. They should be base names, not
99
# paths.
@@ -29,7 +29,7 @@ limit-inference-results=100
2929

3030
# List of plugins (as comma separated values of python modules names) to load,
3131
# usually to register additional checkers.
32-
load-plugins=
32+
load-plugins=pylint.extensions.no_self_use
3333

3434
# Pickle collected data for later comparisons.
3535
persistent=yes
@@ -69,7 +69,6 @@ disable=missing-docstring,
6969
duplicate-code,
7070
ungrouped-imports, # Leave this up to isort
7171
wrong-import-order, # Leave this up to isort
72-
bad-continuation, # Leave this up to black
7372
line-too-long, # Leave this up to black
7473
exec-used,
7574
super-with-arguments, # temp-pylint-upgrade
@@ -81,6 +80,7 @@ disable=missing-docstring,
8180
invalid-overridden-method, # temp-pylint-upgrade
8281
missing-module-docstring, # temp-pylint-upgrade
8382
import-error, # needed as a workaround as reported here: https://github.com/open-telemetry/opentelemetry-python-contrib/issues/290
83+
cyclic-import,
8484

8585
# Enable the message, report, category or checker with the given id(s). You can
8686
# either give multiple identifier separated by comma (,) or put this option
@@ -268,13 +268,6 @@ max-line-length=79
268268
# Maximum number of lines in a module.
269269
max-module-lines=1000
270270

271-
# List of optional constructs for which whitespace checking is disabled. `dict-
272-
# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}.
273-
# `trailing-comma` allows a space between comma and closing bracket: (a, ).
274-
# `empty-line` allows space-only lines.
275-
no-space-check=trailing-comma,
276-
dict-separator
277-
278271
# Allow the body of a class to be on the same line as the declaration if body
279272
# contains single statement.
280273
single-line-class-stmt=no

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
## Version 1.22.0/0.43b0 (2023-12-14)
11+
1012
### Added
1113

1214
- `opentelemetry-instrumentation` Added Otel semantic convention opt-in mechanism
1315
([#1987](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1987))
16+
- `opentelemetry-instrumentation-httpx` Fix mixing async and non async hooks
17+
([#1920](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1920))
18+
- `opentelemetry-instrumentation-requests` Implement new semantic convention opt-in with stable http semantic conventions
19+
([#2002](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2002))
20+
- `opentelemetry-instrument-grpc` Fix arity of context.abort for AIO RPCs
21+
([#2066](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2066))
22+
- Consolidate instrumentation suppression mechanisms and fix bug in httpx instrumentation
23+
([#2061](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2061))
24+
25+
### Fixed
1426

27+
- `opentelemetry-instrumentation-httpx` Remove URL credentials
28+
([#2020](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2020))
29+
- `opentelemetry-instrumentation-urllib`/`opentelemetry-instrumentation-urllib3` Fix metric descriptions to match semantic conventions
30+
([#1959](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1959))
31+
- `opentelemetry-resource-detector-azure` Added dependency for Cloud Resource ID attribute
32+
([#2072](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2072))
33+
1534
## Version 1.21.0/0.42b0 (2023-11-01)
1635

1736
### Added
@@ -27,10 +46,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2746

2847
### Fixed
2948

49+
- `opentelemetry-instrumentation-aio-pika` and `opentelemetry-instrumentation-pika` Fix missing trace context propagation when trace not recording.
50+
([#1969](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1969))
3051
- Fix version of Flask dependency `werkzeug`
3152
([#1980](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1980))
3253
- `opentelemetry-resource-detector-azure` Using new Cloud Resource ID attribute.
3354
([#1976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1976))
55+
- Do not collect `system.network.connections` by default on macOS which was causing exceptions in metrics collection.
56+
([#2008](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2008))
3457

3558
## Version 1.20.0/0.41b0 (2023-09-01)
3659

@@ -1394,6 +1417,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13941417
- `opentelemetry-ext-wsgi` Updates for core library changes
13951418
- `opentelemetry-ext-http-requests` Updates for core library changes
13961419

1420+
- `Added support for PyPy3` Initial release
1421+
## [#1033](https://github.com/open-telemetryopentelemetry-python-contrib/issues/1033)
1422+
13971423
## Version 0.1a0 (2019-09-30)
13981424

13991425
### Added

CONTRIBUTING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ An easier way to do so is:
5252
2. Run `.tox/lint/bin/isort .`
5353

5454
See
55-
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python/blob/main/tox.ini)
55+
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
5656
for more detail on available tox commands.
5757

58+
### Troubleshooting
59+
60+
- Some packages may require additional system wide dependencies to be installed. For example, you may need to install `libpq-dev` to run the postgresql client libraries instrumentation tests. or `libsnappy-dev` to run the prometheus exporter tests. If you encounter a build error, please check the installation instructions for the package you are trying to run tests for.
61+
5862
### Benchmarks
5963

6064
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.

_template/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.43b0.dev"
15+
__version__ = "0.44b0.dev"

dev-requirements.txt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
pylint==2.12.2
2-
flake8~=3.7
3-
isort~=5.6
4-
black>=22.1.0
5-
httpretty~=1.0
6-
mypy==0.790
7-
sphinx
8-
sphinx-rtd-theme~=0.4
9-
sphinx-autodoc-typehints
10-
pytest!=5.2.3
11-
pytest-cov>=2.8
12-
readme-renderer~=24.0
1+
pylint==3.0.2
2+
flake8==6.1.0
3+
isort==5.12.0
4+
black==22.3.0
5+
httpretty==1.1.4
6+
mypy==0.931
7+
sphinx==7.1.2
8+
sphinx-rtd-theme==2.0.0rc4
9+
sphinx-autodoc-typehints==1.25.2
10+
pytest==7.1.3
11+
pytest-cov==4.1.0
12+
readme-renderer==42.0
1313
bleach==4.1.0 # transient dependency for readme-renderer
14-
grpcio-tools==1.29.0
15-
mypy-protobuf>=1.23
1614
protobuf~=3.13
1715
markupsafe>=2.0.1
1816
codespell==2.1.0
1917
requests==2.31.0
2018
ruamel.yaml==0.17.21
19+
flaky==3.7.0

docs-requirements.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
sphinx==4.5.0
2-
sphinx-rtd-theme~=0.4
3-
sphinx-autodoc-typehints
1+
sphinx==7.1.2
2+
sphinx-rtd-theme==2.0.0rc4
3+
sphinx-autodoc-typehints==1.25.2
44

55
# Need to install the api/sdk in the venv for autodoc. Modifying sys.path
66
# doesn't work for pkg_resources.
@@ -45,11 +45,8 @@ remoulade>=0.50
4545
sqlalchemy>=1.0
4646
tornado>=5.1.1
4747
tortoise-orm>=0.17.0
48-
ddtrace>=0.34.0
4948
httpx>=0.18.0
5049

5150
# indirect dependency pins
5251
markupsafe==2.0.1
5352
itsdangerous==2.0.1
54-
55-
docutils==0.16

eachdist.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sortfirst=
1616
ext/*
1717

1818
[stable]
19-
version=1.22.0.dev
19+
version=1.23.0.dev
2020

2121
packages=
2222
opentelemetry-sdk
@@ -34,7 +34,7 @@ packages=
3434
opentelemetry-api
3535

3636
[prerelease]
37-
version=0.43b0.dev
37+
version=0.44b0.dev
3838

3939
packages=
4040
all
@@ -54,6 +54,7 @@ packages=
5454
[lintroots]
5555
extraroots=examples/*,scripts/
5656
subglob=*.py,tests/,test/,src/*,examples/*
57+
ignore=sklearn
5758

5859
[testroots]
5960
extraroots=examples/*,tests/

exporter/opentelemetry-exporter-prometheus-remote-write/src/opentelemetry/exporter/prometheus_remote_write/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.43b0.dev"
15+
__version__ = "0.44b0.dev"

exporter/opentelemetry-exporter-prometheus-remote-write/tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import pytest
44

55
import opentelemetry.test.metrictestutil as metric_util
6+
7+
# pylint: disable=no-name-in-module
68
from opentelemetry.exporter.prometheus_remote_write import (
79
PrometheusRemoteWriteMetricsExporter,
810
)

exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import pytest
1919

20+
# pylint: disable=no-name-in-module
2021
from opentelemetry.exporter.prometheus_remote_write import (
2122
PrometheusRemoteWriteMetricsExporter,
2223
)

exporter/opentelemetry-exporter-richconsole/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ classifiers = [
2727
dependencies = [
2828
"opentelemetry-api ~= 1.12",
2929
"opentelemetry-sdk ~= 1.12",
30-
"opentelemetry-semantic-conventions == 0.43b0.dev",
30+
"opentelemetry-semantic-conventions == 0.44b0.dev",
3131
"rich>=10.0.0",
3232
]
3333

exporter/opentelemetry-exporter-richconsole/src/opentelemetry/exporter/richconsole/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.43b0.dev"
15+
__version__ = "0.44b0.dev"

instrumentation/opentelemetry-instrumentation-aio-pika/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ classifiers = [
2626
]
2727
dependencies = [
2828
"opentelemetry-api ~= 1.5",
29+
"opentelemetry-instrumentation == 0.44b0.dev",
2930
"wrapt >= 1.0.0, < 2.0.0",
3031
]
3132

@@ -35,7 +36,7 @@ instruments = [
3536
]
3637
test = [
3738
"opentelemetry-instrumentation-aio-pika[instruments]",
38-
"opentelemetry-test-utils == 0.43b0.dev",
39+
"opentelemetry-test-utils == 0.44b0.dev",
3940
"pytest",
4041
"wrapt >= 1.0.0, < 2.0.0",
4142
]

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/callback_decorator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
from opentelemetry import context, propagate, trace
2020
from opentelemetry.instrumentation.aio_pika.span_builder import SpanBuilder
21-
from opentelemetry.instrumentation.aio_pika.utils import (
22-
is_instrumentation_enabled,
23-
)
21+
from opentelemetry.instrumentation.utils import is_instrumentation_enabled
2422
from opentelemetry.semconv.trace import MessagingOperationValues
2523
from opentelemetry.trace import Span, Tracer
2624

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/publish_decorator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ async def decorated_publish(
4545
if not span:
4646
return await publish(message, routing_key, **kwargs)
4747
with trace.use_span(span, end_on_exit=True):
48-
if span.is_recording():
49-
propagate.inject(message.properties.headers)
48+
propagate.inject(message.properties.headers)
5049
return_value = await publish(message, routing_key, **kwargs)
5150
return return_value
5251

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/span_builder.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
from aio_pika.abc import AbstractChannel, AbstractMessage
1717

18-
from opentelemetry.instrumentation.aio_pika.utils import (
19-
is_instrumentation_enabled,
20-
)
18+
from opentelemetry.instrumentation.utils import is_instrumentation_enabled
2119
from opentelemetry.semconv.trace import (
2220
MessagingOperationValues,
2321
SpanAttributes,

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/utils.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

instrumentation/opentelemetry-instrumentation-aio-pika/src/opentelemetry/instrumentation/aio_pika/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "0.43b0.dev"
15+
__version__ = "0.44b0.dev"

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import asyncio
1515
from typing import Type
1616
from unittest import TestCase, mock, skipIf
17+
from unittest.mock import MagicMock
1718

1819
from aio_pika import Exchange, RobustExchange
1920

@@ -92,6 +93,36 @@ def test_publish(self):
9293
def test_robust_publish(self):
9394
self._test_publish(RobustExchange)
9495

96+
def _test_publish_works_with_not_recording_span(self, exchange_type):
97+
exchange = exchange_type(CONNECTION_7, CHANNEL_7, EXCHANGE_NAME)
98+
with mock.patch.object(
99+
PublishDecorator, "_get_publish_span"
100+
) as mock_get_publish_span:
101+
mocked_not_recording_span = MagicMock()
102+
mocked_not_recording_span.is_recording.return_value = False
103+
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:
107+
with mock.patch(
108+
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
109+
) as mock_inject:
110+
decorated_publish = PublishDecorator(
111+
self.tracer, exchange
112+
).decorate(mock_publish)
113+
self.loop.run_until_complete(
114+
decorated_publish(MESSAGE, ROUTING_KEY)
115+
)
116+
mock_publish.assert_called_once()
117+
mock_get_publish_span.assert_called_once()
118+
mock_inject.assert_called_once()
119+
120+
def test_publish_works_with_not_recording_span(self):
121+
self._test_publish_works_with_not_recording_span(Exchange)
122+
123+
def test_publish_works_with_not_recording_span_robust(self):
124+
self._test_publish_works_with_not_recording_span(RobustExchange)
125+
95126

96127
@skipIf(AIOPIKA_VERSION_INFO <= (8, 0), "Only for aio_pika 8")
97128
class TestInstrumentedExchangeAioRmq8(TestCase):
@@ -144,3 +175,33 @@ def test_publish(self):
144175

145176
def test_robust_publish(self):
146177
self._test_publish(RobustExchange)
178+
179+
def _test_publish_works_with_not_recording_span(self, exchange_type):
180+
exchange = exchange_type(CONNECTION_7, CHANNEL_7, EXCHANGE_NAME)
181+
with mock.patch.object(
182+
PublishDecorator, "_get_publish_span"
183+
) as mock_get_publish_span:
184+
mocked_not_recording_span = MagicMock()
185+
mocked_not_recording_span.is_recording.return_value = False
186+
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:
190+
with mock.patch(
191+
"opentelemetry.instrumentation.aio_pika.publish_decorator.propagate.inject"
192+
) as mock_inject:
193+
decorated_publish = PublishDecorator(
194+
self.tracer, exchange
195+
).decorate(mock_publish)
196+
self.loop.run_until_complete(
197+
decorated_publish(MESSAGE, ROUTING_KEY)
198+
)
199+
mock_publish.assert_called_once()
200+
mock_get_publish_span.assert_called_once()
201+
mock_inject.assert_called_once()
202+
203+
def test_publish_works_with_not_recording_span(self):
204+
self._test_publish_works_with_not_recording_span(Exchange)
205+
206+
def test_publish_works_with_not_recording_span_robust(self):
207+
self._test_publish_works_with_not_recording_span(RobustExchange)

0 commit comments

Comments
 (0)