opentelemetry-bootstrap -a install is unnecessarily slow — recommend piping to pip install in docs
feature-request
### What problem do you want to solve?
`opentelemetry-bootstrap --action=install` is very slow because it calls `pip install -U --upgrade-strategy=only-if-needed <package>` in a loop — once per discovered instrumentor ([source](https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap.py#L136-L138)).
For a typical project with ~8 instrumentors, this means:
* 8 separate subprocess spawns (each ~0.5s Python startup overhead)
* 8 separate pip loads (~1s each)
* 8 separate dependency resolution passes with -U flag (checking PyPI for upgrades each time)
* 8 separate pip check validations implicitly
In my testing this takes 60–120 seconds in a Docker build.
### Faster alternative
`opentelemetry-bootstrap --action=requirements | pip install -r /dev/stdin`
This is faster because:
* 1 subprocess instead of 8
* 1 pip startup instead of 8
* 1 resolver pass that handles all packages together, instead of 8 independent passes
* No `-U` flag — in a fresh environment (e.g., Docker build), there's nothing to upgrade, so the upgrade check is pure overhead
In my testing this takes 15–25 seconds — a 4–6x speedup.
### Relation to existing docs
The [troubleshooting docs](https://opentelemetry.io/docs/zero-code/python/troubleshooting/#bootstrap-using-uv) already recommend a similar pattern for `uv`:
`uv run opentelemetry-bootstrap -a requirements | uv add --requirement -`
But there's no equivalent recommendation for pip users. Since pip is still the default package manager for most Python users, it would be helpful to document this pattern as well.
### Suggestions
1. Add a "Bootstrap using pip" section in the troubleshooting docs alongside the existing "Bootstrap using uv" section, recommending:
`opentelemetry-bootstrap --action=requirements | pip install -r /dev/stdin`
2. Consider changing `_run_install` to batch all packages into a single `pip install` call instead of looping, which would make `--action=install` fast by default without requiring users to discover this workaround.
### Environment
Python 3.14
opentelemetry-distro (latest)
Docker build context (fresh venv each time, no cache benefit from `-U`)
1 条评论