Skip to content

feat: instrumentation introspection - #294

Merged
LucasAlvesSoares merged 10 commits into
mainfrom
framework-registry
Sep 1, 2026
Merged

feat: instrumentation introspection#294
LucasAlvesSoares merged 10 commits into
mainfrom
framework-registry

Conversation

@LucasAlvesSoares

@LucasAlvesSoares LucasAlvesSoares commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Exposes two introspection functions so that modules and users can query the SDK's instrumentation state at runtime:

  • get_attached_adapters() -> list[Adapter] — returns the framework adapters attached via bootstrap(app) (e.g. [Adapter.STARLETTE]), exposed from sap_cloud_sdk.core.runtime_context
  • get_instrumented_libraries() -> list[Library] — returns the libraries successfully patched by auto_instrument() (e.g. [Library.HTTPX, Library.SQLALCHEMY]), exposed from sap_cloud_sdk.core.telemetry

Both return typed StrEnum members (Adapter, Library) so callers get autocomplete and refactor safety while plain-string comparisons still work. Both return an empty list before the corresponding setup call is made, and only include entries for things that were actually wired up (skipped libraries due to missing installs do not appear).

Related Issue

Closes #<issue_number>

Type of Change

Please check the relevant option:

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Code refactoring
  • Dependency update

How to Test

  1. Run the unit test suites:
    pytest tests/core/unit/runtime_context/test_runtime_context.py
    pytest tests/core/unit/telemetry/instrumentation/test_instrumentation.py
    
  2. In an application, call bootstrap(app) then assert Adapter.STARLETTE in get_attached_adapters()
  3. Call auto_instrument() with an OTLP endpoint set, then assert Library.HTTPX and other installed libraries appear in get_instrumented_libraries()
  4. Confirm that uninstalled libraries do not appear in the list

Checklist

Before submitting your PR, please review and check the following:

  • I have read the Contributing Guidelines
  • I have verified that my changes solve the issue
  • I have added/updated automated tests to cover my changes
  • All tests pass locally
  • I have verified that my code follows the Code Guidelines
  • I have updated documentation (if applicable)
  • I have added type hints for all public APIs
  • My code does not contain sensitive information (credentials, tokens, etc.)
  • I have followed Conventional Commits for commit messages

Additional Notes

Any future FrameworkAdapter subclass must implement the name property returning an Adapter enum member — enforced as an abstract property on the base class. The pattern is demonstrated by _StarletteContextAdapter.

get_instrumented_libraries() records only on a successful _instrument() call — import errors and missing-library skips are not recorded, so the list accurately reflects what is active at runtime. Both record_attached and record_instrumented are idempotent.

@LucasAlvesSoares
LucasAlvesSoares marked this pull request as ready for review August 31, 2026 14:38
@LucasAlvesSoares
LucasAlvesSoares requested a review from a team as a code owner August 31, 2026 14:38
jeanscherf
jeanscherf previously approved these changes Aug 31, 2026

@jeanscherf jeanscherf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

<weird-kitty-thumbs-up.jpg>

@LucasAlvesSoares
LucasAlvesSoares merged commit 2175d92 into main Sep 1, 2026
11 checks passed
@LucasAlvesSoares
LucasAlvesSoares deleted the framework-registry branch September 1, 2026 00:10
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.

3 participants