Skip to content

Commit 7697dfb

Browse files
authoredMar 14, 2024
Merge branch 'main' into issue_2183
2 parents 932117d + 9b3d0b4 commit 7697dfb

File tree

8 files changed

+91
-31
lines changed

8 files changed

+91
-31
lines changed
 

‎CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## Unreleased
99

1010
### Fixed
11+
- `opentelemetry-instrumentation-celery` Allow Celery instrumentation to be installed multiple times
12+
([#2342](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2342))
1113
- Align gRPC span status codes to OTEL specification ([#1756](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/1756))
1214

1315
## Version 1.23.0/0.44b0 (2024-02-23)

‎CONTRIBUTING.md

+37-20
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,26 @@ on how to become a [**Member**](https://github.com/open-telemetry/community/blob
1313
[**Approver**](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
1414
and [**Maintainer**](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).
1515

16-
## Find a Buddy and get Started Quickly!
16+
## Index
17+
18+
* [Find a Buddy and get Started Quickly](#find-a-buddy-and-get-started-quickly)
19+
* [Development](#development)
20+
* [Troubleshooting](#troubleshooting)
21+
* [Benchmarks](#benchmarks)
22+
* [Pull requests](#pull-requests)
23+
* [How to Send Pull Requests](#how-to-send-pull-requests)
24+
* [How to Receive Comments](#how-to-receive-comments)
25+
* [How to Get PRs Reviewed](#how-to-get-prs-reviewed)
26+
* [How to Get PRs Merged](#how-to-get-prs-merged)
27+
* [Design Choices](#design-choices)
28+
* [Focus on Capabilities, Not Structure Compliance](#focus-on-capabilities-not-structure-compliance)
29+
* [Running Tests Locally](#running-tests-locally)
30+
* [Testing against a different Core repo branch/commit](#testing-against-a-different-core-repo-branchcommit)
31+
* [Style Guide](#style-guide)
32+
* [Guideline for instrumentations](#guideline-for-instrumentations)
33+
* [Expectations from contributors](#expectations-from-contributors)
34+
35+
## Find a Buddy and get Started Quickly
1736

1837
If you are looking for someone to help you find a starting point and be a resource for your first contribution, join our
1938
Slack and find a buddy!
@@ -31,8 +50,8 @@ This project uses [tox](https://tox.readthedocs.io) to automate
3150
some aspects of development, including testing against multiple Python versions.
3251
To install `tox`, run:
3352

34-
```console
35-
$ pip install tox
53+
```sh
54+
pip install tox
3655
```
3756

3857
You can run `tox` with the following arguments:
@@ -57,7 +76,7 @@ for more detail on available tox commands.
5776

5877
### Troubleshooting
5978

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.
79+
> 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.
6180
6281
### Benchmarks
6382

@@ -94,13 +113,13 @@ pull requests (PRs).
94113
To create a new PR, fork the project in GitHub and clone the upstream repo:
95114

96115
```sh
97-
$ git clone https://github.com/open-telemetry/opentelemetry-python-contrib.git
116+
git clone https://github.com/open-telemetry/opentelemetry-python-contrib.git
98117
```
99118

100119
Add your fork as an origin:
101120

102121
```sh
103-
$ git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-python-contrib.git
122+
git remote add fork https://github.com/YOUR_GITHUB_USERNAME/opentelemetry-python-contrib.git
104123
```
105124

106125
Run tests:
@@ -114,10 +133,10 @@ $ tox # execute in the root of the repository
114133
Check out a new branch, make modifications and push the branch to your fork:
115134

116135
```sh
117-
$ git checkout -b feature
136+
git checkout -b feature
118137
# edit files
119-
$ git commit
120-
$ git push fork feature
138+
git commit
139+
git push fork feature
121140
```
122141

123142
Open a pull request against the main `opentelemetry-python-contrib` repo.
@@ -142,6 +161,7 @@ If you are not getting reviews, please contact the respective owners directly.
142161
### How to Get PRs Merged
143162

144163
A PR is considered to be **ready to merge** when:
164+
145165
* It has received two approvals from [Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
146166
/ [Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer)
147167
(at different companies).
@@ -186,8 +206,7 @@ Some of the tox targets install packages from the [OpenTelemetry Python Core Rep
186206

187207
CORE_REPO_SHA=c49ad57bfe35cfc69bfa863d74058ca9bec55fc3 tox
188208

189-
The continuation 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).
190-
209+
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).
191210

192211
## Style Guide
193212

@@ -203,27 +222,25 @@ Below is a checklist of things to be mindful of when implementing a new instrume
203222

204223
- Follow semantic conventions
205224
- The instrumentation should follow the semantic conventions defined [here](https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/semantic-conventions.md)
206-
- Extends from [BaseInstrumentor](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L26)
225+
- Extends from [BaseInstrumentor](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/opentelemetry-instrumentation/src/opentelemetry/instrumentation/instrumentor.py#L35)
207226
- Supports auto-instrumentation
208-
- Add an entry point (ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/f045c43affff6ff1af8fa2f7514a4fdaca97dacf/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml#L44)
227+
- Add an entry point (ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/pyproject.toml#L44>)
209228
- Run `python scripts/generate_instrumentation_bootstrap.py` after adding a new instrumentation package.
210229
- Functionality that is common amongst other instrumentation and can be abstracted [here](https://github.com/open-telemetry/opentelemetry-python-contrib/tree/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation)
211230
- Request/response [hooks](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/408) for http instrumentations
212231
- `suppress_instrumentation` functionality
213-
- ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/3ec77360cb20482b08b30312a6bedc8b946e3fa1/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L111
232+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py#L191>
214233
- Suppress propagation functionality
215234
- https://github.com/open-telemetry/opentelemetry-python-contrib/issues/344 for more context
216235
- `exclude_urls` functionality
217-
- ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/0fcb60d2ad139f78a52edd85b1cc4e32f2e962d0/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py#L91
236+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-flask/src/opentelemetry/instrumentation/flask/__init__.py#L327>
218237
- `url_filter` functionality
219-
- ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/0fcb60d2ad139f78a52edd85b1cc4e32f2e962d0/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py#L235
238+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-aiohttp-client/src/opentelemetry/instrumentation/aiohttp_client/__init__.py#L268>
220239
- `is_recording()` optimization on non-sampled spans
221-
- ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L133
240+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L234>
222241
- Appropriate error handling
223-
- ex. https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L146
224-
242+
- ex. <https://github.com/open-telemetry/opentelemetry-python-contrib/blob/2518a4ac07cb62ad6587dd8f6cbb5f8663a7e179/instrumentation/opentelemetry-instrumentation-requests/src/opentelemetry/instrumentation/requests/__init__.py#L220>
225243

226244
## Expectations from contributors
227245

228246
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.
229-

‎README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@
3636

3737
---
3838

39-
## OpenTelemetry Python Contrib
39+
# OpenTelemetry Python Contrib
4040

4141
The Python auto-instrumentation libraries for [OpenTelemetry](https://opentelemetry.io/) (per [OTEP 0001](https://github.com/open-telemetry/oteps/blob/main/text/0001-telemetry-without-manual-instrumentation.md))
4242

43-
### Installation
43+
## Index
44+
45+
* [Installation](#installation)
46+
* [Releasing](#releasing)
47+
* [Releasing a package as `1.0` stable](#releasing-a-package-as-10-stable)
48+
* [Contributing](#contributing)
49+
* [Running Tests Locally](#running-tests-locally)
50+
* [Thanks to all the people who already contributed](#thanks-to-all-the-people-who-already-contributed)
51+
52+
## Installation
4453

4554
This repository includes installable packages for each instrumented library. Libraries that produce telemetry data should only depend on `opentelemetry-api`,
4655
and defer the choice of the SDK to the application developer. Applications may
@@ -79,6 +88,7 @@ To resolve this, members of the community are encouraged to commit to becoming a
7988
### Releasing a package as `1.0` stable
8089

8190
To release a package as `1.0` stable, the package:
91+
8292
- SHOULD have a CODEOWNER. To become one, submit an issue and explain why you meet the responsibilities found in [CODEOWNERS](.github/CODEOWNERS).
8393
- MUST have unit tests that cover all supported versions of the instrumented library.
8494
- e.g. Instrumentation packages might use different techniques to instrument different major versions of python packages
@@ -131,9 +141,8 @@ Emeritus Maintainers:
131141
4. Make sure you have `tox` installed. `pip install tox`.
132142
5. Run tests for a package. (e.g. `tox -e test-instrumentation-flask`.)
133143

134-
### Thanks to all the people who already contributed!
144+
### Thanks to all the people who already contributed
135145

136146
<a href="https://github.com/open-telemetry/opentelemetry-python-contrib/graphs/contributors">
137147
<img src="https://contributors-img.web.app/image?repo=open-telemetry/opentelemetry-python-contrib" />
138148
</a>
139-

‎RELEASING.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@
7777
* If for some reason the action failed, see [Publish failed](#publish-failed) below
7878
* Move stable tag
7979
* Run the following (TODO automate):
80+
8081
```bash
8182
git tag -d stable
8283
git tag stable
8384
git push --delete origin tagname
8485
git push origin stable
8586
```
87+
8688
* This will ensure the docs are pointing at the stable release.
8789
* To validate this worked, ensure the stable build has run successfully:
88-
https://readthedocs.org/projects/opentelemetry-python/builds/.
90+
<https://readthedocs.org/projects/opentelemetry-python/builds/>.
8991
If the build has not run automatically, it can be manually trigger via the readthedocs interface.
9092

9193
## Troubleshooting
@@ -98,4 +100,4 @@ If for some reason the action failed, do it manually:
98100
- Build distributions with `./scripts/build.sh`
99101
- Delete distributions we don't want to push (e.g. `testutil`)
100102
- Push to PyPI as `twine upload --skip-existing --verbose dist/*`
101-
- Double check PyPI!
103+
- Double check PyPI!

‎exporter/opentelemetry-exporter-prometheus-remote-write/proto/generate-proto-py.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
PROM_VERSION=v2.39.0
45
PROTO_VERSION=v1.3.2

‎instrumentation/opentelemetry-instrumentation-celery/src/opentelemetry/instrumentation/celery/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ def keys(self, carrier):
113113

114114

115115
class CeleryInstrumentor(BaseInstrumentor):
116-
def __init__(self):
117-
super().__init__()
118-
self.metrics = None
119-
self.task_id_to_start_time = {}
116+
metrics = None
117+
task_id_to_start_time = {}
120118

121119
def instrumentation_dependencies(self) -> Collection[str]:
122120
return _instruments
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright The OpenTelemetry Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import unittest
16+
17+
from opentelemetry.instrumentation.celery import CeleryInstrumentor
18+
19+
20+
class TestUtils(unittest.TestCase):
21+
def test_duplicate_instrumentaion(self):
22+
first = CeleryInstrumentor()
23+
first.instrument()
24+
second = CeleryInstrumentor()
25+
second.instrument()
26+
CeleryInstrumentor().uninstrument()
27+
self.assertIsNotNone(first.metrics)
28+
self.assertIsNotNone(second.metrics)
29+
self.assertEqual(first.task_id_to_start_time, {})
30+
self.assertEqual(second.task_id_to_start_time, {})

‎scripts/prepare_release.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
2-
#
2+
set -e
3+
34
# This script:
45
# 1. parses the version number from the branch name
56
# 2. updates version.py files to match that version

0 commit comments

Comments
 (0)