diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h index 50e763e0c2..88de284831 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_exporter.h @@ -97,7 +97,7 @@ class ElasticsearchLogExporter final : public opentelemetry::sdk::logs::LogExpor void Export( const opentelemetry::nostd::span> &records, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept override; /** diff --git a/exporters/elasticsearch/src/es_log_exporter.cc b/exporters/elasticsearch/src/es_log_exporter.cc index 991678d6b9..6a511d197f 100644 --- a/exporters/elasticsearch/src/es_log_exporter.cc +++ b/exporters/elasticsearch/src/es_log_exporter.cc @@ -121,11 +121,11 @@ class AsyncResponseHandler : public http_client::EventHandler */ AsyncResponseHandler( std::shared_ptr session, - nostd::function_ref result_callback, + std::function &&result_callback, bool console_debug = false) : console_debug_{console_debug}, session_{std::move(session)}, - result_callback_{result_callback} + result_callback_{std::move(result_callback)} {} /** @@ -184,7 +184,7 @@ class AsyncResponseHandler : public http_client::EventHandler // Stores the session object for the request std::shared_ptr session_; // Callback to call to on receiving events - nostd::function_ref result_callback_; + std::function result_callback_; // A string to store the response body std::string body_ = ""; @@ -284,7 +284,7 @@ sdk::common::ExportResult ElasticsearchLogExporter::Export( void ElasticsearchLogExporter::Export( const opentelemetry::nostd::span> &records, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { // Return failure if this exporter has been shutdown if (isShutdown()) @@ -321,8 +321,8 @@ void ElasticsearchLogExporter::Export( request->SetBody(body_vec); // Send the request - auto handler = - std::make_shared(session, result_callback, options_.console_debug_); + auto handler = std::make_shared(session, std::move(result_callback), + options_.console_debug_); session->SendRequest(handler); } diff --git a/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h b/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h index eb3b4bd621..c6d057b4ba 100644 --- a/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h +++ b/exporters/jaeger/include/opentelemetry/exporters/jaeger/jaeger_exporter.h @@ -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> &spans, - nostd::function_ref - result_callback) noexcept override; + std::function + &&result_callback) noexcept override; /** * Shutdown the exporter. diff --git a/exporters/jaeger/src/jaeger_exporter.cc b/exporters/jaeger/src/jaeger_exporter.cc index 4a028773ca..f35b5bccd7 100644 --- a/exporters/jaeger/src/jaeger_exporter.cc +++ b/exporters/jaeger/src/jaeger_exporter.cc @@ -72,7 +72,7 @@ sdk_common::ExportResult JaegerExporter::Export( void JaegerExporter::Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call"); auto status = Export(spans); diff --git a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h index 3ebd3b8e89..ee9d9e9876 100644 --- a/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h +++ b/exporters/memory/include/opentelemetry/exporters/memory/in_memory_span_exporter.h @@ -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> &spans, - nostd::function_ref result_callback) noexcept override + void Export(const nostd::span> &spans, + std::function + &&result_callback) noexcept override { OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call"); auto status = Export(spans); diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h index 017d967c70..deb8645926 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_exporter.h @@ -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> &records, - opentelemetry::nostd::function_ref - result_callback) noexcept; + void Export( + const opentelemetry::nostd::span> &records, + std::function &&result_callback) noexcept; /** * Marks the OStream Log Exporter as shut down. diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h index 5af47280be..0044a29e47 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/span_exporter.h @@ -41,8 +41,8 @@ class OStreamSpanExporter final : public opentelemetry::sdk::trace::SpanExporter void Export( const opentelemetry::nostd::span> &spans, - opentelemetry::nostd::function_ref - result_callback) noexcept override; + std::function &&result_callback) noexcept + override; bool Shutdown( std::chrono::microseconds timeout = std::chrono::microseconds::max()) noexcept override; diff --git a/exporters/ostream/src/log_exporter.cc b/exporters/ostream/src/log_exporter.cc index d4122d6899..46f88b46d4 100644 --- a/exporters/ostream/src/log_exporter.cc +++ b/exporters/ostream/src/log_exporter.cc @@ -182,8 +182,7 @@ sdk::common::ExportResult OStreamLogExporter::Export( void OStreamLogExporter::Export( const opentelemetry::nostd::span> &records, - opentelemetry::nostd::function_ref - result_callback) noexcept + std::function &&result_callback) noexcept { // Do not have async support auto result = Export(records); diff --git a/exporters/ostream/src/span_exporter.cc b/exporters/ostream/src/span_exporter.cc index 24fcf6007b..d566a66f93 100644 --- a/exporters/ostream/src/span_exporter.cc +++ b/exporters/ostream/src/span_exporter.cc @@ -98,8 +98,7 @@ sdk::common::ExportResult OStreamSpanExporter::Export( void OStreamSpanExporter::Export( const opentelemetry::nostd::span> &spans, - opentelemetry::nostd::function_ref - result_callback) noexcept + std::function &&result_callback) noexcept { auto result = Export(spans); result_callback(result); diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h index 722e525b04..df02f2e215 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_exporter.h @@ -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> &spans, - nostd::function_ref result_callback) noexcept override; + virtual void Export(const nostd::span> &spans, + std::function + &&result_callback) noexcept override; /** * Shut down the exporter. diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter.h index 5b7f79e13b..13aba881bc 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_exporter.h @@ -62,7 +62,7 @@ class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogExporter */ virtual void Export( const nostd::span> &records, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept override; /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h index 599204c262..3e2a783eff 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_exporter.h @@ -93,7 +93,7 @@ class OtlpHttpExporter final : public opentelemetry::sdk::trace::SpanExporter */ virtual void Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept override; /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h index 417f1dcbf8..320a9bb963 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_exporter.h @@ -94,7 +94,7 @@ class OtlpHttpLogExporter final : public opentelemetry::sdk::logs::LogExporter */ virtual void Export( const nostd::span> &records, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept override; /** diff --git a/exporters/otlp/src/otlp_grpc_exporter.cc b/exporters/otlp/src/otlp_grpc_exporter.cc index f191580b7f..2192533f70 100644 --- a/exporters/otlp/src/otlp_grpc_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_exporter.cc @@ -145,7 +145,7 @@ sdk::common::ExportResult OtlpGrpcExporter::Export( void OtlpGrpcExporter::Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN( "[OTLP TRACE GRPC Exporter] async not supported. Making sync interface call"); diff --git a/exporters/otlp/src/otlp_grpc_log_exporter.cc b/exporters/otlp/src/otlp_grpc_log_exporter.cc index b56f8d9caa..06ee5de7ba 100644 --- a/exporters/otlp/src/otlp_grpc_log_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_log_exporter.cc @@ -163,7 +163,7 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export( void OtlpGrpcLogExporter::Export( const nostd::span> &logs, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN( "[OTLP LOG GRPC Exporter] async not supported. Making sync interface call"); diff --git a/exporters/otlp/src/otlp_http_exporter.cc b/exporters/otlp/src/otlp_http_exporter.cc index 29926d1651..d59d004c6c 100644 --- a/exporters/otlp/src/otlp_http_exporter.cc +++ b/exporters/otlp/src/otlp_http_exporter.cc @@ -61,7 +61,7 @@ opentelemetry::sdk::common::ExportResult OtlpHttpExporter::Export( void OtlpHttpExporter::Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call"); auto status = Export(spans); diff --git a/exporters/otlp/src/otlp_http_log_exporter.cc b/exporters/otlp/src/otlp_http_log_exporter.cc index bd17c4fb37..8116a25301 100644 --- a/exporters/otlp/src/otlp_http_log_exporter.cc +++ b/exporters/otlp/src/otlp_http_log_exporter.cc @@ -62,7 +62,7 @@ opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export( void OtlpHttpLogExporter::Export( const nostd::span> &logs, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN(" async not supported. Making sync interface call"); auto status = Export(logs); diff --git a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h index 3ac8c04028..28f09deaba 100644 --- a/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h +++ b/exporters/zipkin/include/opentelemetry/exporters/zipkin/zipkin_exporter.h @@ -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> &spans, - nostd::function_ref - result_callback) noexcept override; + std::function + &&result_callback) noexcept override; /** * Shut down the exporter. diff --git a/exporters/zipkin/src/zipkin_exporter.cc b/exporters/zipkin/src/zipkin_exporter.cc index 050ed4c9a8..202c048cca 100644 --- a/exporters/zipkin/src/zipkin_exporter.cc +++ b/exporters/zipkin/src/zipkin_exporter.cc @@ -95,7 +95,7 @@ sdk::common::ExportResult ZipkinExporter::Export( void ZipkinExporter::Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept + std::function &&result_callback) noexcept { OTEL_INTERNAL_LOG_WARN("[ZIPKIN EXPORTER] async not supported. Making sync interface call"); auto status = Export(spans); diff --git a/sdk/include/opentelemetry/sdk/logs/exporter.h b/sdk/include/opentelemetry/sdk/logs/exporter.h index 05990471d0..ee3bac92b4 100644 --- a/sdk/include/opentelemetry/sdk/logs/exporter.h +++ b/sdk/include/opentelemetry/sdk/logs/exporter.h @@ -53,7 +53,7 @@ class LogExporter */ virtual void Export( const nostd::span> &records, - nostd::function_ref result_callback) noexcept = 0; + std::function &&result_callback) noexcept = 0; /** * Marks the exporter as ShutDown and cleans up any resources as required. diff --git a/sdk/include/opentelemetry/sdk/trace/exporter.h b/sdk/include/opentelemetry/sdk/trace/exporter.h index 8078b23e48..749fd897fb 100644 --- a/sdk/include/opentelemetry/sdk/trace/exporter.h +++ b/sdk/include/opentelemetry/sdk/trace/exporter.h @@ -49,7 +49,7 @@ class SpanExporter */ virtual void Export( const nostd::span> &spans, - nostd::function_ref result_callback) noexcept = 0; + std::function &&result_callback) noexcept = 0; /** * Shut down the exporter. diff --git a/sdk/test/logs/batch_log_processor_test.cc b/sdk/test/logs/batch_log_processor_test.cc index 55850bf414..5fdda13ca7 100644 --- a/sdk/test/logs/batch_log_processor_test.cc +++ b/sdk/test/logs/batch_log_processor_test.cc @@ -55,9 +55,9 @@ class MockLogExporter final : public LogExporter return ExportResult::kSuccess; } - void Export( - const opentelemetry::nostd::span> &records, - opentelemetry::nostd::function_ref result_callback) noexcept override + void Export(const opentelemetry::nostd::span> &records, + std::function + &&result_callback) noexcept override { auto th = std::thread([this, records, result_callback]() { auto result = Export(records); diff --git a/sdk/test/logs/simple_log_processor_test.cc b/sdk/test/logs/simple_log_processor_test.cc index 8b8efa6636..e0c02203fa 100644 --- a/sdk/test/logs/simple_log_processor_test.cc +++ b/sdk/test/logs/simple_log_processor_test.cc @@ -55,7 +55,8 @@ class TestExporter final : public LogExporter // Dummy Async Export implementation void Export(const nostd::span> &records, - nostd::function_ref result_callback) noexcept override + std::function + &&result_callback) noexcept override { auto result = Export(records); result_callback(result); @@ -146,7 +147,8 @@ class FailShutDownExporter final : public LogExporter } void Export(const nostd::span> &records, - nostd::function_ref result_callback) noexcept override + std::function + &&result_callback) noexcept override { result_callback(ExportResult::kSuccess); } diff --git a/sdk/test/trace/batch_span_processor_test.cc b/sdk/test/trace/batch_span_processor_test.cc index 91561ac658..265cd5936e 100644 --- a/sdk/test/trace/batch_span_processor_test.cc +++ b/sdk/test/trace/batch_span_processor_test.cc @@ -56,9 +56,9 @@ class MockSpanExporter final : public sdk::trace::SpanExporter return sdk::common::ExportResult::kSuccess; } - void Export( - const nostd::span> &spans, - nostd::function_ref result_callback) noexcept override + void Export(const nostd::span> &spans, + std::function + &&result_callback) noexcept override { auto th = std::thread([this, spans, result_callback]() { auto result = Export(spans); diff --git a/sdk/test/trace/simple_processor_test.cc b/sdk/test/trace/simple_processor_test.cc index b8bad5962d..6c8a00ead2 100644 --- a/sdk/test/trace/simple_processor_test.cc +++ b/sdk/test/trace/simple_processor_test.cc @@ -52,8 +52,8 @@ class RecordShutdownExporter final : public SpanExporter } void Export(const opentelemetry::nostd::span> &spans, - opentelemetry::nostd::function_ref - result_callback) noexcept override + std::function + &&result_callback) noexcept override { result_callback(ExportResult::kSuccess); }