open-telemetry / open-telemetry/opentelemetry-ruby
Harden OTLP `AnyValue`/`TraceFlags` encoding for unsupported/ambiguous types
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 606
- Forks
- 301
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 42
Description
Spec requirement
Body MUST support AnyValue to preserve the semantics of structured logs (data-model.md:399-400 (permalink)); TraceFlags is defined as an 8-bit byte of bit flags.
Current behavior
exporter/otlp-logs/lib/opentelemetry/exporter/otlp/logs/logs_exporter.rb:328-347 (permalink) (as_otlp_any_value) has no case branch for nil/Symbol/Time/etc., silently producing an empty AnyValue for any unhandled type — e.g. body: nil is indistinguishable on the wire from an explicitly-empty AnyValue. Separately, :314 (permalink) reads log_record_data.trace_flags.instance_variable_get(:@flags), which only works when trace_flags is a TraceFlags object; it silently returns nil for a caller-supplied raw Integer (which is what log_record_data.rb:20 (permalink)'s own doc comment says the field's type should be).
Suggested fix
Add explicit handling (or at minimum a logged warning) for unsupported Body types in as_otlp_any_value, and make the trace_flags encoding branch on the actual runtime type (Integer vs TraceFlags) instead of assuming an ivar-bearing object.
Related rows in SPEC_COMPLIANCE_LOGS.md
DM-1, OTLP-15
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with as_otlp_any_value and the trace_flags encoding branch in exporter/otlp-logs/lib/opentelemetry/exporter/otlp/logs/logs_exporter.rb, then compare the declared type in logs_sdk/lib/opentelemetry/sdk/logs/log_record_data.rb. Check the referenced data-model.md requirements and SPEC_COMPLIANCE_LOGS.md rows DM-1 and OTLP-15. Done means unsupported Body values are handled explicitly or warned about, and both Integer and TraceFlags inputs encode correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100