Skip to content

fix(telemetry): resolve SDK version dynamically in user agent - #6546

Open
rsareddy0329 wants to merge 2 commits into
aws:masterfrom
rsareddy0329:fix/telemetry-sdk-version-user-agent
Open

rsareddy0329 wants to merge 2 commits into
aws:masterfrom
rsareddy0329:fix/telemetry-sdk-version-user-agent

Conversation

@rsareddy0329

Copy link
Copy Markdown
Contributor

Issue: x-sdkVersion in telemetry is always 3.0, so the "Users by SDK Version" dashboard shows no data for newer releases.

Root cause: sagemaker-core/src/sagemaker/core/user_agent.py hardcodes SDK_VERSION = "3.0". This constant feeds the user-agent suffix and the x-sdkVersion telemetry field used by core, serve, and train. The dynamic lookup V2 had (importlib_metadata.version("sagemaker")) was lost in the V3 port and later pinned to a constant.

Fix: resolve the version at runtime — prefer the sagemaker meta-package, fall back to sagemaker-core for standalone installs, with a static "3.0" fallback so telemetry never raises. importlib-metadata is already a declared dependency.

Testing: new tests/unit/test_user_agent.py covers the resolution order, fallback, and a regression guard against re-hardcoding; existing telemetry tests unaffected. black/flake8 clean.

SDK_VERSION in sagemaker-core/src/sagemaker/core/user_agent.py was
hardcoded to "3.0", so every V3 install reported x-sdkVersion=3.0
regardless of the installed release. This blanked out the
"Users by SDK Version" telemetry dashboard for all newer versions
(core, serve, and train telemetry all import this one constant).

Restore the dynamic resolution V2 used (importlib_metadata.version):
prefer the "sagemaker" meta-package version, fall back to
"sagemaker-core" for standalone installs, and keep a static "3.0"
fallback so user-agent/telemetry construction never raises.

Add tests/unit/test_user_agent.py, which the module previously lacked,
including a regression guard against re-hardcoding the version.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/src/sagemaker/core/user_agent.py with a runtime lookup via importlib_metadata.version(...), preferring the sagemaker meta-package and falling back to sagemaker-core, then to a static "3.0". The importlib-metadata dependency is already declared in pyproject.toml, and the approach mirrors the existing pattern in utils/user_agent.py. The change is correct, consistent with established practice for SDK version reporting (Source: #4414), and comes with adequate unit tests. No blocking issues found.

Reviewed commit 8f94256. Automated review; verify before acting.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR replaces the hardcoded SDK_VERSION = "3.0" in sagemaker-core/src/sagemaker/core/user_agent.py with a runtime lookup via importlib_metadata, preferring the sagemaker meta-package and falling back to sagemaker-core then a static "3.0". The change is correctly targeted — this module feeds x-sdkVersion telemetry for core, serve, and train — and follows existing conventions (core/utils/user_agent.py already uses importlib_metadata.version, and importlib-metadata is a declared dependency). Tests cover resolution order, fallback, and a regression guard, and existing telemetry tests are unaffected. The PR looks clean; no blocking issues found.

Reviewed commit dd9ef3a. Automated review; verify before acting.

This branch was successfully deployed

1 active deployment
auto-approve — dd9ef3a7 Deployed Oct 29, 2026 by rsareddy0329 via wait-for-approval #2139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants