Skip to content

Commit

Permalink
Fixing the format issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DebajitDas committed Mar 14, 2022
1 parent 14f0e7e commit e6ea337
Show file tree
Hide file tree
Showing 29 changed files with 134 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ class ElasticsearchLogExporter final : public opentelemetry::sdk::logs::LogExpor
* @param result_callback callback function accepting ExportResult as argument
*/
void Export(
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept override;
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>>
&records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
override;

/**
* Shutdown this exporter.
Expand Down
37 changes: 18 additions & 19 deletions exporters/elasticsearch/src/es_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class ResponseHandler : public http_client::EventHandler
bool console_debug_ = false;
};


/**
* This class handles the async response message from the Elasticsearch request
*/
Expand All @@ -121,20 +120,18 @@ class AsyncResponseHandler : public http_client::EventHandler
* Creates a response handler, that by default doesn't display to console
*/
AsyncResponseHandler(
std::shared_ptr<ext::http::client::Session> session,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback,
bool console_debug = false)
: console_debug_{console_debug}
, session_{std::move(session)}
, result_callback_{result_callback} {}
std::shared_ptr<ext::http::client::Session> session,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback,
bool console_debug = false)
: console_debug_{console_debug},
session_{std::move(session)},
result_callback_{result_callback}
{}

/**
* Cleans up the session in the destructor.
*/
~AsyncResponseHandler()
{
session_->FinishSession();
}
~AsyncResponseHandler() { session_->FinishSession(); }

/**
* Automatically called when the response is received
Expand All @@ -147,10 +144,12 @@ class AsyncResponseHandler : public http_client::EventHandler
if (body_.find("\"failed\" : 0") == std::string::npos)
{
OTEL_INTERNAL_LOG_ERROR(
"[ES Trace Exporter] Logs were not written to Elasticsearch correctly, response body: "
<< body_);
"[ES Trace Exporter] Logs were not written to Elasticsearch correctly, response body: "
<< body_);
result_callback_(sdk::common::ExportResult::kFailure);
} else {
}
else
{
result_callback_(sdk::common::ExportResult::kSuccess);
}
}
Expand Down Expand Up @@ -194,7 +193,6 @@ class AsyncResponseHandler : public http_client::EventHandler
bool console_debug_ = false;
};


ElasticsearchLogExporter::ElasticsearchLogExporter()
: options_{ElasticsearchExporterOptions()},
http_client_{new ext::http::client::curl::HttpClient()}
Expand Down Expand Up @@ -284,8 +282,9 @@ sdk::common::ExportResult ElasticsearchLogExporter::Export(
}

void ElasticsearchLogExporter::Export(
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>>
&records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
{
// Return failure if this exporter has been shutdown
if (isShutdown())
Expand Down Expand Up @@ -322,8 +321,8 @@ void ElasticsearchLogExporter::Export(
request->SetBody(body_vec);

// Send the request
auto handler = std::make_shared<AsyncResponseHandler>(
session, result_callback, options_.console_debug_);
auto handler =
std::make_shared<AsyncResponseHandler>(session, result_callback, options_.console_debug_);
session->SendRequest(handler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ class JaegerExporter final : public opentelemetry::sdk::trace::SpanExporter
* @param spans a span of unique pointers to span recordables
* @param result_callback callback function accepting ExportResult as argument
*/
void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback)
noexcept override;

