Skip to content

feat(otel): fully enum-driven OtelPluginConfig - #612

Merged
SilanHe merged 11 commits into
mainfrom
feat/otel-invocation-config
Aug 7, 2026
Merged

feat(otel): fully enum-driven OtelPluginConfig#612
SilanHe merged 11 commits into
mainfrom
feat/otel-invocation-config

Conversation

@SilanHe

@SilanHe SilanHe commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

aws/aws-durable-execution-conformance-tests#23 (comment)

Unifies both Python OTel plugins on a single OtelPluginConfig and makes provider selection fully enum-driven via provider_source (EXPLICIT/GLOBAL/AUTO_OTLP, default GLOBAL) with per-case validation. Removes the use_default_tracer_provider boolean and the legacy InvocationOtelPlugin kwargs.

Replace InvocationOtelPlugin's legacy positional kwargs with a single
OtelPluginConfig, mirroring ExecutionOtelPlugin and the JS SDK plugins.
This adds use_default_tracer_provider, enable_http_instrumentation,
exporter_config, and propagators to the Invocation plugin.

Also align the default provider with JS: when no provider is supplied
the plugin auto-configures an OTLP provider (default_use_global=False)
instead of the global/ADOT provider. Pass use_default_tracer_provider
=True for the global (e.g. ADOT) provider.

Migrated test call sites and README snippets to OtelPluginConfig.
105/105 otel tests pass; ruff and mypy clean.

BREAKING CHANGE: InvocationOtelPlugin no longer accepts positional or
keyword arguments; pass an OtelPluginConfig instead, e.g.
InvocationOtelPlugin(OtelPluginConfig(tracer_provider=...)).
@SilanHe
SilanHe force-pushed the feat/otel-invocation-config branch from f11491a to 4e5fe40 Compare August 5, 2026 20:57
hsilan added 2 commits August 5, 2026 21:09
The two OTel example handlers used InvocationOtelPlugin() with no
config. Now that the plugin defaults to auto-configuring an OTLP
provider (localhost:4318), the example tests time out when no
collector is running. Pass
OtelPluginConfig(use_default_tracer_provider=True) so the examples use
the globally configured provider (a no-op proxy under test), matching
the conformance handler and the prior no-arg behavior.
Simplify the tracer-provider selection by resolving it once into an
explicit ProviderSource (EXPLICIT / GLOBAL / AUTO_OTLP) instead of
recomputing booleans in two places.

- Drop the default_use_global parameter from create_tracer_provider;
  both plugins now share the same auto-OTLP default, so the seam is
  dead weight.
- Make OtelPluginConfig.use_default_tracer_provider a plain bool
  (default False) instead of a tri-state Optional[bool].
- ProviderResult carries source; owns_provider is a derived property.
- register_standalone_instrumentations switches on result.source
  rather than (config.tracer_provider, use_default_tracer_provider).

Behavior is unchanged. 105/105 otel tests pass; ruff clean; mypy clean
(pre-existing optional-instrumentation import warnings only).
@SilanHe SilanHe changed the title feat(otel)!: InvocationOtelPlugin accepts OtelPluginConfig (clean replace) feat(otel): InvocationOtelPlugin accepts OtelPluginConfig (clean replace) Aug 5, 2026
@SilanHe SilanHe changed the title feat(otel): InvocationOtelPlugin accepts OtelPluginConfig (clean replace) feat(otel): OtelPlugin accepts OtelPluginConfig Aug 5, 2026
@SilanHe SilanHe closed this Aug 5, 2026
@SilanHe SilanHe reopened this Aug 5, 2026
hsilan added 3 commits August 5, 2026 23:30
Move the ProviderSource enum into otel_plugin_config and add
resolve_provider_source() so the explicit > global > auto-OTLP precedence
lives in one place. create_tracer_provider becomes a straight switch on the
resolved source. Remove the redundant ProviderResult.owns_provider property
and the dead self._owns_provider fields in both plugins.
Replace the use_default_tracer_provider boolean with a provider_source:
ProviderSource field as the single driver of provider selection. tracer_provider
becomes the EXPLICIT-only field; __post_init__ validates that EXPLICIT has a
tracer_provider and GLOBAL/AUTO_OTLP do not. create_tracer_provider switches on
config.provider_source; the redundant resolve_provider_source helper is removed.
ExecutionOtelPlugin ambient-parenting now keys off ProviderSource.GLOBAL.

