From 15a148e1ac5fd7f5f187042b0531550e80c2c471 Mon Sep 17 00:00:00 2001 From: WenTao Ou Date: Fri, 21 Oct 2022 16:13:25 +0800 Subject: [PATCH] Fix debug log of OTLP HTTP exporter and ES log exporter (#1703) --- exporters/elasticsearch/src/es_log_exporter.cc | 4 ++-- exporters/otlp/src/otlp_http_client.cc | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/exporters/elasticsearch/src/es_log_exporter.cc b/exporters/elasticsearch/src/es_log_exporter.cc index 3d7ee72949..13798ae300 100644 --- a/exporters/elasticsearch/src/es_log_exporter.cc +++ b/exporters/elasticsearch/src/es_log_exporter.cc @@ -35,10 +35,10 @@ class ResponseHandler : public http_client::EventHandler const std::string &body) noexcept { std::stringstream ss; - ss << "Status:" << response.GetStatusCode() << "Header:"; + ss << "Status:" << response.GetStatusCode() << ", Header:"; response.ForEachHeader([&ss](opentelemetry::nostd::string_view header_name, opentelemetry::nostd::string_view header_value) { - ss << "\t" << header_name.data() << " : " << header_value.data() << ","; + ss << "\t" << header_name.data() << ": " << header_value.data() << ","; return true; }); ss << "Body:" << body; diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index b64ebb16d1..8ea20919df 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -83,10 +83,10 @@ class ResponseHandler : public http_client::EventHandler const std::string &body) noexcept { std::stringstream ss; - ss << "Status:" << response.GetStatusCode() << "Header:"; + ss << "Status:" << response.GetStatusCode() << ", Header:"; response.ForEachHeader([&ss](opentelemetry::nostd::string_view header_name, opentelemetry::nostd::string_view header_value) { - ss << "\t" << header_name.data() << " : " << header_value.data() << ","; + ss << "\t" << header_name.data() << ": " << header_value.data() << ","; return true; }); ss << "Body:" << body; @@ -116,8 +116,7 @@ class ResponseHandler : public http_client::EventHandler OTEL_INTERNAL_LOG_ERROR("OTLP HTTP Client] Export failed, " << log_message); result = sdk::common::ExportResult::kFailure; } - - if (console_debug_) + else if (console_debug_) { if (log_message.empty()) {