Skip to content

refactor(otel): resolve provider source via enum - #792

Merged
SilanHe merged 15 commits into
mainfrom
feat/otel-provider-source-enum
Aug 7, 2026
Merged

refactor(otel): resolve provider source via enum#792
SilanHe merged 15 commits into
mainfrom
feat/otel-provider-source-enum

Conversation

@SilanHe

@SilanHe SilanHe commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

Replaces useDefaultTracerProvider and the derived ownsProvider with a single ProviderSource enum (GLOBAL | AUTO_OTLP | EXPLICIT), owned by the config and validated centrally.

The default ProviderSource is "GLOBAL" which will fetch the active provider user the getDefaultProvider() function.

Resolve the tracer provider once into an explicit ProviderSource
(Explicit / Global / AutoOtlp) and carry it on ProviderResult, instead
of re-deriving the decision from config in two places.

registerStandaloneInstrumentations now switches on the resolved
ProviderSource rather than recomputing it from
(config.tracerProvider, config.useDefaultTracerProvider):
- Explicit  -> skip all instrumentation (caller owns it)
- Global    -> AWS SDK instrumentation only
- AutoOtlp  -> AWS SDK + HTTP (unless enableHttpInstrumentation=false)

ownsProvider remains on ProviderResult (derived: true only for
AutoOtlp). Behavior is unchanged; this mirrors the Python refactor for
cross-SDK symmetry. 194/194 otel tests pass; build clean.
@SilanHe
SilanHe requested a deployment to ai-pr-review-runtime August 5, 2026 22:09 — with GitHub Actions Waiting
@SilanHe
SilanHe requested a deployment to ai-pr-review-runtime August 5, 2026 22:09 — with GitHub Actions Waiting
hsilan and others added 7 commits August 5, 2026 22:19
…ignal

ProviderResult.source (ProviderSource enum) is now the single source of
truth for provider tier/ownership. The ownsProvider boolean was a pure
projection of source === AutoOtlp and was read by no production code (the
ExecutionOtelPlugin field was write-only). Removes it from ProviderResult
and the plugin, and switches the provider-resolution tests to assert on
source.

194/194 otel tests pass; tsc --noEmit + build clean.
…iderSource

Move the ProviderSource enum into the config module and add a single
resolveProviderSource(config) resolver that owns the precedence chain
(explicit tracerProvider > useDefaultTracerProvider > auto-OTLP).

- createTracerProvider now resolves the source once and switches on it,
  instead of re-deriving the tiers from raw config booleans inline.
- ExecutionOtelPlugin stores providerSource and gates the child
  Invocation span on 'source !== Global' (was '!useDefaultTracerProvider').
- InvocationOtelPlugin drops its write-only useDefaultTracerProvider field.
- provider.ts re-exports ProviderSource so existing import sites are stable.

No behavior change. 194/194 otel tests pass; tsc --noEmit + build clean.
…erSource enum

BREAKING CHANGE: OtelPluginConfig no longer accepts `useDefaultTracerProvider`.
Provider mode is now selected via the fully enum-driven `providerSource`
(ProviderSource.AutoOtlp default | Global | Explicit).

- providerSource is the sole selector; tracerProvider is a companion input
  consumed only by Explicit. resolveProviderSource now validates the coupling:
  Explicit requires tracerProvider (throws if missing), and tracerProvider is
  rejected for any non-Explicit source (throws) instead of being silently
  ignored.
- ProviderSource is now exported publicly from index.ts.
- Migrated all examples, the shared test setup, 6 test files, and the README.
  Explicit-provider call sites now pass providerSource: ProviderSource.Explicit;
  ADOT/global sites pass ProviderSource.Global.

198/198 otel tests pass; tsc --noEmit + build clean; examples codegen +
tsc --noEmit clean.
BREAKING CHANGE: the default provider mode changes from AutoOtlp to Global.
A no-config plugin now uses the globally registered provider
(trace.getTracerProvider()) instead of building its own OTLP exporter. If no
global provider is registered, OTel returns a no-op provider and no spans are
exported — callers who relied on zero-config local OTLP export must now set
providerSource: ProviderSource.AutoOtlp explicitly.

- resolveProviderSource defaults to ProviderSource.Global.
- Pinned the sites that depend on auto-OTLP behavior to explicit AutoOtlp:
  the community-collector execution/invocation cloud-mode examples and the
  'creates its own internal provider' unit test.
- Updated the resolution tests (absent/empty config now resolves to Global)
  and the README (modes list, deployment matrix, config docs).

197/197 otel tests pass; tsc --noEmit + build clean; examples codegen +
tsc --noEmit clean.
The factory doc still implied AutoOtlp was the fallback/default. Rewrote it
to describe all three ProviderSource tiers with Global as the default.
SilanHe and others added 3 commits August 7, 2026 10:10
Rename ProviderSource members from PascalCase (Explicit/Global/AutoOtlp)
to SCREAMING_SNAKE_CASE (EXPLICIT/GLOBAL/AUTO_OTLP), matching the Python
and Java SDK enums. String values are unchanged. Updated all references,
tests, examples, and README.
@SilanHe
SilanHe marked this pull request as ready for review August 7, 2026 20:12
@SilanHe
SilanHe merged commit 31d7dbe into main Aug 7, 2026
16 of 18 checks passed
@SilanHe
SilanHe deleted the feat/otel-provider-source-enum branch August 7, 2026 22:58
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