void Export(const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept override;

/**
* Shutdown the exporter.
Expand Down
6 changes: 2 additions & 4 deletions exporters/jaeger/src/jaeger_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,12 @@ sdk_common::ExportResult JaegerExporter::Export(
}

void JaegerExporter::Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback)
noexcept
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call");
auto status = Export(spans);
result_callback(status);

}

void JaegerExporter::InitializeEndpoint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte
*/
void Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback)
noexcept override
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept override
{
OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call");
auto status = Export(spans);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ class OStreamLogExporter final : public opentelemetry::sdk::logs::LogExporter
/**
* Exports a span of logs sent from the processor asynchronously.
*/
void Export(
const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>> &records,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback)
noexcept;
void Export(const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>> &records,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept;

/**
* Marks the OStream Log Exporter as shut down.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
&spans) noexcept override;

void Export(
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback)
noexcept override;
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>>
&spans,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept override;

bool Shutdown(
std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;
Expand Down
6 changes: 3 additions & 3 deletions exporters/ostream/src/log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ sdk::common::ExportResult OStreamLogExporter::Export(
}

void OStreamLogExporter::Export(
const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>> &records,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback)
noexcept
const opentelemetry::nostd::span<std::unique_ptr<sdk::logs::Recordable>> &records,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept
{
// Do not have async support
auto result = Export(records);
Expand Down
5 changes: 3 additions & 2 deletions exporters/ostream/src/span_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ sdk::common::ExportResult OStreamSpanExporter::Export(
}

void OStreamSpanExporter::Export(
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
const opentelemetry::nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept
{
auto result = Export(spans);
result_callback(result);
Expand Down
9 changes: 4 additions & 5 deletions exporters/otlp/src/otlp_grpc_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,13 @@ sdk::common::ExportResult OtlpGrpcExporter::Export(
}

void OtlpGrpcExporter::Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback)
noexcept
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN("[OTLP TRACE GRPC Exporter] async not supported. Making sync interface call");
OTEL_INTERNAL_LOG_WARN(
"[OTLP TRACE GRPC Exporter] async not supported. Making sync interface call");
auto status = Export(spans);
result_callback(status);

}

bool OtlpGrpcExporter::Shutdown(std::chrono::microseconds timeout) noexcept
Expand Down
7 changes: 4 additions & 3 deletions exporters/otlp/src/otlp_grpc_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export(
}

void OtlpGrpcLogExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN("[OTLP LOG GRPC Exporter] async not supported. Making sync interface call");
OTEL_INTERNAL_LOG_WARN(
"[OTLP LOG GRPC Exporter] async not supported. Making sync interface call");
auto status = Export(logs);
result_callback(status);
}
Expand Down
5 changes: 2 additions & 3 deletions exporters/otlp/src/otlp_http_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

#include "opentelemetry/sdk/common/global_log_handler.h"


namespace nostd = opentelemetry::nostd;

OPENTELEMETRY_BEGIN_NAMESPACE
Expand Down Expand Up @@ -60,8 +59,8 @@ opentelemetry::sdk::common::ExportResult OtlpHttpExporter::Export(
}

void OtlpHttpExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call");
auto status = Export(spans);
Expand Down
4 changes: 2 additions & 2 deletions exporters/otlp/src/otlp_http_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export(
}

void OtlpHttpLogExporter::Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &logs,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call");
auto status = Export(logs);
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/test/otlp_http_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ TEST_F(OtlpHttpExporterTestPeer, ExportJsonIntegrationTest)
auto mock_session =
std::static_pointer_cast<http_client::nosend::Session>(no_send_client->session_);
EXPECT_CALL(*mock_session, SendRequest)
.WillOnce([&mock_session,
report_trace_id](std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
.WillOnce([&mock_session, report_trace_id](
std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false);
auto resource_span = *check_json["resource_spans"].begin();
auto instrumentation_library_span = *resource_span["instrumentation_library_spans"].begin();
Expand Down Expand Up @@ -217,8 +217,8 @@ TEST_F(OtlpHttpExporterTestPeer, ExportBinaryIntegrationTest)
auto mock_session =
std::static_pointer_cast<http_client::nosend::Session>(no_send_client->session_);
EXPECT_CALL(*mock_session, SendRequest)
.WillOnce([&mock_session,
report_trace_id](std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
.WillOnce([&mock_session, report_trace_id](
std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
opentelemetry::proto::collector::trace::v1::ExportTraceServiceRequest request_body;
request_body.ParseFromArray(&mock_session->GetRequest()->body_[0],
static_cast<int>(mock_session->GetRequest()->body_.size()));
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/test/otlp_http_log_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ TEST_F(OtlpHttpLogExporterTestPeer, ExportJsonIntegrationTest)
auto mock_session =
std::static_pointer_cast<http_client::nosend::Session>(no_send_client->session_);
EXPECT_CALL(*mock_session, SendRequest)
.WillOnce([&mock_session, report_trace_id,
report_span_id](std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
.WillOnce([&mock_session, report_trace_id, report_span_id](
std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false);
auto resource_logs = *check_json["resource_logs"].begin();
auto instrumentation_library_span = *resource_logs["instrumentation_library_logs"].begin();
Expand Down Expand Up @@ -232,8 +232,8 @@ TEST_F(OtlpHttpLogExporterTestPeer, ExportBinaryIntegrationTest)
auto mock_session =
std::static_pointer_cast<http_client::nosend::Session>(no_send_client->session_);
EXPECT_CALL(*mock_session, SendRequest)
.WillOnce([&mock_session, report_trace_id,
report_span_id](std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
.WillOnce([&mock_session, report_trace_id, report_span_id](
std::shared_ptr<opentelemetry::ext::http::client::EventHandler> callback) {
opentelemetry::proto::collector::logs::v1::ExportLogsServiceRequest request_body;
request_body.ParseFromArray(&mock_session->GetRequest()->body_[0],
static_cast<int>(mock_session->GetRequest()->body_.size()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ class ZipkinExporter final : public opentelemetry::sdk::trace::SpanExporter
* @param spans a span of unique pointers to span recordables
* @param result_callback callback function accepting ExportResult as argument
*/
void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback)
noexcept override;
void Export(const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept override;

/**
* Shut down the exporter.
Expand Down
5 changes: 2 additions & 3 deletions exporters/zipkin/src/zipkin_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ sdk::common::ExportResult ZipkinExporter::Export(
}

void ZipkinExporter::Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback)
noexcept
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN("[ZIPKIN EXPORTER] async not supported. Making sync interface call");
auto status = Export(spans);
Expand Down
1 change: 0 additions & 1 deletion ext/test/http/curl_http_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ TEST_F(BasicCurlHttpTests, SendPostRequest)

session_manager->CancelAllSessions();
session_manager->FinishAllSessions();

}

TEST_F(BasicCurlHttpTests, RequestTimeout)
Expand Down
3 changes: 2 additions & 1 deletion sdk/include/opentelemetry/sdk/logs/batch_log_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ class BatchLogProcessor : public LogProcessor
const bool is_export_async_;

/* Synchronization primitives */
std::condition_variable cv_, force_flush_cv_, async_shutdown_cv_;;
std::condition_variable cv_, force_flush_cv_, async_shutdown_cv_;
;
std::mutex cv_m_, force_flush_cv_m_, shutdown_m_, async_shutdown_m_;

/* The buffer/queue to which the ended logs are added */
Expand Down
1 change: 0 additions & 1 deletion sdk/include/opentelemetry/sdk/logs/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class LogExporter
virtual sdk::common::ExportResult Export(
const nostd::span<std::unique_ptr<Recordable>> &records) noexcept = 0;


/**
* Exports asynchronously the batch of log records to their export destination
* @param records a span of unique pointers to log records
Expand Down
5 changes: 3 additions & 2 deletions sdk/include/opentelemetry/sdk/logs/simple_log_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class SimpleLogProcessor : public LogProcessor
{

public:
explicit SimpleLogProcessor(std::unique_ptr<LogExporter> &&exporter, bool is_export_async = false);
explicit SimpleLogProcessor(std::unique_ptr<LogExporter> &&exporter,
bool is_export_async = false);
virtual ~SimpleLogProcessor() = default;

std::unique_ptr<Recordable> MakeRecordable() noexcept override;
Expand All @@ -48,7 +49,7 @@ class SimpleLogProcessor : public LogProcessor
opentelemetry::common::SpinLockMutex lock_;
// The atomic boolean flag to ensure the ShutDown() function is only called once
std::atomic_flag shutdown_latch_ = ATOMIC_FLAG_INIT;
bool is_export_async_ = false;
bool is_export_async_ = false;
};
} // namespace logs
} // namespace sdk
Expand Down
Loading

0 comments on commit e6ea337

Please sign in to comment.