Skip to content

feat(otel): OtelPluginConfig parameter to replace constructor overloads for configuration options - #594

Open
SilanHe wants to merge 7 commits into
mainfrom
feat/otel-configurable-instrumentation-name
Open

feat(otel): OtelPluginConfig parameter to replace constructor overloads for configuration options#594
SilanHe wants to merge 7 commits into
mainfrom
feat/otel-configurable-instrumentation-name

Conversation

@SilanHe

@SilanHe SilanHe commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

Replaces the OTel plugins' telescoping constructors with an immutable OtelPluginConfig builder, adds a config-only constructor that auto-configures a plugin-owned OTLP/HTTP provider, and uses a single ProviderSource enum (EXPLICIT/GLOBAL/AUTO_OTLP) to select the tracer provider. Breaking (preview API). All tests pass.

Both ExecutionOtelPlugin and InvocationOtelPlugin hardcoded the tracer's
instrumentation scope name as "aws-durable-execution-sdk-java", unlike the JS
(instrumentationName) and Python (instrument_name) plugins which expose it.

Add a new fullest public constructor overload on each plugin that accepts an
instrumentationName parameter; the existing 4-arg constructor delegates to it
with the INSTRUMENTATION_NAME default (non-breaking). A null value falls back to
the default. The no-arg ADOT constructor keeps the default (zero-config path);
custom scope names are set via the builder constructors.

No instance field is needed -- the scope name is only used at tracer creation
(.get(...)), so it is resolved locally in the constructor.

Tests: +1 per plugin asserting the exported spans' instrumentation scope name
equals the custom value (Invocation 50, Execution 31). spotless clean.
@SilanHe
SilanHe requested a review from a team August 5, 2026 17:19
@SilanHe
SilanHe requested a deployment to ai-pr-review-runtime August 5, 2026 17:19 — with GitHub Actions Waiting
@SilanHe
SilanHe requested a deployment to ai-pr-review-runtime August 5, 2026 17:19 — with GitHub Actions Waiting
@SilanHe
SilanHe marked this pull request as draft August 5, 2026 17:26
SilanHe and others added 2 commits August 5, 2026 13:09
…g builder

Both InvocationOtelPlugin and ExecutionOtelPlugin used a chain of
positional constructor overloads (up to 5 args). Adding each new knob
(most recently instrumentationName) meant another overload on both
plugins and increasingly ambiguous call sites (two String args, a
boolean). This introduces an immutable OtelPluginConfig value object
with a named-field builder and collapses the overloads to a single
(SdkTracerProviderBuilder, OtelPluginConfig) constructor per plugin.

- New OtelPluginConfig with builder: contextExtractor, enableMdc,
  workflowSpanName, instrumentationName (null-safe defaults).
- Kept no-arg ADOT and single-builder convenience constructors; removed
  the 2/3/4/5-arg telescoping constructors.
- Matches the OtelPluginConfig object in the JS and Python SDKs
  (cross-SDK parity) and is forward-compatible: future options are
  builder methods, not new constructors.
- Migrated all test call sites and updated the README + examples docs.

InvocationOtelPluginTest 50, ExecutionOtelPluginTest 31, integration
17, MdcSpanEnricherTest 3 all pass; examples compile; spotless clean.
@SilanHe SilanHe changed the title feat(otel): make instrumentation scope name configurable refactor(otel): configure plugins via OtelPluginConfig builder (replaces telescoping ctors) Aug 5, 2026
@SilanHe SilanHe changed the title refactor(otel): configure plugins via OtelPluginConfig builder (replaces telescoping ctors) feat(otel): OtelPluginConfig parameter to replace constructor overloads for configuration options Aug 5, 2026
hsilan and others added 3 commits August 5, 2026 22:33
Bring the Java plugins to full 3-tier parity with the JS and Python
SDK plugins, resolved via config:

- ProviderSource enum (EXPLICIT / GLOBAL / AUTO_OTLP) with an
  ownsProvider() helper; surfaced through OtelPluginConfig.resolveSource()
  and exposed on each plugin via providerSource().
- New (OtelPluginConfig) constructor on both plugins: when no builder is
  supplied it resolves GLOBAL (useDefaultTracerProvider=true) or, by
  default, AUTO_OTLP -- a plugin-owned SdkTracerProvider that exports over
  OTLP/HTTP (OtlpHttpSpanExporter + BatchSpanProcessor), with an
  env-driven sampler (OTEL_DURABLE_SAMPLING_RATIO) and Lambda resource
  attributes, mirroring JS/Python.
- OtelPluginConfig gains useDefaultTracerProvider, otlpEndpoint and
  otlpHeaders builder options.
- pom: add opentelemetry-exporter-otlp and move opentelemetry-sdk to
  compile scope so the auto path works without the ADOT agent.

The no-arg constructor still uses the ADOT/global provider (unchanged);
the builder constructors remain EXPLICIT. otel-plugin suite green
(Invocation 53, Execution 33); spotless clean.
…rSource

Replace the redundant useDefaultTracerProvider boolean and the derived
resolveSource() with a single ProviderSource field on OtelPluginConfig
(default AUTO_OTLP). Drop the now-dead ProviderSource.ownsProvider()
helper. The config-only plugin constructors read config.providerSource()
directly and reject EXPLICIT (which requires the (SdkTracerProviderBuilder,
OtelPluginConfig) constructor).
@SilanHe
SilanHe marked this pull request as ready for review August 6, 2026 00:03
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