opentelemetry-java icon indicating copy to clipboard operation
opentelemetry-java copied to clipboard

Preserve OpenCensus status description when converting to OpenTelemetry

Open thswlsqls opened this issue 5 months ago • 1 comments

Fixes #8508

Description

  • OpenTelemetrySpanImpl.setStatus(io.opencensus.trace.Status) mapped only the status code (OK/ERROR) and dropped the OpenCensus status description, so Status.UNKNOWN.withDescription("connection refused") reached exporters as an ERROR with no description.
  • Now read status.getDescription() and forward it through the existing setStatus(StatusCode, String) delegation — the sibling overload that already carries a description to the OpenTelemetry span — falling back to the code-only overload when the description is null.
  • No description branch is needed for OK: SdkSpan.setStatus ignores a description when the status is not ERROR.

Testing done

  • Added OpenTelemetrySpanImplTest#setStatus_preservesDescription (description forwarded as setStatus(ERROR, "...")) and #setStatus_withoutDescription_setsCodeOnly (no description delegates the code-only overload).
  • ./gradlew :opencensus-shim:check — passed (new test class: 2 tests).
  • Added a ## Unreleased entry in CHANGELOG.md (status description is now visible in exported span status).

thswlsqls avatar Jun 22 '26 08:06 thswlsqls

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 91.61%. Comparing base (c5c9d87) to head (9385e33). :warning: Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8511      +/-   ##
============================================
+ Coverage     91.60%   91.61%   +0.01%     
- Complexity    10312    10315       +3     
============================================
  Files          1013     1013              
  Lines         27274    27278       +4     
  Branches       3202     3203       +1     
============================================
+ Hits          24983    24990       +7     
+ Misses         1563     1562       -1     
+ Partials        728      726       -2     

:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 22 '26 08:06 codecov[bot]

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

otelbot[bot] avatar Jul 13 '26 20:07 otelbot[bot]