Skip to content

feature: add telemetry attribution module for SDK usage provenance#5661

Open
ryantanaka wants to merge 4 commits intoaws:masterfrom
ryantanaka:feat/telemetry-attribution
Open

feature: add telemetry attribution module for SDK usage provenance#5661
ryantanaka wants to merge 4 commits intoaws:masterfrom
ryantanaka:feat/telemetry-attribution

Conversation

@ryantanaka
Copy link

@ryantanaka ryantanaka commented Mar 20, 2026

Issue #, if available:
N/A

Description of changes:

Adds a new telemetry/attribution.py module to sagemaker-core that provides a structured way to
attribute SDK usage to external integrations such as agent plugins. This attribution if provided will be included in UserAgent header and telemetry requests.

Example Usage:

# other imports
from sagemaker.core import set_attribution, Attribution

set_attribution(Attribution.SAGEMAKER_AGENT_PLUGIN)

# subsequent PySDK code

Adds mechanism to include ARN of resource created for target resources in telemetry requests.

Changes:

  • Added sagemaker/core/telemetry/attribution.py with an Attribution enum and set_attribution()
    function. Calling set_attribution(Attribution.SAGEMAKER_AGENT_PLUGIN) sets the SAGEMAKER_PYSDK_ CREATED_BY environment variable, which is picked up by the telemetry emitter and appended as x- createdBy in the telemetry request URL.
  • Updated telemetry_logging.py to import _CREATED_BY_ENV_VAR from attribution.py as the single
    source of truth for the environment variable name.
  • Re-exported Attribution and set_attribution from sagemaker.core for a clean public import path.
  • Added unit tests for the new module in tests/unit/telemetry/test_attribution.py.
  • Fixed a pre-existing test bug in test_telemetry_logging.py where feature codes [1, 2] were stale
    and should have been [11, 12] following the update in fix: Update telemetry constants to include MLOPS as well #5438.'
  • Added createdBy to user agent metadata.
  • Added x-resourceArn to telemetry request URL. This currently applies when TrainingJobs are created, however the implementation allows us to add additional PySDK return types, for which we want to extract a field to be used to set x-resourceArn.
  • Fixed bug where telemetry requests were being skipped for calls to *Trainer.train() despite having the telemetry decorator specifically when sagemaker_session is not passed to the constructor of *Trainer(...).

Ryan Tanaka added 3 commits March 23, 2026 01:16
… bug with telemetry not being sent for *Trainer.train() if sagemaker_session is not provided
… has been set to aid in resource attribution
@ryantanaka ryantanaka deployed to manual-approval March 23, 2026 08:25 — with GitHub Actions Active
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