Skip to content

Commit 3c7d60c

Browse files
authored
Merge branch 'main' into add-type-hints-to-dbapi
2 parents 80cd44e + 1ddba1b commit 3c7d60c

File tree

31 files changed

+897
-712
lines changed

31 files changed

+897
-712
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Added
15+
16+
- `opentelemetry-instrumentation-confluent-kafka` Add support for confluent-kafka <=2.7.0
17+
([#3100](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3100))
18+
- Add support to database stability opt-in in `_semconv` utilities and add tests
19+
([#3111](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3111))
20+
21+
### Fixed
22+
23+
- `opentelemetry-instrumentation-httpx` Fix `RequestInfo`/`ResponseInfo` type hints
24+
([#3105](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3105))
1425
- `opentelemetry-instrumentation-dbapi` Move `TracedCursorProxy` and `TracedConnectionProxy` to the module level
1526
([#3068](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3068))
1627

CONTRIBUTING.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ You can run `tox` with the following arguments:
6363

6464
* `tox` to run all existing tox commands, including unit tests for all packages
6565
under multiple Python versions
66-
* `tox -e docs` to regenerate the API docs
66+
* `tox -e docs` to regenerate all docs
6767
* `tox -e py312-test-instrumentation-aiopg` to e.g. run the aiopg instrumentation unit tests under a specific
6868
Python version
6969
* `tox -e spellcheck` to run a spellcheck on all the code
@@ -89,7 +89,9 @@ for more detail on available tox commands.
8989

9090
### Troubleshooting
9191

92-
> 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.
92+
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.
93+
94+
For `docs` building, you may need to install `mysql-client` and other required dependencies as necessary. Ensure the Python version used in your local setup matches the version used in the [CI](./.github/workflows/) to maintain compatibility when building the documentation.
9395

9496
### Benchmarks
9597

@@ -278,6 +280,20 @@ Below is a checklist of things to be mindful of when implementing a new instrume
278280
- Testing
279281
- When adding a new instrumentation remember to update `tox.ini` adding appropriate rules in `envlist`, `command_pre` and `commands` sections
280282

283+
### Update supported instrumentation package versions
284+
285+
- Navigate to the **instrumentation package directory:**
286+
- Update **`pyproject.toml`** file by modifying _instruments_ entry in the `[project.optional-dependencies]` section with the new version constraint
287+
- Update `_instruments` variable in instrumentation **`package.py`** file with the new version constraint
288+
- At the **root of the project directory**, run `tox -e generate` to regenerate necessary files
289+
290+
If you're adding support for a new version of the instrumentation package, follow these additional steps:
291+
292+
- At the **instrumentation package directory:** Add new test-requirements.txt file with the respective package version required for testing
293+
- At the **root of the project directory**: Add a new test environment entry for the package version in [tox.ini](./tox.ini) and run `tox -e generate-workflows` to regenerate new workflows accordingly. In the same [tox.ini](./tox.ini) file, search for `opentelemetry-instrumentation-{package}/test-requirements` and add a new line to point to the new test-requirements.txt you created in the previous step so tox can install the correct requirements.
294+
295+
Example PRs: [#2976](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2976), [#2845](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2845)
296+
281297
## Guideline for GenAI instrumentations
282298

283299
Instrumentations that relate to [Generative AI](https://opentelemetry.io/docs/specs/semconv/gen-ai/) systems will be placed in the [instrumentation-genai](./instrumentation-genai) folder. This section covers contributions related to those instrumentations. Please note that the [guidelines for instrumentations](#guideline-for-instrumentations) and [expectations from contributors](#expectations-from-contributors) still apply.

dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pytest==7.4.4
88
pytest-cov==4.1.0
99
readme-renderer==42.0
1010
bleach==4.1.0 # transient dependency for readme-renderer
11-
protobuf~=3.13
1211
markupsafe>=2.0.1
1312
codespell==2.1.0
1413
requests==2.32.3

docs/nitpick-exceptions.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ py-class=
2929
httpx.SyncByteStream
3030
httpx.AsyncByteStream
3131
httpx.Response
32+
httpx.URL
33+
httpx.Headers
3234
aiohttp.web_request.Request
3335
yarl.URL
3436
cimpl.Producer
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
openai~=1.54.4
1+
openai~=1.57.3
22

3-
opentelemetry-sdk~=1.28.2
4-
opentelemetry-exporter-otlp-proto-grpc~=1.28.2
3+
opentelemetry-sdk~=1.29.0
4+
opentelemetry-exporter-otlp-proto-grpc~=1.29.0
55
opentelemetry-instrumentation-openai-v2~=2.0b0
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
openai~=1.54.4
1+
openai~=1.57.3
22

3-
opentelemetry-sdk~=1.28.2
4-
opentelemetry-exporter-otlp-proto-grpc~=1.28.2
5-
opentelemetry-distro~=0.49b2
3+
opentelemetry-sdk~=1.29.0
4+
opentelemetry-exporter-otlp-proto-grpc~=1.29.0
5+
opentelemetry-distro~=0.50b0
66
opentelemetry-instrumentation-openai-v2~=2.0b0

instrumentation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
| [opentelemetry-instrumentation-cassandra](./opentelemetry-instrumentation-cassandra) | cassandra-driver ~= 3.25,scylla-driver ~= 3.25 | No | experimental
1717
| [opentelemetry-instrumentation-celery](./opentelemetry-instrumentation-celery) | celery >= 4.0, < 6.0 | No | experimental
1818
| [opentelemetry-instrumentation-click](./opentelemetry-instrumentation-click) | click >= 8.1.3, < 9.0.0 | No | experimental
19-
| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka >= 1.8.2, <= 2.4.0 | No | experimental
19+
| [opentelemetry-instrumentation-confluent-kafka](./opentelemetry-instrumentation-confluent-kafka) | confluent-kafka >= 1.8.2, <= 2.7.0 | No | experimental
2020
| [opentelemetry-instrumentation-dbapi](./opentelemetry-instrumentation-dbapi) | dbapi | No | experimental
2121
| [opentelemetry-instrumentation-django](./opentelemetry-instrumentation-django) | django >= 1.10 | Yes | experimental
2222
| [opentelemetry-instrumentation-elasticsearch](./opentelemetry-instrumentation-elasticsearch) | elasticsearch >= 6.0 | No | experimental

instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ def response_hook(span: Span, params: typing.Union[
9292
from opentelemetry import trace
9393
from opentelemetry.instrumentation._semconv import (
9494
_get_schema_url,
95-
_HTTPStabilityMode,
9695
_OpenTelemetrySemanticConventionStability,
9796
_OpenTelemetryStabilitySignalType,
9897
_report_new,
9998
_set_http_method,
10099
_set_http_url,
101100
_set_status,
101+
_StabilityMode,
102102
)
103103
from opentelemetry.instrumentation.aiohttp_client.package import _instruments
104104
from opentelemetry.instrumentation.aiohttp_client.version import __version__
@@ -142,7 +142,7 @@ def _set_http_status_code_attribute(
142142
span,
143143
status_code,
144144
metric_attributes=None,
145-
sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT,
145+
sem_conv_opt_in_mode=_StabilityMode.DEFAULT,
146146
):
147147
status_code_str = str(status_code)
148148
try:
@@ -169,7 +169,7 @@ def create_trace_config(
169169
request_hook: _RequestHookT = None,
170170
response_hook: _ResponseHookT = None,
171171
tracer_provider: TracerProvider = None,
172-
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
172+
sem_conv_opt_in_mode: _StabilityMode = _StabilityMode.DEFAULT,
173173
) -> aiohttp.TraceConfig:
174174
"""Create an aiohttp-compatible trace configuration.
175175
@@ -326,7 +326,7 @@ def _instrument(
326326
trace_configs: typing.Optional[
327327
typing.Sequence[aiohttp.TraceConfig]
328328
] = None,
329-
sem_conv_opt_in_mode: _HTTPStabilityMode = _HTTPStabilityMode.DEFAULT,
329+
sem_conv_opt_in_mode: _StabilityMode = _StabilityMode.DEFAULT,
330330
):
331331
"""Enables tracing of all ClientSessions
332332

instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
from opentelemetry.instrumentation import aiohttp_client
3030
from opentelemetry.instrumentation._semconv import (
3131
OTEL_SEMCONV_STABILITY_OPT_IN,
32-
_HTTPStabilityMode,
3332
_OpenTelemetrySemanticConventionStability,
33+
_StabilityMode,
3434
)
3535
from opentelemetry.instrumentation.aiohttp_client import (
3636
AioHttpClientInstrumentor,
@@ -150,7 +150,7 @@ def test_status_codes_new_semconv(self):
150150
path = "test-path?query=param#foobar"
151151
host, port = self._http_request(
152152
trace_config=aiohttp_client.create_trace_config(
153-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
153+
sem_conv_opt_in_mode=_StabilityMode.HTTP
154154
),
155155
url=f"/{path}",
156156
status_code=status_code,
@@ -173,7 +173,7 @@ def test_status_codes_both_semconv(self):
173173
path = "test-path?query=param#foobar"
174174
host, port = self._http_request(
175175
trace_config=aiohttp_client.create_trace_config(
176-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
176+
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
177177
),
178178
url=f"/{path}",
179179
status_code=status_code,
@@ -213,7 +213,7 @@ def test_schema_url_new_semconv(self):
213213
with self.subTest(status_code=200):
214214
self._http_request(
215215
trace_config=aiohttp_client.create_trace_config(
216-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
216+
sem_conv_opt_in_mode=_StabilityMode.HTTP
217217
),
218218
url="/test-path?query=param#foobar",
219219
status_code=200,
@@ -230,7 +230,7 @@ def test_schema_url_both_semconv(self):
230230
with self.subTest(status_code=200):
231231
self._http_request(
232232
trace_config=aiohttp_client.create_trace_config(
233-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
233+
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
234234
),
235235
url="/test-path?query=param#foobar",
236236
status_code=200,
@@ -398,7 +398,7 @@ async def request_handler(request):
398398

399399
host, port = self._http_request(
400400
trace_config=aiohttp_client.create_trace_config(
401-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
401+
sem_conv_opt_in_mode=_StabilityMode.HTTP
402402
),
403403
url="/test",
404404
request_handler=request_handler,
@@ -426,7 +426,7 @@ async def request_handler(request):
426426

427427
host, port = self._http_request(
428428
trace_config=aiohttp_client.create_trace_config(
429-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP_DUP
429+
sem_conv_opt_in_mode=_StabilityMode.HTTP_DUP
430430
),
431431
url="/test",
432432
request_handler=request_handler,
@@ -546,7 +546,7 @@ async def do_request(url):
546546
def test_nonstandard_http_method_new_semconv(self):
547547
trace_configs = [
548548
aiohttp_client.create_trace_config(
549-
sem_conv_opt_in_mode=_HTTPStabilityMode.HTTP
549+
sem_conv_opt_in_mode=_StabilityMode.HTTP
550550
)
551551
]
552552
app = HttpServerMock("nonstandard_method")

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
205205
_filter_semconv_active_request_count_attr,
206206
_filter_semconv_duration_attrs,
207207
_get_schema_url,
208-
_HTTPStabilityMode,
209208
_OpenTelemetrySemanticConventionStability,
210209
_OpenTelemetryStabilitySignalType,
211210
_report_new,
@@ -225,6 +224,7 @@ def client_response_hook(span: Span, scope: dict[str, Any], message: dict[str, A
225224
_set_http_url,
226225
_set_http_user_agent,
227226
_set_status,
227+
_StabilityMode,
228228
)
229229
from opentelemetry.instrumentation.asgi.types import (
230230
ClientRequestHook,
@@ -324,7 +324,7 @@ def set(self, carrier: dict, key: str, value: str) -> None: # pylint: disable=n
324324

325325
# pylint: disable=too-many-branches
326326
def collect_request_attributes(
327-
scope, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
327+
scope, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
328328
):
329329
"""Collects HTTP request attributes from the ASGI scope and returns a
330330
dictionary to be used as span creation attributes."""
@@ -356,7 +356,7 @@ def collect_request_attributes(
356356
_set_http_url(
357357
result,
358358
remove_url_credentials(http_url),
359-
_HTTPStabilityMode.DEFAULT,
359+
_StabilityMode.DEFAULT,
360360
)
361361
http_method = scope.get("method", "")
362362
if http_method:
@@ -439,7 +439,7 @@ def set_status_code(
439439
span,
440440
status_code,
441441
metric_attributes=None,
442-
sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT,
442+
sem_conv_opt_in_mode=_StabilityMode.DEFAULT,
443443
):
444444
"""Adds HTTP response attributes to span using the status_code argument."""
445445
status_code_str = str(status_code)
@@ -755,12 +755,12 @@ async def __call__(
755755
)
756756
duration_s = default_timer() - start
757757
duration_attrs_old = _parse_duration_attrs(
758-
attributes, _HTTPStabilityMode.DEFAULT
758+
attributes, _StabilityMode.DEFAULT
759759
)
760760
if target:
761761
duration_attrs_old[SpanAttributes.HTTP_TARGET] = target
762762
duration_attrs_new = _parse_duration_attrs(
763-
attributes, _HTTPStabilityMode.HTTP
763+
attributes, _StabilityMode.HTTP
764764
)
765765
if self.duration_histogram_old:
766766
self.duration_histogram_old.record(
@@ -960,7 +960,7 @@ async def otel_send(message: dict[str, Any]):
960960

961961

962962
def _parse_duration_attrs(
963-
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
963+
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
964964
):
965965
return _filter_semconv_duration_attrs(
966966
req_attrs,
@@ -971,7 +971,7 @@ def _parse_duration_attrs(
971971

972972

973973
def _parse_active_request_count_attrs(
974-
req_attrs, sem_conv_opt_in_mode=_HTTPStabilityMode.DEFAULT
974+
req_attrs, sem_conv_opt_in_mode=_StabilityMode.DEFAULT
975975
):
976976
return _filter_semconv_active_request_count_attr(
977977
req_attrs,

0 commit comments

Comments
 (0)