lib/ddtrace/transport/traces.rb in ddtrace-0.46.0 vs lib/ddtrace/transport/traces.rb in ddtrace-0.47.0
- old
+ new
@@ -121,10 +121,24 @@
if downgrade?(response)
downgrade!
return send_traces(traces)
end
end
- end.force
+ end
+
+ # Force resolution of lazy enumerator.
+ #
+ # The "correct" method to call here would be `#force`,
+ # as this method was created to force the eager loading
+ # of a lazy enumerator.
+ #
+ # Unfortunately, JRuby < 9.2.9.0 erroneously eagerly loads
+ # the lazy Enumerator during intermediate steps.
+ # This forces us to use `#to_a`, as this method works for both
+ # lazy and regular Enumerators.
+ # Using `#to_a` can mask the fact that we expect a lazy
+ # Enumerator.
+ responses = responses.to_a
Datadog.health_metrics.transport_chunked(responses.size)
responses
end