Skip to content

[Solace] Add OpenTelemetry distributed tracing support to SolaceIO (#40175) - #40482

Merged
stankiewicz merged 2 commits into
apache:masterfrom
stankiewicz:solaceio-opentelemetry-tracing
Oct 13, 2026
Merged

stankiewicz merged 2 commits into
apache:masterfrom
stankiewicz:solaceio-opentelemetry-tracing

Conversation

@stankiewicz

Copy link
Copy Markdown
Contributor

Fixes #40175
Supersedes #40187

Summary

Adds OpenTelemetry distributed tracing support to both SolaceIO.Read and SolaceIO.Write, aligned with KafkaIO and PubsubIO and utilizing Solace.Record user properties introduced in #40108 for W3C Trace Context propagation (traceparent, tracestate).

Changes

  • Build & Dependencies (sdks/java/io/solace/build.gradle):
    • Added opentelemetry_bom, opentelemetry_api, and opentelemetry_context to implementation.
    • Added opentelemetry_sdk and opentelemetry_sdk_testing to testImplementation.
  • Read-Side Trace Extraction (SolaceIO.Read & OpenTelemetryHeaderConsumer):
    • Added withEnableOpenTelemetryTracing() on SolaceIO.Read (default false).
    • Applied ParDo.of(new OpenTelemetryHeaderConsumer<>()) in SolaceIO.Read.expand().
    • Initialized Tracer ("SolaceIO") from options.as(SdkHarnessOptions.class).getOpenTelemetry().
    • Extracted W3C trace context (traceparent, tracestate, with case-insensitive header lookup) from Solace.Record.getUserProperties() via W3CTraceContextPropagator.getInstance().extract(...) and TextMapGetter<Record>.
    • Created a "SolaceIO.Read" span with SpanKind.CONSUMER and setParent(context) wrapping receiver.output(element) so Beam propagates the OpenTelemetry context in WindowedValue.
  • Write-Side Trace Injection (SolaceIO.Write & OpenTelemetryHeaderPropagator):
    • Added withEnableOpenTelemetryTracing() on SolaceIO.Write (default false).
    • Added toBuilder() to Solace.Record.
    • Applied ParDo.of(new OpenTelemetryHeaderPropagator()) in SolaceIO.Write.expand().
    • Created a "SolaceIO.Write" span with SpanKind.PRODUCER and setParent(Context.current()), injecting the active W3C trace context into a copy of Solace.Record's userProperties via W3CTraceContextPropagator.getInstance().inject(...) and TextMapSetter<Record>.
  • Unit Tests:
    • SolaceIOReadTest: Verified configuration toggle and SpanKind.CONSUMER span creation, parent trace/span ID linkage, case-insensitive TraceParent extraction, and tracestate preservation using InMemorySpanExporter.
    • SolaceIOWriteTest: Verified configuration toggle, SpanKind.PRODUCER span creation for both STREAMING and BATCHED writers, W3C traceparent injection into Solace.Record user properties and JCSMP SDTMap message properties, and end-to-end consumer-to-producer trace context continuity.

@stankiewicz
stankiewicz marked this pull request as draft October 9, 2026 09:46
@stankiewicz
stankiewicz marked this pull request as ready for review October 9, 2026 09:48
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.05%. Comparing base (76f6e6d) to head (efe66c2).
⚠️ Report is 156 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40482      +/-   ##
============================================
+ Coverage     56.16%   65.05%   +8.88%     
- Complexity     2288    13973   +11685     
============================================
  Files          1124     1729     +605     
  Lines        178336   108467   -69869     
  Branches       1489    11305    +9816     
============================================
- Hits         100170    70558   -29612     
+ Misses        75645    33700   -41945     
- Partials       2521     4209    +1688     
Flag Coverage Δ
go ?
java 65.05% <ø> (-10.74%) ⬇️
python ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@chamikaramj chamikaramj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

configuration.getNackOnTimeout())));

if (configuration.getEnableOpenTelemetryTracing()) {
output =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We expect T to be of type Solace.Record.class right ?

If so should we add a check here for that to prevent unintended issues in the reader ?

Also add a test pls.

AI suggestion:

if (configuration.getEnableOpenTelemetryTracing()) {
  checkArgument(
      TypeDescriptor.of(Solace.Record.class).isSupertypeOf(configuration.getTypeDescriptor()),
      "SolaceIO.Read: withEnableOpenTelemetryTracing() requires Solace.Record output "
          + "(SolaceIO.read()); user properties are not available after a custom parseFn.");
  // ... apply OpenTelemetryHeaderConsumer as today
}

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.

nice find! will do

@stankiewicz
stankiewicz merged commit c91977c into apache:master Oct 13, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: SolaceIO: Add OpenTelemetry Distributed Tracing Support

2 participants