Skip to content

OpenTelemetry context is not inherited by Enumerator #1918

@tavianator

Description

@tavianator

Inside an Enumerator, the current span appears different:

puts Fiber.current
puts OpenTelemetry::Trace.current_span&.context&.hex_span_id
enum = Enumerator.new do |y|
  puts Fiber.current
  puts OpenTelemetry::Trace.current_span&.context&.hex_span_id
  y << "foo"
end
enum.next
#<Fiber:0x00000001003cfa40 (resumed)>
564badbb047bd974
#<Fiber:0x0000000341732118 (resumed)>
0000000000000000

This is causing an issue for me with the Ruby Anthropic SDK, because they use an Enumerator for their HTTP requests: https://github.com/anthropics/anthropic-sdk-ruby/blob/9b9be231a1677c073f1bd6a341f15b56f9a6ec54/lib/anthropic/internal/transport/pooled_net_requester.rb#L136

I suspect this is related to #1807 and #1766.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions