Skip to content

feat(telemetry): add register_sdk_resource_attributes() for companion SDKs - #288

Draft
jeanscherf wants to merge 2 commits into
mainfrom
feat/sdk-resource-attribute-registry
Draft

feat(telemetry): add register_sdk_resource_attributes() for companion SDKs#288
jeanscherf wants to merge 2 commits into
mainfrom
feat/sdk-resource-attribute-registry

Conversation

@jeanscherf

@jeanscherf jeanscherf commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds register_sdk_resource_attributes(attributes: dict) to telemetry/config.py
  • create_resource_attributes_from_env() merges registered attributes into the resource dict, so they appear on every span and metric
  • Exports register_sdk_resource_attributes from sap_cloud_sdk.core.telemetry

Why

Companion internal SDKs (e.g. sap-internal-sdk) need a way to contribute their version as an OTel resource attribute without requiring agents to change their auto_instrument() calls. This PR provides the extension point.

Usage from a companion SDK at import time — version read dynamically from package metadata:

from importlib.metadata import version, PackageNotFoundError
from sap_cloud_sdk.core.telemetry.config import register_sdk_resource_attributes

try:
    sdk_version = version("my-sdk-package")
except PackageNotFoundError:
    sdk_version = "unknown"

register_sdk_resource_attributes({
    "sap.my_sdk.version": sdk_version,
    "sap.my_sdk.language": "python",
})

Test plan

  • 4 new tests in TestRegisterSdkResourceAttributes covering registration, merging, and empty-registry no-op
  • Full telemetry unit test suite: 404 passed

… SDKs

Adds a module-level registry in create_resource_attributes_from_env() so
companion SDKs (e.g. sap-internal-sdk) can contribute their version as an
OTel resource attribute at import time, without requiring any change to
agent startup code.
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.

1 participant