Skip to content

Fix inconsistent exception logging patterns and add guidance#8231

Open
VamshikrishnaMonagari wants to merge 1 commit intoopen-telemetry:mainfrom
VamshikrishnaMonagari:fix-exception-logging-patterns
Open

Fix inconsistent exception logging patterns and add guidance#8231
VamshikrishnaMonagari wants to merge 1 commit intoopen-telemetry:mainfrom
VamshikrishnaMonagari:fix-exception-logging-patterns

Conversation

@VamshikrishnaMonagari
Copy link
Copy Markdown
Contributor

Category A : Remove redundant e.getMessage() where exception is already passed as the Throwable parameter:

  • GrpcExporter.java
  • HttpExporter.java
  • JaegerRemoteSampler.java (also fix stale FINEST log to pass exception as Throwable instead of concatenating)

Category B : Pass exception as Throwable instead of stringifying via getMessage(), so logging frameworks can render full stack traces:

  • AutoConfiguredOpenTelemetrySdkBuilder.java
  • DeclarativeConfiguration.java
  • TracerShim.java
  • SdkDoubleHistogram.java
  • SdkLongHistogram.java

Add best practice guidance to CONTRIBUTING.md recommending the use of dedicated logger overloads that accept a Throwable parameter.

Resolves #8228

@VamshikrishnaMonagari VamshikrishnaMonagari requested a review from a team as a code owner March 31, 2026 01:10
@VamshikrishnaMonagari VamshikrishnaMonagari force-pushed the fix-exception-logging-patterns branch from 7690798 to 699d1bd Compare March 31, 2026 01:16
…uidance

Category A — Remove redundant e.getMessage() where exception is already
passed as the Throwable parameter:
- GrpcExporter.java
- HttpExporter.java
- JaegerRemoteSampler.java (also fix stale FINEST log to pass exception
  as Throwable instead of concatenating)

Category B — Pass exception as Throwable instead of stringifying via
getMessage(), so logging frameworks can render full stack traces:
- AutoConfiguredOpenTelemetrySdkBuilder.java
- DeclarativeConfiguration.java
- TracerShim.java
- SdkDoubleHistogram.java
- SdkLongHistogram.java

Add best practice guidance to CONTRIBUTING.md recommending the use of
dedicated logger overloads that accept a Throwable parameter.

Resolves open-telemetry#8228
@VamshikrishnaMonagari VamshikrishnaMonagari force-pushed the fix-exception-logging-patterns branch from 699d1bd to e01ec36 Compare March 31, 2026 01:56
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.31%. Comparing base (7f50d5b) to head (e01ec36).

Files with missing lines Patch % Lines
...incubator/fileconfig/DeclarativeConfiguration.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8231      +/-   ##
============================================
- Coverage     90.32%   90.31%   -0.01%     
  Complexity     7653     7653              
============================================
  Files           843      843              
  Lines         23080    23074       -6     
  Branches       2312     2312              
============================================
- Hits          20846    20840       -6     
+ Misses         1516     1515       -1     
- Partials        718      719       +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.

Add contributing guidance for logging when handling exceptions

1 participant