Skip to content

Commit

Permalink
Merge branch 'main' into fix_368_consistent_namespace_scope_resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
PaurushGarg authored Nov 15, 2021
2 parents 692ac34 + b2a0a56 commit 2a1d460
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogExporter
* Shutdown this exporter.
* @param timeout The maximum time to wait for the shutdown method to return.
*/
bool Shutdown(std::chrono::microseconds timeout = std::chrono::microseconds(0)) noexcept override
{
return true;
}
bool Shutdown(
std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;

private:
// Configuration options for the exporter
Expand All @@ -79,6 +77,7 @@ class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogExporter
* @param stub the service stub to be used for exporting
*/
OtlpGrpcLogExporter(std::unique_ptr<proto::collector::logs::v1::LogsService::StubInterface> stub);
bool is_shutdown_ = false;
};

} // namespace otlp
Expand Down
11 changes: 11 additions & 0 deletions exporters/otlp/src/otlp_grpc_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ std::unique_ptr<opentelemetry::sdk::logs::Recordable> OtlpGrpcLogExporter::MakeR
opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs) noexcept
{
if (is_shutdown_)
{
OTEL_INTERNAL_LOG_ERROR("[OTLP gRPC log] Export failed, exporter is shutdown");
return sdk::common::ExportResult::kFailure;
}
proto::collector::logs::v1::ExportLogsServiceRequest request;
OtlpRecordableUtils::PopulateRequest(logs, &request);

Expand All @@ -150,6 +155,12 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export(
return sdk::common::ExportResult::kSuccess;
}

bool OtlpGrpcLogExporter::Shutdown(std::chrono::microseconds timeout) noexcept
{
is_shutdown_ = true;
return true;
}

} // namespace otlp
} // namespace exporter
OPENTELEMETRY_END_NAMESPACE
Expand Down
6 changes: 2 additions & 4 deletions exporters/otlp/test/otlp_grpc_log_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TEST_F(OtlpGrpcLogExporterTestPeer, ShutdownTest)
// exporter shuold not be shutdown by default
nostd::span<std::unique_ptr<sdk::logs::Recordable>> batch_1(&recordable_1, 1);
EXPECT_CALL(*mock_stub, Export(_, _, _))
.Times(Exactly(2))
.Times(Exactly(1))
.WillOnce(Return(grpc::Status::OK))
.WillOnce(Return(grpc::Status::CANCELLED));

Expand Down Expand Up @@ -132,11 +132,9 @@ TEST_F(OtlpGrpcLogExporterTestPeer, ExportIntegrationTest)

uint8_t trace_id_bin[opentelemetry::trace::TraceId::kSize] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
char trace_id_hex[2 * opentelemetry::trace::TraceId::kSize] = {0};
opentelemetry::trace::TraceId trace_id{trace_id_bin};
uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4',
uint8_t span_id_bin[opentelemetry::trace::SpanId::kSize] = {'7', '6', '5', '4',
'3', '2', '1', '0'};
char span_id_hex[2 * opentelemetry::trace::SpanId::kSize] = {0};
opentelemetry::trace::SpanId span_id{span_id_bin};

auto logger = provider->GetLogger("test");
Expand Down

0 comments on commit 2a1d460

Please sign in to comment.