Upgrade OpenTelemetry and Azure packages to latest compatible versions #2634
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR addresses the failed Dependabot PR #2619 by upgrading OpenTelemetry and Azure packages to their latest compatible versions, and fixes a critical test infrastructure issue.
Problem
The original Dependabot PR attempted to upgrade
opentelemetry-sdk
from 1.31.1 to 1.35.0, but failed CI due to dependency conflicts. Investigation revealed that Azure Monitor packages constrainopentelemetry-sdk
to<1.32,>=1.28.0
, making version 1.35.0 incompatible.Additionally, tests were completely failing due to
tiktoken
attempting to download tokenizer data at module import time fromopenaipublic.blob.core.windows.net
, which is blocked by firewall rules.Root Cause
The dependency conflict stems from:
azure-monitor-opentelemetry
requiringopentelemetry-sdk<1.32,>=1.28.0
microsoft-kiota-*
packages requiringopentelemetry-sdk>=1.27.0
opentelemetry-sdk==1.35.0
which exceeds the Azure constraintThe test infrastructure issue was caused by:
tiktoken.encoding_for_model()
being called at module import time inprepdocslib/textsplitter.py
Solution
Dependency Updates
Instead of forcing an incompatible upgrade, this PR:
uv pip compile
opentelemetry-sdk==1.31.1
(the latest version supported by Azure packages)azure-monitor-opentelemetry
: 1.6.1 → 1.6.12azure-monitor-opentelemetry-exporter
: 1.0.0b32 → 1.0.0b40azure-core
: 1.30.2 → 1.35.0azure-identity
: 1.17.1 → 1.23.1Test Infrastructure Fix
Implemented lazy loading for tiktoken encoding:
bpe = tiktoken.encoding_for_model(ENCODING_MODEL)
with lazy loading functionget_encoding()
function that loads encoding only when neededget_encoding().encode(text)
instead of direct global accessVerification
uv pip install -r requirements-dev.txt
ruff check .
)black . --check
)mypy
)The remaining 22 test failures are expected as they require actual network access to
openaipublic.blob.core.windows.net
for tiktoken functionality.Installation Command
To verify the upgrade works in a fresh environment:
This provides a substantial dependency refresh while maintaining compatibility and fixes the test infrastructure. Future upgrades to
opentelemetry-sdk
1.35.0+ will be possible once Azure Monitor packages release versions with relaxed constraints.Fixes #2633.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.