Skip to content

opentelemetry-sdk: sketch of an OpAMP integration#4646

Open
xrmx wants to merge 11 commits intoopen-telemetry:mainfrom
xrmx:opamp-prototype-integration
Open

opentelemetry-sdk: sketch of an OpAMP integration#4646
xrmx wants to merge 11 commits intoopen-telemetry:mainfrom
xrmx:opamp-prototype-integration

Conversation

@xrmx
Copy link
Copy Markdown
Contributor

@xrmx xrmx commented Jun 19, 2025

Description

This is a basic integration for setting up OpAMP in the sdk configurator.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 5, 2026

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Mar 5, 2026
@xrmx xrmx removed the Stale label Mar 5, 2026
@github-actions
Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.


# OpAMP is a system created to configure OpenTelemetry SDKs with a remote config.
# This is different than other init helpers because setting up OpAMP requires distro
# provided code as it's not strictly specified. We call OpAMP init before other code
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In my distro I initialize the OpAMP client after the sdk has been setup but can't exclude other scenarios

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.

Should we add this a SIG topic to get the execution order?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've renamed the entry point to pre_sdk_init_function so that we can add a post_sdk_init_function if required

@xrmx xrmx marked this pull request as ready for review March 20, 2026 11:41
@xrmx xrmx requested a review from a team as a code owner March 20, 2026 11:41
@xrmx xrmx moved this to Reviewed PRs that need fixes in Python PR digest Mar 20, 2026
Copy link
Copy Markdown
Member

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

Thanks for doing this. Added a comment.

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py Outdated
# up the rest of the SDK.
try:
_init_opamp = _import_opamp()
_init_opamp(resource=resource)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is it possible for _init_opamp to raise a RuntimeError? If so, it could be slightly confusing as the logs would say no init function found instead of the actual error.
Also, is it possible for it to throw other types of exceptions? Would we want to catch more broadly to ensure we don't prevent the rest from initializing?

Copy link
Copy Markdown
Contributor Author

@xrmx xrmx Apr 9, 2026

Choose a reason for hiding this comment

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

Changed error handling in 830fd1b. If the user provided function raises any exception it'll break as any other loaded components doing that. Not sure we should catch more broadly, it's fine to crash at init time if something is wrong and for someone maybe a misconfigured sdk is worse than a sdk not working. But I don't have a strong opinion on that.

Comment thread opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py Outdated

# OpAMP is a system created to configure OpenTelemetry SDKs with a remote config.
# This is different than other init helpers because setting up OpAMP requires distro
# provided code as it's not strictly specified. We call OpAMP init before other code
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.

Should we add this a SIG topic to get the execution order?

@xrmx xrmx force-pushed the opamp-prototype-integration branch from 23f3ff7 to 830fd1b Compare April 9, 2026 09:19
@xrmx xrmx requested review from kelseyma and pmcollins April 14, 2026 13:54
Comment thread opentelemetry-sdk/src/opentelemetry/sdk/_configuration/__init__.py
# provided code as it's not strictly specified. We call OpAMP init before other code
# because people may want to have it blocking to get an updated config before setting
# up the rest of the SDK.
_init_opamp = _import_opamp()
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.

My org is interested in using OpAMP first to report effective SDK configuration. For that use case, it would be convenient if there were also an OpAMP hook after _init_tracing, _init_metrics, and _init_logging, so the OpAMP client could inspect how providers, processors, exporters, resources, etc. were actually configured from the various sources (env vars, CLI flags, file config, defaults, and entry points).

With only a pre-init hook, the OpAMP implementation would have to re-create or re-invoke parts of the SDK configuration logic and infer the effective config, or it would have to poll the global providers and traverse the private object graphs after an arbitrary delay.

I can see the value of the current pre-init hook for influencing initial configuration before providers are wired, but a post-init hook seems useful for reporting effective config. This could be a separate PR.

Longer term, maybe it would be better to introduce a configuration controller/object that could be the source of truth for SDK config: it could resolve the config from the supported sources, provide the effective config for reporting, accept updates from OpAMP, and notify listeners when the configuration changes. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

4 participants