Tests migrate the explicit-provider+flag shortcut to monkeypatching
trace.get_tracer_provider with provider_source=GLOBAL, matching the existing
InvocationOtelPlugin integration test. Examples updated to provider_source=GLOBAL.

BREAKING CHANGE: use_default_tracer_provider is removed; pass
provider_source=ProviderSource.GLOBAL (ADOT) or ProviderSource.EXPLICIT with a
tracer_provider instead.
@SilanHe
SilanHe force-pushed the feat/otel-invocation-config branch from 57c1904 to 327b360 Compare August 5, 2026 23:30
@SilanHe SilanHe changed the title feat(otel): OtelPlugin accepts OtelPluginConfig feat(otel): fully enum-driven OtelPluginConfig Aug 5, 2026
hsilan added 2 commits August 5, 2026 23:47
Default OtelPluginConfig.provider_source to ProviderSource.GLOBAL (use the
globally configured provider, e.g. the ADOT Lambda layer) instead of AUTO_OTLP.
Switch create_tracer_provider on each ProviderSource explicitly with an
exhaustive guard, so no branch reads as an implicit default (the default
GLOBAL lives on OtelPluginConfig.provider_source).
@SilanHe

SilanHe commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

conformance tests are expected to fail until aws/aws-durable-execution-conformance-tests#66 is merged

@SilanHe
SilanHe marked this pull request as ready for review August 7, 2026 20:12
Docstrings and an inline comment described the old AUTO_OTLP default,
stating the plugin auto-configures an OTLP provider when nothing is
supplied. The default is now GLOBAL (uses the globally configured, e.g.
ADOT, provider); AUTO_OTLP is the opt-in for a plugin-owned provider.
Comment/docstring-only; no behavior change.
SilanHe added a commit to aws/aws-durable-execution-conformance-tests that referenced this pull request Aug 7, 2026
* fix(otel): pass use_default_tracer_provider=True in Python Invocation handler

