stankiewicz opened a new pull request, #40482:
URL: https://github.com/apache/beam/pull/40482
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]