Skip to content

Commit

Permalink
Merge branch 'main' into feature/http-route-in-metric
Browse files Browse the repository at this point in the history
  • Loading branch information
GonzaloGuasch authored Jul 1, 2024
2 parents b2c8849 + 58a6d3a commit 447624a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ suggestion-mode=yes
# active Python interpreter and may run arbitrary code.
unsafe-load-any-extension=no

# Run python dependant checks considering the baseline version
py-version=3.8


[MESSAGES CONTROL]

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2573](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2573))
- `opentelemetry-instrumentation-confluent-kafka` Add support for version 2.4.0 of confluent_kafka
([#2616](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2616))
- `opentelemetry-instrumentation-confluent-kafka` Add support for produce purge
([#2638](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2638))

### Breaking changes

Expand Down
48 changes: 42 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ $ pip install tox

You can run `tox` with the following arguments:

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

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

```console
$ pre-commit install
```

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

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

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

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:

1. First time run (e.g., opentelemetry-instrumentation-aiopg)
```console
tox -e py312-test-instrumentation-aiopg
```
2. Run tests again without pre-steps:
```console
.tox/py312-test-instrumentation-aiopg/bin/pytest instrumentation/opentelemetry-instrumentation-aiopg
```

### Testing against a different Core repo branch/commit

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:

```sh
CORE_REPO_SHA=c49ad57bfe35cfc69bfa863d74058ca9bec55fc3 tox
```

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

## Style Guide

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

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.

## Updating supported Python versions

### Bumping the Python baseline

When updating the minimum supported Python version remember to:

- Remove the version in `pyproject.toml` trove classifiers
- Remove the version from `tox.ini`
- Search for `sys.version_info` usage and remove code for unsupported versions
- Bump `py-version` in `.pylintrc` for Python version dependent checks

### Adding support for a new Python release

When adding support for a new Python release remember to:

- Add the version in `tox.ini`
- Add the version in `pyproject.toml` trove classifiers
- Update github workflows accordingly; lint and benchmarks use the latest supported version
- Update `.pre-commit-config.yaml`
- Update tox examples in the documentation
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ The Python auto-instrumentation libraries for [OpenTelemetry](https://openteleme
* [Releasing](#releasing)
* [Releasing a package as `1.0` stable](#releasing-a-package-as-10-stable)
* [Contributing](#contributing)
* [Running Tests Locally](#running-tests-locally)
* [Thanks to all the people who already contributed](#thanks-to-all-the-people-who-already-contributed)

## Installation
Expand Down Expand Up @@ -143,14 +142,6 @@ Emeritus Maintainers:

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

## Running Tests Locally

1. Go to your Contrib repo directory. `cd ~/git/opentelemetry-python-contrib`.
2. Create a virtual env in your Contrib repo directory. `python3 -m venv my_test_venv`.
3. Activate your virtual env. `source my_test_venv/bin/activate`.
4. Make sure you have `tox` installed. `pip install tox`.
5. Run tests for a package. (e.g. `tox -e test-instrumentation-flask`.)

### Thanks to all the people who already contributed

<a href="https://github.com/open-telemetry/opentelemetry-python-contrib/graphs/contributors">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def flush(self, timeout=-1):
def poll(self, timeout=-1):
return self._producer.poll(timeout)

def purge(self, in_queue=True, in_flight=True, blocking=True):
self._producer.purge(in_queue, in_flight, blocking)

def produce(
self, topic, value=None, *args, **kwargs
): # pylint: disable=keyword-arg-before-vararg
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,11 @@ commands_pre =
processor-baggage: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
processor-baggage: pip install -r {toxinidir}/processor/opentelemetry-processor-baggage/test-requirements.txt

http: pip install opentelemetry-api@{env:CORE_REPO}\#egg=opentelemetry-api&subdirectory=opentelemetry-api
http: pip install opentelemetry-semantic-conventions@{env:CORE_REPO}\#egg=opentelemetry-semantic-conventions&subdirectory=opentelemetry-semantic-conventions
http: pip install opentelemetry-sdk@{env:CORE_REPO}\#egg=opentelemetry-sdk&subdirectory=opentelemetry-sdk
http: pip install opentelemetry-test-utils@{env:CORE_REPO}\#egg=opentelemetry-test-utils&subdirectory=tests/opentelemetry-test-utils
http: pip install -r {toxinidir}/util/opentelemetry-util-http/test-requirements.txt
http: pip install {toxinidir}/util/opentelemetry-util-http

; In order to get a health coverage report,
Expand Down
12 changes: 12 additions & 0 deletions util/opentelemetry-util-http/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
asgiref==3.7.2
Deprecated==1.2.14
importlib-metadata==6.11.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.5.0
py-cpuinfo==9.0.0
pytest==7.4.4
pytest-benchmark==4.0.0
tomli==2.0.1
typing_extensions==4.10.0
-e opentelemetry-instrumentation
4 changes: 2 additions & 2 deletions util/opentelemetry-util-http/tests/test_sanitize_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_standard_method_lowercase(self):

def test_nonstandard_method(self):
method = sanitize_method("UNKNOWN")
self.assertEqual(method, "NONSTANDARD")
self.assertEqual(method, "_OTHER")

@patch.dict(
"os.environ",
Expand All @@ -42,4 +42,4 @@ def test_nonstandard_method(self):
)
def test_nonstandard_method_allowed(self):
method = sanitize_method("UNKNOWN")
self.assertEqual(method, "NONSTANDARD")
self.assertEqual(method, "UNKNOWN")

0 comments on commit 447624a

Please sign in to comment.