The Python SDK's InvocationOtelPlugin is being aligned to the JS default
(auto-configure an OTLP provider when nothing is supplied) instead of defaulting
to the global/ADOT provider (aws/aws-durable-execution-sdk-python#612). The
conformance harness relies on the global provider configured by the OTel
extension, so the Python handler must now request it explicitly -- matching the
TypeScript handler's InvocationOtelPlugin({ useDefaultTracerProvider: true }).

Update examples/python/src/common.py to construct
InvocationOtelPlugin(OtelPluginConfig(use_default_tracer_provider=True)), and
assert that constructor in test_python_examples.py.

* fix(otel): python examples use ProviderSource.GLOBAL

The Python OTel SDK removed use_default_tracer_provider in favor of the
provider_source enum; GLOBAL is the equivalent of the old flag.

* fix(otel): ts examples use ProviderSource.Global

The JS OTel SDK removed useDefaultTracerProvider in favor of the
providerSource enum; Global is the equivalent of the old flag.

* fix(otel): examples use empty config (defaults Global)

Both Python and TypeScript OTel examples now construct plugins with an
empty config and rely on the provider_source/providerSource default of
GLOBAL, instead of naming it explicitly.

---------

Co-authored-by: silanhe <hsilan@amazon.com>
@SilanHe
SilanHe temporarily deployed to ai-pr-review-runtime August 7, 2026 22:39 — with GitHub Actions Inactive
@SilanHe
SilanHe deployed to ai-pr-review-runtime August 7, 2026 22:39 — with GitHub Actions Active
@SilanHe
SilanHe merged commit f7cc397 into main Aug 7, 2026
23 of 26 checks passed
@SilanHe
SilanHe deleted the feat/otel-invocation-config branch August 7, 2026 22:46
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codex AI review

  • P1 packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel/invocation_plugin.py:99, otel_plugin_config.py:80 — Removing the documented constructor kwargs and use_default_tracer_provider breaks existing Lambda imports with TypeError or ValueError. Preserve these forms through a deprecated adapter to ProviderSource, with compatibility tests, until a breaking release.

  • P2 packages/aws-durable-execution-sdk-python-otel/README.md:178 — The example incorrectly says omission selects auto-OTLP, references the removed boolean, and suggests setting tracer_provider without ProviderSource.EXPLICIT, which validation rejects. Document and import the correct GLOBAL, EXPLICIT, and AUTO_OTLP combinations.

Reviewed commit f77a6c5198db1fee536801af1a6f0258db093d9f. Workflow run

Comment on lines +182 to +183
context_extractor=xray_context_extractor,
# Custom instrumentation scope name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These new doc comments are stale and contradict the API this PR ships:

  • They reference use_default_tracer_provider, which this PR removes from OtelPluginConfig. Passing it now raises TypeError (unknown field). The same dead reference appears again in the API-reference block below (line 264: # ...and the rest of OtelPluginConfig (use_default_tracer_provider, ...)).
  • "When omitted, an OTLP provider is auto-configured" is incorrect: the new default is provider_source=GLOBAL (uses trace.get_tracer_provider()), not AUTO_OTLP. Auto-configuration now requires provider_source=ProviderSource.AUTO_OTLP.
  • The tracer_provider=None example with the comment "Provide your own TracerProvider if you already have one configured" is misleading — supplying a provider now requires provider_source=ProviderSource.EXPLICIT, otherwise OtelPluginConfig.__post_init__ raises ValueError.

Suggest rewording these comments to describe provider_source (GLOBAL default; AUTO_OTLP to build/own an OTLP provider; EXPLICIT + tracer_provider to supply your own) and dropping the use_default_tracer_provider mentions here and at line 264.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Claude AI review

This PR cleanly unifies both OTel plugins on a single enum-driven OtelPluginConfig, replacing the use_default_tracer_provider boolean and owns_provider flag with a ProviderSource enum plus __post_init__ validation. The runtime refactor across provider.py, instrumentations.py, execution_plugin.py, and invocation_plugin.py is internally consistent — the EXPLICIT/GLOBAL/AUTO_OTLP switch preserves prior semantics, deterministic-ID stitching is intact, and every test call site using the removed kwargs was migrated, with new validation tests added.

Findings

1. Stale/incorrect README plugin-options docs (Medium)packages/aws-durable-execution-sdk-python-otel/README.md:182-183 (and the API-reference block near line 264). The newly-added doc comments still reference use_default_tracer_provider, a field this PR removes — the documented usage now raises TypeError. The comment "When omitted, an OTLP provider is auto-configured" is also wrong: the new default is GLOBAL, not AUTO_OTLP; and the tracer_provider=None example omits the now-required provider_source=ProviderSource.EXPLICIT (enforced by __post_init__ with a ValueError). Fix: reword to describe provider_source and drop the use_default_tracer_provider mentions. (Posted inline.)

Residual test risk (not blocking)

  • New global side effect for InvocationOtelPlugin: it now calls register_standalone_instrumentations, which in the default GLOBAL mode instruments botocore process-wide — behavior the invocation plugin did not previously exhibit. Appears intentional (unification) but changes upgrade behavior; no test asserts instrumentation registration for InvocationOtelPlugin.
  • No coverage for InvocationOtelPlugin with provider_source=AUTO_OTLP: the provider-owning/flush path is tested only for ExecutionOtelPlugin, though the invocation plugin's docstrings now advertise AUTO_OTLP as supported.

Reviewed commit f77a6c5198db1fee536801af1a6f0258db093d9f. Workflow run

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