Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ If you are using AI agents to assist with contributions, please read [AGENTS.md]
- [Find a Buddy and get Started Quickly](#find-a-buddy-and-get-started-quickly)
- [Development](#development)
- [Virtual Environment](#virtual-environment)
- [Virtual Environment Including Local Core Repository](#virtual-environment-including-local-core-repository)
- [Troubleshooting](#troubleshooting)
- [Benchmarks](#benchmarks)
- [Pull Requests](#pull-requests)
Expand Down Expand Up @@ -120,6 +121,26 @@ uv sync

This will create a virtual environment in the `.venv` directory and install all the necessary dependencies.

#### Virtual Environment Including Local Core Repository

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I usually do is the following:

from contrib -> uv sync and uv sync --project ../opentelemetry-python --active --inexact. It will replace the previously git installed deps from -core by using the local path. Do you think this can help?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @emdneto . So that is the way to do it... Well I will remove the script and update the markdown with this, thanks.

Have you had any experience with debugging using a virtual environment like this, for instance with vscode?
Are the python files the ones in the actual clone of your repo then or are they coming from the venv directory?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the python files the ones in the actual clone of your repo
This ⬆️

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emdneto yes, using the script to generate a tool.uv.sources section would then use the the local files in my actual clone instead of installing the package from a remote. But your command seems to achieve the same. I still have to get around to actually locally testing it though (what I put into the PR so far I've tested of course, not your command yet)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, I ran your commands through now and I've gotten the following results (I'm using where it's pulling opentelemetry-api from as an example)

So having the contrib and core repo cloned in two different folders and running a simple uv sync in the contrib repo (without your arguments yet), pulls opentelemetry-api from github as expected:

Using CPython 3.12.13 interpreter at: /opt/python/3.12.13/bin/python3
Creating virtual environment at: .venv
Resolved 292 packages in 33ms
Installed 224 packages in 348ms
...
 + opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
...

Running the command you mentioned uv sync --project ../opentelemetry-python --active --inexact after activating the environment source .venv/bin/activate gives me:

Resolved 88 packages in 13ms
Uninstalled 32 packages in 25ms
Installed 54 packages in 34ms
...
 - opentelemetry-api==1.44.0.dev0 (from git+https://github.com/open-telemetry/opentelemetry-python@9ffd585e2f5eb296e2c9e834887b382af0c18727#subdirectory=opentelemetry-api)
 + opentelemetry-api==1.42.0.dev0 (from file:///home/mallert2/workspace/otel/otel-python/opentelemetry-python/opentelemetry-api)
...

This looks good and it is now pulling in opentelemetry-api locally. It also changed a bunch of other dependency versions to what is in the uv.lock file of the core repository, but I guess that should be fine.


If you also have a local clone of [`opentelemetry-python`](https://github.com/open-telemetry/opentelemetry-python) and want `uv` to use your local clone to resolve core dependencies, you can run the following commands after **activating the virtual environment created in the previous step**.

Note you may have to replace `../opentelemetry-python` with the path to your local clone.

```sh
uv sync --project ../opentelemetry-python --active --inexact
```

How you activate the virtual environment is platform specific. Some examples:
```sh
source .venv/bin/activate # Linux
```

```ps1
.venv\Scripts\activate.ps1 # Windows Powershell
.venv\Scripts\activate.bat # Windows CMD
```

### Troubleshooting

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.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies = [
"opentelemetry-instrumentation",
"opentelemetry-distro",
"opentelemetry-test-utils",
"opentelemetry-exporter-otlp",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this change.

"opentelemetry-exporter-prometheus-remote-write",
"opentelemetry-exporter-richconsole",
"opentelemetry-instrumentation-aio-pika[instruments]",
Expand Down