Skip to content

Adding trace propagation to local observations#1724

Open
salaboy wants to merge 2 commits intodapr:masterfrom
salaboy:trace-prop-local-obs
Open

Adding trace propagation to local observations#1724
salaboy wants to merge 2 commits intodapr:masterfrom
salaboy:trace-prop-local-obs

Conversation

@salaboy
Copy link
Copy Markdown
Collaborator

@salaboy salaboy commented Apr 11, 2026

Description

Unfortunately, without adding trace propagation to the observations created in the SDK, traces are not correlated automatically.

With this PR, traces are correlated
1 18 0-SNAPSHOT

WIthout this PR, we have a span, but that span is not correlated with downstream spans

1 17 3-rc-1

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1725

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@salaboy salaboy requested review from a team as code owners April 11, 2026 10:00
Signed-off-by: salaboy <Salaboy@gmail.com>
@salaboy salaboy force-pushed the trace-prop-local-obs branch from fd33547 to dac5d5b Compare April 11, 2026 10:02
…ing-boot-observation module

Eliminates the verbatim duplication between dapr-spring-boot-autoconfigure
(Spring Boot 3.x) and dapr-spring-boot-4-autoconfigure (Spring Boot 4.x):
both modules previously held 100%-identical copies of ObservationDaprClient
(~820 LOC) and ObservationDaprWorkflowClient (~400 LOC, including the W3C
traceparent/tracestate formatters, repeated 4 times overall).

Introduces a new Spring-agnostic module dapr-spring/dapr-spring-boot-observation
under package io.dapr.spring.observation.client holding a single canonical copy
of both decorators plus a package-private TraceContextFormat helper that
replaces the 4 duplicated formatter copies. The module has zero Spring imports
so it can be shared safely across Spring Boot 3.x and 4.x without API drift.

Autoconfigure modules now depend on dapr-spring-boot-observation (optional),
replacing their direct opentelemetry-api dependency. Consumers who skip
observation wiring still don't pull OTel onto the classpath.

OtelTracingClientInterceptor is now a private static final singleton on
ObservationDaprWorkflowClient instead of allocated per client — justified by
its existing javadoc which already stated it is stateless and shareable.

Tests for the decorators themselves moved to the new module (33 pass); the
Spring-wiring test DaprClientObservationAutoConfigurationTest stays in boot 3
with updated imports.

Net: -1104 lines.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 32.39437% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.76%. Comparing base (9b80cfc) to head (68eb74e).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ervation/client/ObservationDaprWorkflowClient.java 37.83% 22 Missing and 1 partial ⚠️
.../spring/observation/client/TraceContextFormat.java 0.00% 11 Missing ⚠️
...a/io/dapr/workflows/client/DaprWorkflowClient.java 0.00% 8 Missing ⚠️
...ring/observation/client/ObservationDaprClient.java 60.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1724      +/-   ##
============================================
+ Coverage     72.91%   76.76%   +3.84%     
- Complexity     2256     2260       +4     
============================================
  Files           242      241       -1     
  Lines          7415     7066     -349     
  Branches        738      740       +2     
============================================
+ Hits           5407     5424      +17     
+ Misses         1646     1279     -367     
- Partials        362      363       +1     

☔ View full report in Codecov by Sentry.
📢 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.

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.

Propagate traces from local observations to downstream spans

2 participants