Skip to content

Commit 447624a

Browse files
Merge branch 'main' into feature/http-route-in-metric
2 parents b2c8849 + 58a6d3a commit 447624a

File tree

8 files changed

+69
-17
lines changed

8 files changed

+69
-17
lines changed

.pylintrc

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ suggestion-mode=yes
4545
# active Python interpreter and may run arbitrary code.
4646
unsafe-load-any-extension=no
4747

48+
# Run python dependant checks considering the baseline version
49+
py-version=3.8
50+
4851

4952
[MESSAGES CONTROL]
5053

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
([#2573](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2573))
2121
- `opentelemetry-instrumentation-confluent-kafka` Add support for version 2.4.0 of confluent_kafka
2222
([#2616](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2616))
23+
- `opentelemetry-instrumentation-confluent-kafka` Add support for produce purge
24+
([#2638](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2638))
2325

2426
### Breaking changes
2527

CONTRIBUTING.md

+42-6
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ $ pip install tox
6060

6161
You can run `tox` with the following arguments:
6262

63-
- `tox` to run all existing tox commands, including unit tests for all packages
63+
* `tox` to run all existing tox commands, including unit tests for all packages
6464
under multiple Python versions
65-
- `tox -e docs` to regenerate the API docs
66-
- `tox -e py312-test-instrumentation-aiopg` to e.g. run the aiopg instrumentation unit tests under a specific
65+
* `tox -e docs` to regenerate the API docs
66+
* `tox -e py312-test-instrumentation-aiopg` to e.g. run the aiopg instrumentation unit tests under a specific
6767
Python version
68-
- `tox -e spellcheck` to run a spellcheck on all the code
69-
- `tox -e lint-some-package` to run lint checks on `some-package`
68+
* `tox -e spellcheck` to run a spellcheck on all the code
69+
* `tox -e lint-some-package` to run lint checks on `some-package`
7070

7171
`black` and `isort` are executed when `tox -e lint` is run. The reported errors can be tedious to fix manually.
7272
An easier way to do so is:
@@ -84,6 +84,7 @@ You can also configure it to run lint tools automatically before committing with
8484

8585
```console
8686
$ pre-commit install
87+
```
8788

8889
See
8990
[`tox.ini`](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/tox.ini)
@@ -161,6 +162,7 @@ Open a pull request against the main `opentelemetry-python-contrib` repo.
161162

162163
* If the PR is not ready for review, please put `[WIP]` in the title, tag it
163164
as `work-in-progress`, or mark it as [`draft`](https://github.blog/2019-02-14-introducing-draft-pull-requests/).
165+
* Make sure tests and lint are passing locally before requesting a review.
164166
* Make sure CLA is signed and CI is clear.
165167

166168
### How to Get PRs Reviewed
@@ -216,13 +218,26 @@ For a deeper discussion, see: https://github.com/open-telemetry/opentelemetry-sp
216218
2. Make sure you have `tox` installed. `pip install tox`.
217219
3. Run `tox` without any arguments to run tests for all the packages. Read more about [tox](https://tox.readthedocs.io/en/latest/).
218220

221+
Some tests can be slow due to pre-steps that do dependencies installs. To help with that, you can run tox a first time, and after that run the tests using previous installed dependencies in toxdir as following:
222+
223+
1. First time run (e.g., opentelemetry-instrumentation-aiopg)
224+
```console
225+
tox -e py312-test-instrumentation-aiopg
226+
```
227+
2. Run tests again without pre-steps:
228+
```console
229+
.tox/py312-test-instrumentation-aiopg/bin/pytest instrumentation/opentelemetry-instrumentation-aiopg
230+
```
231+
219232
### Testing against a different Core repo branch/commit
220233

221234
Some of the tox targets install packages from the [OpenTelemetry Python Core Repository](https://github.com/open-telemetry/opentelemetry-python) via pip. The version of the packages installed defaults to the main branch in that repository when tox is run locally. It is possible to install packages tagged with a specific git commit hash by setting an environment variable before running tox as per the following example:
222235

236+
```sh
223237
CORE_REPO_SHA=c49ad57bfe35cfc69bfa863d74058ca9bec55fc3 tox
238+
```
224239

225-
The continuation integration overrides that environment variable with as per the configuration [here](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/.github/workflows/test.yml#L9).
240+
The continuous integration overrides that environment variable with as per the configuration [here](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/.github/workflows/test.yml#L9).
226241

227242
## Style Guide
228243

@@ -260,3 +275,24 @@ Below is a checklist of things to be mindful of when implementing a new instrume
260275
## Expectations from contributors
261276

262277
OpenTelemetry is an open source community, and as such, greatly encourages contributions from anyone interested in the project. With that being said, there is a certain level of expectation from contributors even after a pull request is merged, specifically pertaining to instrumentations. The OpenTelemetry Python community expects contributors to maintain a level of support and interest in the instrumentations they contribute. This is to ensure that the instrumentation does not become stale and still functions the way the original contributor intended. Some instrumentations also pertain to libraries that the current members of the community are not so familiar with, so it is necessary to rely on the expertise of the original contributing parties.
278+
279+
## Updating supported Python versions
280+
281+
### Bumping the Python baseline
282+
283+
When updating the minimum supported Python version remember to:
284+
285+
- Remove the version in `pyproject.toml` trove classifiers
286+
- Remove the version from `tox.ini`
287+
- Search for `sys.version_info` usage and remove code for unsupported versions
288+
- Bump `py-version` in `.pylintrc` for Python version dependent checks
289+
290+
### Adding support for a new Python release
291+
292+
When adding support for a new Python release remember to:
293+
294+
- Add the version in `tox.ini`
295+
- Add the version in `pyproject.toml` trove classifiers
296+
- Update github workflows accordingly; lint and benchmarks use the latest supported version
297+
- Update `.pre-commit-config.yaml`
298+
- Update tox examples in the documentation

README.md

-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ The Python auto-instrumentation libraries for [OpenTelemetry](https://openteleme
4646
* [Releasing](#releasing)
4747
* [Releasing a package as `1.0` stable](#releasing-a-package-as-10-stable)
4848
* [Contributing](#contributing)
49-
* [Running Tests Locally](#running-tests-locally)
5049
* [Thanks to all the people who already contributed](#thanks-to-all-the-people-who-already-contributed)
5150

5251
## Installation
@@ -143,14 +142,6 @@ Emeritus Maintainers:
143142

144143
*Find more about the maintainer role in [community repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*
145144

146-
## Running Tests Locally
147-
148-
1. Go to your Contrib repo directory. `cd ~/git/opentelemetry-python-contrib`.
149-
2. Create a virtual env in your Contrib repo directory. `python3 -m venv my_test_venv`.
150-
3. Activate your virtual env. `source my_test_venv/bin/activate`.
151-
4. Make sure you have `tox` installed. `pip install tox`.
152-
5. Run tests for a package. (e.g. `tox -e test-instrumentation-flask`.)
153-
154145
### Thanks to all the people who already contributed
155146

156147
<a href="https://github.com/open-telemetry/opentelemetry-python-contrib/graphs/contributors">

instrumentation/opentelemetry-instrumentation-confluent-kafka/src/opentelemetry/instrumentation/confluent_kafka/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ def flush(self, timeout=-1):
156156
def poll(self, timeout=-1):
157157
return self._producer.poll(timeout)
158158

159+
def purge(self, in_queue=True, in_flight=True, blocking=True):
160+
self._producer.purge(in_queue, in_flight, blocking)
161+
159162
def produce(
160163
self, topic, value=None, *args, **kwargs
161164
): # pylint: disable=keyword-arg-before-vararg

tox.ini

+5
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,11 @@ commands_pre =
761761
processor-baggage: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
762762
processor-baggage: pip install -r {toxinidir}/processor/opentelemetry-processor-baggage/test-requirements.txt
763763

764+
http: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
765+
http: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
766+
http: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
767+
http: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
768+
http: pip install -r {toxinidir}/util/opentelemetry-util-http/test-requirements.txt
764769
http: pip install {toxinidir}/util/opentelemetry-util-http
765770

766771
; In order to get a health coverage report,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
asgiref==3.7.2
2+
Deprecated==1.2.14
3+
importlib-metadata==6.11.0
4+
iniconfig==2.0.0
5+
packaging==24.0
6+
pluggy==1.5.0
7+
py-cpuinfo==9.0.0
8+
pytest==7.4.4
9+
pytest-benchmark==4.0.0
10+
tomli==2.0.1
11+
typing_extensions==4.10.0
12+
-e opentelemetry-instrumentation

util/opentelemetry-util-http/tests/test_sanitize_method.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_standard_method_lowercase(self):
3232

3333
def test_nonstandard_method(self):
3434
method = sanitize_method("UNKNOWN")
35-
self.assertEqual(method, "NONSTANDARD")
35+
self.assertEqual(method, "_OTHER")
3636

3737
@patch.dict(
3838
"os.environ",
@@ -42,4 +42,4 @@ def test_nonstandard_method(self):
4242
)
4343
def test_nonstandard_method_allowed(self):
4444
method = sanitize_method("UNKNOWN")
45-
self.assertEqual(method, "NONSTANDARD")
45+
self.assertEqual(method, "UNKNOWN")

0 commit comments

Comments
 (0)