Skip to content

Commit

Permalink
Fix leak in Jaeger exporter
Browse files Browse the repository at this point in the history
The jaeger_span was never destroyed after its release from the
JaegerRecordable. This change let a `std::unique_ptr` handle
the destruction when going out of scope, first allowing the
`thrift::Span` to be copied to the `span_buffer_`.
  • Loading branch information
bjosv committed Dec 21, 2021
1 parent 1cf2422 commit 902fdfe
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions exporters/jaeger/src/thrift_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ int ThriftSender::Append(std::unique_ptr<JaegerRecordable> &&span) noexcept
max_span_bytes -= process_bytes_size_;
}

thrift::Span &jaeger_span = *span->Span();
jaeger_span.__set_tags(span->Tags());
jaeger_span.__set_logs(span->Logs());
auto jaeger_span = std::unique_ptr<thrift::Span>(span->Span());
jaeger_span->__set_tags(span->Tags());
jaeger_span->__set_logs(span->Logs());

const uint32_t span_size = CalcSizeOfSerializedThrift(jaeger_span);
const uint32_t span_size = CalcSizeOfSerializedThrift(*jaeger_span);
if (span_size > max_span_bytes)
{
OTEL_INTERNAL_LOG_ERROR("[JAEGER TRACE Exporter] Append() failed: too large span");
Expand All @@ -51,7 +51,7 @@ int ThriftSender::Append(std::unique_ptr<JaegerRecordable> &&span) noexcept
byte_buffer_size_ += span_size;
if (byte_buffer_size_ <= max_span_bytes)
{
span_buffer_.push_back(jaeger_span);
span_buffer_.push_back(*jaeger_span);
if (byte_buffer_size_ < max_span_bytes)
{
return 0;
Expand All @@ -64,7 +64,7 @@ int ThriftSender::Append(std::unique_ptr<JaegerRecordable> &&span) noexcept
}

const auto flushed = Flush();
span_buffer_.push_back(jaeger_span);
span_buffer_.push_back(*jaeger_span);
byte_buffer_size_ = span_size + process_bytes_size_;

return flushed;
Expand Down

0 comments on commit 902fdfe

Please sign in to comment.