Skip to content

Commit

Permalink
+ Fix warning when comparing signed and unsigned integer.
Browse files Browse the repository at this point in the history
+ Temporary fix the `Export()` may be called too many times when we shutdown or just wakeup worker thread once.This problem is completely fixed in open-telemetry#1209 but not merged yet.
+ Fix http client may has a different error code when our network is under a proxy.
  • Loading branch information
owent committed Mar 5, 2022
1 parent d8fafab commit 13628f3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ class ElasticSearchRecordable final : public sdk::logs::Recordable
void SetSeverity(opentelemetry::logs::Severity severity) noexcept override
{
// Convert the severity enum to a string
int severity_index = static_cast<int>(severity);
if (severity_index < 0 ||
severity_index >= std::extent<decltype(opentelemetry::logs::SeverityNumToText)>::value)
std::uint32_t severity_index = static_cast<std::uint32_t>(severity);
if (severity_index >= std::extent<decltype(opentelemetry::logs::SeverityNumToText)>::value)
{
std::stringstream sout;
sout << "Invalid severity(" << severity_index << ")";
Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/src/otlp_grpc_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ sdk::common::ExportResult OtlpGrpcExporter::Export(
<< " span(s) failed, exporter is shutdown");
return sdk::common::ExportResult::kFailure;
}
if (spans.empty())
{
return sdk::common::ExportResult::kSuccess;
}

proto::collector::trace::v1::ExportTraceServiceRequest request;
OtlpRecordableUtils::PopulateRequest(spans, &request);

Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/src/otlp_grpc_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export(
<< " log(s) failed, exporter is shutdown");
return sdk::common::ExportResult::kFailure;
}
if (logs.empty())
{
return sdk::common::ExportResult::kSuccess;
}

proto::collector::logs::v1::ExportLogsServiceRequest request;
OtlpRecordableUtils::PopulateRequest(logs, &request);

Expand Down
5 changes: 5 additions & 0 deletions exporters/otlp/src/otlp_http_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ std::unique_ptr<opentelemetry::sdk::trace::Recordable> OtlpHttpExporter::MakeRec
opentelemetry::sdk::common::ExportResult OtlpHttpExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans) noexcept
{
if (spans.empty())
{
return opentelemetry::sdk::common::ExportResult::kSuccess;
}

proto::collector::trace::v1::ExportTraceServiceRequest service_request;
OtlpRecordableUtils::PopulateRequest(spans, &service_request);
return http_client_->Export(service_request);
Expand Down
4 changes: 4 additions & 0 deletions exporters/otlp/src/otlp_http_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ std::unique_ptr<opentelemetry::sdk::logs::Recordable> OtlpHttpLogExporter::MakeR
opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs) noexcept
{
if (logs.empty())
{
return opentelemetry::sdk::common::ExportResult::kSuccess;
}
proto::collector::logs::v1::ExportLogsServiceRequest service_request;
OtlpRecordableUtils::PopulateRequest(logs, &service_request);
return http_client_->Export(service_request);
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/test/otlp_http_log_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ExportJsonIntegrationTest)

auto provider = nostd::shared_ptr<sdk::logs::LoggerProvider>(new sdk::logs::LoggerProvider());
provider->AddProcessor(std::unique_ptr<sdk::logs::LogProcessor>(
new sdk::logs::BatchLogProcessor(std::move(exporter), 5, std::chrono::milliseconds(256), 1)));
new sdk::logs::BatchLogProcessor(std::move(exporter), 5, std::chrono::milliseconds(256), 5)));

std::string report_trace_id;
std::string report_span_id;
Expand Down Expand Up @@ -192,7 +192,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ExportBinaryIntegrationTest)

auto provider = nostd::shared_ptr<sdk::logs::LoggerProvider>(new sdk::logs::LoggerProvider());
provider->AddProcessor(std::unique_ptr<sdk::logs::LogProcessor>(
new sdk::logs::BatchLogProcessor(std::move(exporter), 5, std::chrono::milliseconds(256), 1)));
new sdk::logs::BatchLogProcessor(std::move(exporter), 5, std::chrono::milliseconds(256), 5)));

std::string report_trace_id;
std::string report_span_id;
Expand Down
4 changes: 3 additions & 1 deletion ext/test/http/curl_http_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ TEST_F(BasicCurlHttpTests, SendGetRequestSyncTimeout)
auto result = http_client.Get("http://222.222.222.200:19000/get/", m1);
EXPECT_EQ(result, false);

EXPECT_EQ(result.GetSessionState(), http_client::SessionState::ConnectFailed);
// When network is under proxy, it may cennect success but closed by peer when send data
EXPECT_TRUE(result.GetSessionState() == http_client::SessionState::ConnectFailed ||
result.GetSessionState() == http_client::SessionState::SendFailed);
}

TEST_F(BasicCurlHttpTests, SendPostRequestSync)
Expand Down

0 comments on commit 13628f3

Please sign in to comment.