Open MaxLeb opened 4 days ago
According to the trace, this line at exporters/elasticsearch/src/es_log_record_exporter.cc:353, crashes with a nullptr:
synchronization_data_->session_counter_.fetch_add(1, std::memory_order_release);
I think I found the issue.
I will test it as soon as I can but I am using the constructor
:
ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter(
const ElasticsearchExporterOptions &options)
: options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()}
{}
and it never calls the other constructor that initiate the synchronization_data_
:
ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter()
: options_{ElasticsearchExporterOptions()},
http_client_{ext::http::client::HttpClientFactory::Create()}
#ifdef ENABLE_ASYNC_EXPORT
,
synchronization_data_(new SynchronizationData())
#endif
{
#ifdef ENABLE_ASYNC_EXPORT
synchronization_data_->finished_session_counter_.store(0);
synchronization_data_->session_counter_.store(0);
#endif
}
I will test to fix it and probably submit a PR or at least a patch here if I do not have time to properly create the PR.
As expected, fixing the code fixes the crash. Here is a patch that makes it work, will try to provide a proper PR
0001-EXPORTER-Fix-crash-in-ElasticsearchLogRecordExporter.patch
Thanks, synchronization_data_
was obviously missing.
Please file a PR for this.
Describe your environment
Using a manually built version of OpenTelemetry 1.16.1 on macOS with :
Steps to reproduce
The usage is pretty simple:
First an init of the exporter with a single log record processor:
Then, when logs needs to be sent a call to
m_Logger.EmitLogRecord(xxx)
What is the expected behavior? The program should run and send the log to the ELK endpoint.
What is the actual behavior? It crashes on
es_log_record_exporter.cc:353
Backtrace:
Additional context There is no problem if using a
HttpLogRecordExporter
instead of aElasticsearchLogRecordExporter
with the exact samecode