Improve error reporting / debugging UX with the OTLP default/HTTP exporters #1936
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
addresses: #1931
This PR significantly enhances the debugging experience for OTLP exporters by:
These changes ended up helping me debug a really gnarly issue where a slightly old version of the sentry-ruby SDK was causing issues with how the OpenTelemetry ruby SDK was bubbling up errors due to incorrect IPv6 parsing - causing all my traces to be dropped with an one-line error
Unable to export X spans
.Reviewer's Note
Significant AI assistance was used in the process of getting this PR working.
Motivation
Previously, when OTLP exports failed, developers had minimal information to diagnose the root cause. The exporters simply returned a
FAILURE
constant without any context about:This made troubleshooting production issues extremely difficult, especially for:
Changes
1. Enhanced Export Result Type (
sdk/lib/opentelemetry/sdk/trace/export.rb
)Introduced a new
ExportResult
class that wraps result codes with optional error context:Backwards Compatibility: The
ExportResult
class overloads the==
operator and providesto_i
to ensure existing code comparing results toSUCCESS
,FAILURE
, orTIMEOUT
constants continues to work seamlessly.2. Comprehensive Debug Logging
Added detailed debug-level logging at key points in the export pipeline:
Entry/Exit Points
HTTP Request Flow
Exception Handling
Examples of new debug logs:
3. Rich Failure Context
All failure scenarios now return detailed context via
Export.failure()
:HTTP Error Responses
Network Exceptions
Timeout Scenarios
4. Enhanced BatchSpanProcessor Error Reporting
Updated
BatchSpanProcessor
to extract and log error context:5. Updated Exporters
Applied consistent changes to both:
exporter/otlp/lib/opentelemetry/exporter/otlp/exporter.rb
)exporter/otlp-http/lib/opentelemetry/exporter/otlp/http/trace_exporter.rb
)Both now capture exception objects and maintain the error context through the entire export pipeline.
Example Scenarios
Before
After (with debug logging enabled)