Skip to content

Add OpenTelemetry tracing support to SolaceIO - #40187

Closed
singhmrinal02 wants to merge 4 commits into
apache:masterfrom
singhmrinal02:fix-solaceio-opentelemetry
Closed

singhmrinal02 wants to merge 4 commits into
apache:masterfrom
singhmrinal02:fix-solaceio-opentelemetry

Conversation

@singhmrinal02

Copy link
Copy Markdown
Contributor

Addresses #40175.

Summary

This PR adds OpenTelemetry tracing support to SolaceIO.

I added an option to enable tracing for SolaceIO reads and passed this option through the source and reader. I also updated the related tests and kept tracing disabled by default.

Testing

I tested the changes locally and the build completed successfully.

@singhmrinal02

Copy link
Copy Markdown
Contributor Author

I'm pretty new to open source and this is one of my first contributions, so I might have missed something or done something wrong. If you find anything that needs to be changed, please let me know. I'd really like to learn from the review, and if you have any tips on how I can improve and contribute better in the future, I'd really appreciate it.

@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.55%. Comparing base (2448f5a) to head (764ed67).
⚠️ Report is 40 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40187      +/-   ##
============================================
- Coverage     59.59%   58.55%   -1.05%     
+ Complexity    17598    13628    -3970     
============================================
  Files          3050     2577     -473     
  Lines        293086   269350   -23736     
  Branches      13816    11079    -2737     
============================================
- Hits         174679   157710   -16969     
+ Misses       111287   105710    -5577     
+ Partials       7120     5930    -1190     
Flag Coverage Δ
java 64.92% <ø> (-1.20%) ⬇️

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

Copy link
Copy Markdown
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @kennknowles for label java.
R: @damccorm for label build.

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).

@stankiewicz

Copy link
Copy Markdown
Contributor

@singhmrinal02 thanks for picking this up! Goal of this FR is to enable open telemetry propagation - check similar implementation in Kafka and PubSub. You've done some good work with configuring IO, missing part in read is extracting headers and creating a span, missing part in writer is taking a context and injecting it into headers.

}

public Read<T> withEnableOpenTelemetryTracing() {
configurationBuilder.setEnableOpenTelemetryTracing(true);

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.

Add check.
This feature will only work if TypeDescriptor.of(Solace.Record.class) , ParDo after UnboundedSource need to access headers, which are available in Solace.Record.

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.

Thanks for reviewing and for the guidance! I’ll check again and work on the missing parts.

@kennknowles

Copy link
Copy Markdown
Member

R: @stankiewicz

@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

@stankiewicz

Copy link
Copy Markdown
Contributor

The implementation is incomplete - In its current state, the PR introduces a configuration toggle (withEnableOpenTelemetryTracing()) and passes it down to UnboundedSolaceReader, but no actual tracing instrumentation is performed. The reader merely logs a debug message (LOG.debug(...)), without creating OpenTelemetry spans, propagating W3C trace context, or supporting write pipelines.

key flaws:

  1. No Actual OpenTelemetry Instrumentation -No spans are created or recorded, no trace parent is extracted, and no OpenTelemetry API/SDK dependencies are imported. The feature is essentially a no-op that produces log.
  2. Tracing Inside UnboundedSolaceReader Instead of a ParDo. KafkaIO
    and PubsubIO handle distributed tracing via a dedicated ParDo transform applied to the PCollection in expand(). This ensures proper span lifecycle scoping across element processing.
  3. Completely Missing Write Support (SolaceIO.Write) , FR was for both Read and Write
  4. Ignoring Solace Message User Properties (PR SolaceIO: map message user properties #40108) - Distributed tracing in messaging systems relies on W3C Trace Context headers (traceparent, tracestate). PR #40108 was merged to expose Solace JCSMP user properties as a Map<String, String> on Solace.Record. Without reading or writing these properties, W3C trace propagation cannot function.
  5. Unrelated Build System Changes

Changes requested:

  1. Add missing OpenTelemetry dependencies in sdks/java/io/solace/build.gradle
  • implementation platform(library.java.opentelemetry_bom)
  • implementation library.java.opentelemetry_api
  • implementation library.java.opentelemetry_context
  • testImplementation library.java.opentelemetry_sdk
  1. Read-Side Trace Extraction

A dedicated DoFn (e.g., OpenTelemetryHeaderConsumer) applied in SolaceIO.Read.expand().
OpenTelemetry instance injection via PipelineOptions:

openTelemetry = options.as(SdkHarnessOptions.class).getOpenTelemetry();
tracer = openTelemetry.getTracer("SolaceIO");

Extraction of W3C trace context from record.getProperties() using W3CTraceContextPropagator.getInstance().extract(...) and TextMapGetter<Solace.Record>.
Creating a consumer span ("SolaceIO.Read") wrapping receiver.output(record).

  1. Write-Side Trace Injection
  • withEnableOpenTelemetryTracing() on SolaceIO.Write.
  • A dedicated DoFn (e.g., OpenTelemetryHeaderPropagator) applied in SolaceIO.Write.expand().
  • Injection of the current trace context into Solace.Record user properties using W3CTraceContextPropagator.getInstance().inject(...) and TextMapSetter.

Align the implementation with the pattern used in with KafkaIO.
4. Revert

  • Revert changes to BeamModulePlugin.groovy and keep the PR focused on SolaceIO.
  • Revert the changes in UnboundedSolaceReader and UnboundedSolaceSource to prevent mixing transport polling with telemetry context propagation.
  1. Tests
    Add unit tests with InMemorySpanExporter to verify span creation and context propagation.

@stankiewicz stankiewicz 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.

see comment above

@stankiewicz

Copy link
Copy Markdown
Contributor

@singhmrinal02 let me know if you want to continue working on this.

@singhmrinal02

Copy link
Copy Markdown
Contributor Author

I’d also like to work on this issue. I’m a bit busy until the 9th, though, so I might not be able to start right away. If that’s too much of a delay and someone else can take it up sooner, it’s totally fine to assign it to them.

Also, thanks a lot for guiding me and reviewing my previous work. I really appreciate all the feedback!

@stankiewicz

stankiewicz commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

@singhmrinal02 I've created PR #40187. I appreciate your work, thanks for that. The main challenge is time here, as I have users waiting for this capability and next cut is early next week, I can't wait any longer. I feel, if we have more time, you would be able to finish that.

@chamikaramj

Copy link
Copy Markdown
Contributor

Should this be closed @stankiewicz ?

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.

4 participants