Skip to content

Commit

Permalink
Changing the type of callback function in Export function to std::fun…
Browse files Browse the repository at this point in the history
  • Loading branch information
DebajitDas authored Mar 22, 2022
1 parent 6f53da3 commit 729c2f8
Show file tree
Hide file tree
Showing 25 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ElasticsearchLogExporter final : public opentelemetry::sdk::logs::LogExpor
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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
override;

/**
Expand Down
12 changes: 6 additions & 6 deletions exporters/elasticsearch/src/es_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class AsyncResponseHandler : public http_client::EventHandler
*/
AsyncResponseHandler(
std::shared_ptr<ext::http::client::Session> session,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback,
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback,
bool console_debug = false)
: console_debug_{console_debug},
session_{std::move(session)},
result_callback_{result_callback}
result_callback_{std::move(result_callback)}
{}

/**
Expand Down Expand Up @@ -184,7 +184,7 @@ class AsyncResponseHandler : public http_client::EventHandler
// Stores the session object for the request
std::shared_ptr<ext::http::client::Session> session_;
// Callback to call to on receiving events
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback_;
std::function<bool(opentelemetry::sdk::common::ExportResult)> result_callback_;

// A string to store the response body
std::string body_ = "";
Expand Down Expand Up @@ -284,7 +284,7 @@ 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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
{
// Return failure if this exporter has been shutdown
if (isShutdown())
Expand Down Expand Up @@ -321,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, std::move(result_callback),
options_.console_debug_);
session->SendRequest(handler);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class JaegerExporter final : public opentelemetry::sdk::trace::SpanExporter
* @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;
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override;

/**
* Shutdown the exporter.
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/src/jaeger_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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
std::function<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
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class InMemorySpanExporter final : public opentelemetry::sdk::trace::SpanExporte
* @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<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept override
void Export(const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
std::function<bool(opentelemetry::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,9 +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,
std::function<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 @@ -41,8 +41,8 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter
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;
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
override;

bool Shutdown(
std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override;
Expand Down
3 changes: 1 addition & 2 deletions exporters/ostream/src/log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ 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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
{
// Do not have async support
auto result = Export(records);
Expand Down
3 changes: 1 addition & 2 deletions exporters/ostream/src/span_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ 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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
{
auto result = Export(spans);
result_callback(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class OtlpGrpcExporter 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
*/
virtual void Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept override;
virtual void Export(const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override;

/**
* Shut down the exporter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogExporter
*/
virtual void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
override;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class OtlpHttpExporter final : public opentelemetry::sdk::trace::SpanExporter
*/
virtual void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
override;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class OtlpHttpLogExporter final : public opentelemetry::sdk::logs::LogExporter
*/
virtual void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::logs::Recordable>> &records,
nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)> result_callback) noexcept
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
override;

/**
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_grpc_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ 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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN(
"[OTLP TRACE GRPC Exporter] async not supported. Making sync interface call");
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_grpc_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ 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
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept
{
OTEL_INTERNAL_LOG_WARN(
"[OTLP LOG GRPC Exporter] async not supported. Making sync interface call");
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_http_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ 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
std::function<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
2 changes: 1 addition & 1 deletion exporters/otlp/src/otlp_http_log_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ 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
std::function<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
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class ZipkinExporter final : public opentelemetry::sdk::trace::SpanExporter
* @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;
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override;

/**
* Shut down the exporter.
Expand Down
2 changes: 1 addition & 1 deletion exporters/zipkin/src/zipkin_exporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ 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
std::function<bool(opentelemetry::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
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/logs/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LogExporter
*/
virtual void Export(
const nostd::span<std::unique_ptr<Recordable>> &records,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept = 0;
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept = 0;

/**
* Marks the exporter as ShutDown and cleans up any resources as required.
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/trace/exporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SpanExporter
*/
virtual void Export(
const nostd::span<std::unique_ptr<opentelemetry::sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept = 0;
std::function<bool(opentelemetry::sdk::common::ExportResult)> &&result_callback) noexcept = 0;

/**
* Shut down the exporter.
Expand Down
6 changes: 3 additions & 3 deletions sdk/test/logs/batch_log_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class MockLogExporter final : public LogExporter
return ExportResult::kSuccess;
}

void Export(
const opentelemetry::nostd::span<std::unique_ptr<Recordable>> &records,
opentelemetry::nostd::function_ref<bool(ExportResult)> result_callback) noexcept override
void Export(const opentelemetry::nostd::span<std::unique_ptr<Recordable>> &records,
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override
{
auto th = std::thread([this, records, result_callback]() {
auto result = Export(records);
Expand Down
6 changes: 4 additions & 2 deletions sdk/test/logs/simple_log_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class TestExporter final : public LogExporter

// Dummy Async Export implementation
void Export(const nostd::span<std::unique_ptr<Recordable>> &records,
nostd::function_ref<bool(ExportResult)> result_callback) noexcept override
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override
{
auto result = Export(records);
result_callback(result);
Expand Down Expand Up @@ -146,7 +147,8 @@ class FailShutDownExporter final : public LogExporter
}

void Export(const nostd::span<std::unique_ptr<Recordable>> &records,
nostd::function_ref<bool(ExportResult)> result_callback) noexcept override
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override
{
result_callback(ExportResult::kSuccess);
}
Expand Down
6 changes: 3 additions & 3 deletions sdk/test/trace/batch_span_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class MockSpanExporter final : public sdk::trace::SpanExporter
return sdk::common::ExportResult::kSuccess;
}

void Export(
const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
nostd::function_ref<bool(sdk::common::ExportResult)> result_callback) noexcept override
void Export(const nostd::span<std::unique_ptr<sdk::trace::Recordable>> &spans,
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override
{
auto th = std::thread([this, spans, result_callback]() {
auto result = Export(spans);
Expand Down
4 changes: 2 additions & 2 deletions sdk/test/trace/simple_processor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class RecordShutdownExporter final : public SpanExporter
}

void Export(const opentelemetry::nostd::span<std::unique_ptr<Recordable>> &spans,
opentelemetry::nostd::function_ref<bool(opentelemetry::sdk::common::ExportResult)>
result_callback) noexcept override
std::function<bool(opentelemetry::sdk::common::ExportResult)>
&&result_callback) noexcept override
{
result_callback(ExportResult::kSuccess);
}
Expand Down

0 comments on commit 729c2f8

Please sign in to comment.