From 7efeeabeea09f11a91531b2a575725cbb91fea9b Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Sun, 6 Nov 2022 21:08:24 +0100 Subject: [PATCH] [Logs SDK] LogProcessor, LogExporter class name (#1736) --- examples/otlp/README.md | 4 +- examples/otlp/grpc_log_main.cc | 4 +- examples/otlp/http_log_main.cc | 6 +- .../elasticsearch/es_log_record_exporter.h | 12 +-- .../src/es_log_record_exporter.cc | 13 ++-- .../test/es_log_record_exporter_test.cc | 6 +- .../exporters/ostream/log_record_exporter.h | 10 +-- exporters/ostream/src/log_record_exporter.cc | 12 +-- exporters/ostream/test/ostream_log_test.cc | 34 +++++---- .../otlp/otlp_grpc_log_record_exporter.h | 17 +++-- .../otlp_grpc_log_record_exporter_factory.h | 8 +- .../exporters/otlp/otlp_http_client.h | 2 +- .../otlp/otlp_http_log_record_exporter.h | 18 ++--- .../otlp_http_log_record_exporter_factory.h | 10 +-- .../otlp_http_log_record_exporter_options.h | 2 +- .../otlp/src/otlp_grpc_log_record_exporter.cc | 17 +++-- .../otlp_grpc_log_record_exporter_factory.cc | 9 ++- .../otlp/src/otlp_http_log_record_exporter.cc | 35 +++++---- .../otlp_http_log_record_exporter_factory.cc | 11 +-- ...p_grpc_log_record_exporter_factory_test.cc | 6 +- .../otlp_grpc_log_record_exporter_test.cc | 17 +++-- ...p_http_log_record_exporter_factory_test.cc | 6 +- .../otlp_http_log_record_exporter_test.cc | 75 ++++++++++--------- .../sdk/logs/batch_log_record_processor.h | 10 +-- .../logs/batch_log_record_processor_factory.h | 8 +- .../logs/batch_log_record_processor_options.h | 2 +- .../sdk/logs/multi_log_record_processor.h | 6 +- .../logs/multi_log_record_processor_factory.h | 4 +- .../sdk/logs/simple_log_record_processor.h | 6 +- .../simple_log_record_processor_factory.h | 6 +- sdk/src/logs/batch_log_record_processor.cc | 37 ++++----- .../batch_log_record_processor_factory.cc | 6 +- sdk/src/logs/logger_context.cc | 5 +- sdk/src/logs/multi_log_record_processor.cc | 15 ++-- .../multi_log_record_processor_factory.cc | 4 +- sdk/src/logs/simple_log_record_processor.cc | 12 +-- .../simple_log_record_processor_factory.cc | 4 +- .../logs/batch_log_record_processor_test.cc | 23 +++--- sdk/test/logs/logger_provider_sdk_test.cc | 6 +- .../logs/simple_log_record_processor_test.cc | 12 +-- 40 files changed, 260 insertions(+), 240 deletions(-) diff --git a/examples/otlp/README.md b/examples/otlp/README.md index f97af279da..43010e6d79 100644 --- a/examples/otlp/README.md +++ b/examples/otlp/README.md @@ -13,8 +13,8 @@ calls a `foo_library` which has been instrumented using the [OpenTelemetry API](https://github.com/open-telemetry/opentelemetry-cpp/tree/main/api). ### Logs -The application in `http_log_main.cc` initializes an `OtlpHttpLogExporter` instance, -the application in `grpc_log_main.cc` initializes an `OtlpGrpcLogExporter` instance. +The application in `http_log_main.cc` initializes an `OtlpHttpLogRecordExporter` instance, +the application in `grpc_log_main.cc` initializes an `OtlpGrpcLogRecordExporter` instance. And they register a logger provider from the [OpenTelemetry SDK](https://github.com/open-telemetry/opentelemetry-cpp). The application then calls a `logs_foo_library` which has been instrumented using the [OpenTelemetry diff --git a/examples/otlp/grpc_log_main.cc b/examples/otlp/grpc_log_main.cc index d5705bcd8d..2dcfd92f1a 100644 --- a/examples/otlp/grpc_log_main.cc +++ b/examples/otlp/grpc_log_main.cc @@ -43,8 +43,8 @@ void InitTracer() void InitLogger() { // Create OTLP exporter instance - auto exporter = otlp::OtlpGrpcLogExporterFactory::Create(opts); - auto processor = logs_sdk::SimpleLogProcessorFactory::Create(std::move(exporter)); + auto exporter = otlp::OtlpGrpcLogRecordExporterFactory::Create(opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); nostd::shared_ptr provider( logs_sdk::LoggerProviderFactory::Create(std::move(processor))); diff --git a/examples/otlp/http_log_main.cc b/examples/otlp/http_log_main.cc index 5d1471516c..ed52389f6e 100644 --- a/examples/otlp/http_log_main.cc +++ b/examples/otlp/http_log_main.cc @@ -42,13 +42,13 @@ void InitTracer() trace::Provider::SetTracerProvider(provider); } -opentelemetry::exporter::otlp::OtlpHttpLogExporterOptions logger_opts; +opentelemetry::exporter::otlp::OtlpHttpLogRecordExporterOptions logger_opts; void InitLogger() { logger_opts.console_debug = true; // Create OTLP exporter instance - auto exporter = otlp::OtlpHttpLogExporterFactory::Create(logger_opts); - auto processor = logs_sdk::SimpleLogProcessorFactory::Create(std::move(exporter)); + auto exporter = otlp::OtlpHttpLogRecordExporterFactory::Create(logger_opts); + auto processor = logs_sdk::SimpleLogRecordProcessorFactory::Create(std::move(exporter)); std::shared_ptr provider = logs_sdk::LoggerProviderFactory::Create(std::move(processor)); diff --git a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h index 2768dd9dc9..2659851fd7 100644 --- a/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h +++ b/exporters/elasticsearch/include/opentelemetry/exporters/elasticsearch/es_log_record_exporter.h @@ -59,21 +59,21 @@ struct ElasticsearchExporterOptions }; /** - * The ElasticsearchLogExporter exports logs to Elasticsearch in JSON format + * The ElasticsearchLogRecordExporter exports logs to Elasticsearch in JSON format */ -class ElasticsearchLogExporter final : public opentelemetry::sdk::logs::LogRecordExporter +class ElasticsearchLogRecordExporter final : public opentelemetry::sdk::logs::LogRecordExporter { public: /** - * Create an ElasticsearchLogExporter with default exporter options. + * Create an ElasticsearchLogRecordExporter with default exporter options. */ - ElasticsearchLogExporter(); + ElasticsearchLogRecordExporter(); /** - * Create an ElasticsearchLogExporter with user specified options. + * Create an ElasticsearchLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ - ElasticsearchLogExporter(const ElasticsearchExporterOptions &options); + ElasticsearchLogRecordExporter(const ElasticsearchExporterOptions &options); /** * Creates a recordable that stores the data in a JSON object diff --git a/exporters/elasticsearch/src/es_log_record_exporter.cc b/exporters/elasticsearch/src/es_log_record_exporter.cc index c3f4013412..72e3b2cad2 100644 --- a/exporters/elasticsearch/src/es_log_record_exporter.cc +++ b/exporters/elasticsearch/src/es_log_record_exporter.cc @@ -289,21 +289,22 @@ class AsyncResponseHandler : public http_client::EventHandler }; # endif -ElasticsearchLogExporter::ElasticsearchLogExporter() +ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter() : options_{ElasticsearchExporterOptions()}, http_client_{ext::http::client::HttpClientFactory::Create()} {} -ElasticsearchLogExporter::ElasticsearchLogExporter(const ElasticsearchExporterOptions &options) +ElasticsearchLogRecordExporter::ElasticsearchLogRecordExporter( + const ElasticsearchExporterOptions &options) : options_{options}, http_client_{ext::http::client::HttpClientFactory::Create()} {} -std::unique_ptr ElasticsearchLogExporter::MakeRecordable() noexcept +std::unique_ptr ElasticsearchLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr(new ElasticSearchRecordable); } -sdk::common::ExportResult ElasticsearchLogExporter::Export( +sdk::common::ExportResult ElasticsearchLogRecordExporter::Export( const nostd::span> &records) noexcept { // Return failure if this exporter has been shutdown @@ -400,7 +401,7 @@ sdk::common::ExportResult ElasticsearchLogExporter::Export( # endif } -bool ElasticsearchLogExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept +bool ElasticsearchLogRecordExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { const std::lock_guard locked(lock_); is_shutdown_ = true; @@ -412,7 +413,7 @@ bool ElasticsearchLogExporter::Shutdown(std::chrono::microseconds /* timeout */) return true; } -bool ElasticsearchLogExporter::isShutdown() const noexcept +bool ElasticsearchLogRecordExporter::isShutdown() const noexcept { const std::lock_guard locked(lock_); return is_shutdown_; diff --git a/exporters/elasticsearch/test/es_log_record_exporter_test.cc b/exporters/elasticsearch/test/es_log_record_exporter_test.cc index 099ae3fae9..4cd3b5064f 100644 --- a/exporters/elasticsearch/test/es_log_record_exporter_test.cc +++ b/exporters/elasticsearch/test/es_log_record_exporter_test.cc @@ -33,7 +33,7 @@ TEST(ElasticsearchLogsExporterTests, InvalidEndpoint) // Create an elasticsearch exporter auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogExporter(options)); + std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter(options)); // Create a log record and send to the exporter auto record = exporter->MakeRecordable(); @@ -48,7 +48,7 @@ TEST(ElasticsearchLogsExporterTests, Shutdown) { // Create an elasticsearch exporter and immediately shut it down auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogExporter); + std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); bool shutdownResult = exporter->Shutdown(); ASSERT_TRUE(shutdownResult); @@ -65,7 +65,7 @@ TEST(ElasticsearchLogsExporterTests, RecordableCreation) { // Create an elasticsearch exporter auto exporter = - std::unique_ptr(new logs_exporter::ElasticsearchLogExporter); + std::unique_ptr(new logs_exporter::ElasticsearchLogRecordExporter); // Create a recordable auto record = exporter->MakeRecordable(); diff --git a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h index e25559a095..7aa60a8409 100644 --- a/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h +++ b/exporters/ostream/include/opentelemetry/exporters/ostream/log_record_exporter.h @@ -19,16 +19,16 @@ namespace exporter namespace logs { /** - * The OStreamLogExporter exports logs through an ostream (default set to std::cout) + * The OStreamLogRecordExporter exports logs through an ostream (default set to std::cout) */ -class OStreamLogExporter final : public opentelemetry::sdk::logs::LogRecordExporter +class OStreamLogRecordExporter final : public opentelemetry::sdk::logs::LogRecordExporter { public: /** - * Create an OStreamLogExporter. This constructor takes in a reference to an ostream that the - * Export() method will send log data into. The default ostream is set to stdout. + * Create an OStreamLogRecordExporter. This constructor takes in a reference to an ostream that + * the Export() method will send log data into. The default ostream is set to stdout. */ - explicit OStreamLogExporter(std::ostream &sout = std::cout) noexcept; + explicit OStreamLogRecordExporter(std::ostream &sout = std::cout) noexcept; std::unique_ptr MakeRecordable() noexcept override; diff --git a/exporters/ostream/src/log_record_exporter.cc b/exporters/ostream/src/log_record_exporter.cc index 8a9562a475..66cff9c41b 100644 --- a/exporters/ostream/src/log_record_exporter.cc +++ b/exporters/ostream/src/log_record_exporter.cc @@ -21,16 +21,16 @@ namespace logs /*********************** Constructor ***********************/ -OStreamLogExporter::OStreamLogExporter(std::ostream &sout) noexcept : sout_(sout) {} +OStreamLogRecordExporter::OStreamLogRecordExporter(std::ostream &sout) noexcept : sout_(sout) {} /*********************** Exporter methods ***********************/ -std::unique_ptr OStreamLogExporter::MakeRecordable() noexcept +std::unique_ptr OStreamLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr(new sdklogs::LogRecord()); } -sdk::common::ExportResult OStreamLogExporter::Export( +sdk::common::ExportResult OStreamLogRecordExporter::Export( const nostd::span> &records) noexcept { if (isShutdown()) @@ -102,20 +102,20 @@ sdk::common::ExportResult OStreamLogExporter::Export( return sdk::common::ExportResult::kSuccess; } -bool OStreamLogExporter::Shutdown(std::chrono::microseconds) noexcept +bool OStreamLogRecordExporter::Shutdown(std::chrono::microseconds) noexcept { const std::lock_guard locked(lock_); is_shutdown_ = true; return true; } -bool OStreamLogExporter::isShutdown() const noexcept +bool OStreamLogRecordExporter::isShutdown() const noexcept { const std::lock_guard locked(lock_); return is_shutdown_; } -void OStreamLogExporter::printAttributes( +void OStreamLogRecordExporter::printAttributes( const std::unordered_map &map, const std::string prefix) { diff --git a/exporters/ostream/test/ostream_log_test.cc b/exporters/ostream/test/ostream_log_test.cc index 77a67c1265..12551caf83 100644 --- a/exporters/ostream/test/ostream_log_test.cc +++ b/exporters/ostream/test/ostream_log_test.cc @@ -26,9 +26,10 @@ namespace logs { // Test that when OStream Log exporter is shutdown, no logs should be sent to stream -TEST(OStreamLogExporter, Shutdown) +TEST(OStreamLogRecordExporter, Shutdown) { - auto exporter = std::unique_ptr(new exporterlogs::OStreamLogExporter); + auto exporter = + std::unique_ptr(new exporterlogs::OStreamLogRecordExporter); // Save cout's original buffer here std::streambuf *original = std::cout.rdbuf(); @@ -57,8 +58,8 @@ TEST(OStreamLogExporter, Shutdown) // This function tests MakeRecordable() as well as Export(). TEST(OstreamLogExporter, DefaultLogRecordToCout) { - auto exporter = - std::unique_ptr(new exporterlogs::OStreamLogExporter(std::cout)); + auto exporter = std::unique_ptr( + new exporterlogs::OStreamLogRecordExporter(std::cout)); // Save cout's original buffer here std::streambuf *original = std::cout.rdbuf(); @@ -98,11 +99,11 @@ TEST(OstreamLogExporter, DefaultLogRecordToCout) // Testing what a log record with only the "timestamp", "severity", "name" and "message" fields set, // will print out -TEST(OStreamLogExporter, SimpleLogToCout) +TEST(OStreamLogRecordExporter, SimpleLogToCout) { // Initialize an Ostream exporter to std::cout - auto exporter = - std::unique_ptr(new exporterlogs::OStreamLogExporter(std::cout)); + auto exporter = std::unique_ptr( + new exporterlogs::OStreamLogRecordExporter(std::cout)); // Save original stream buffer, then redirect cout to our new stream buffer std::streambuf *original = std::cout.rdbuf(); @@ -152,11 +153,11 @@ TEST(OStreamLogExporter, SimpleLogToCout) // Testing what a log record with only the "resource" and "attributes" fields // (i.e. KeyValueIterable types) set with primitive types, will print out -TEST(OStreamLogExporter, LogWithStringAttributesToCerr) +TEST(OStreamLogRecordExporter, LogWithStringAttributesToCerr) { // Initialize an Ostream exporter to cerr - auto exporter = - std::unique_ptr(new exporterlogs::OStreamLogExporter(std::cerr)); + auto exporter = std::unique_ptr( + new exporterlogs::OStreamLogRecordExporter(std::cerr)); // Save original stream buffer, then redirect cout to our new stream buffer std::streambuf *original = std::cerr.rdbuf(); @@ -208,12 +209,12 @@ TEST(OStreamLogExporter, LogWithStringAttributesToCerr) // Testing what a log record with only the "resource", and "attributes" fields // (i.e. KeyValueIterable types), set with 2D arrays as values, will print out -TEST(OStreamLogExporter, LogWithVariantTypesToClog) +TEST(OStreamLogRecordExporter, LogWithVariantTypesToClog) { // Initialize an Ostream exporter to cerr - auto exporter = - std::unique_ptr(new exporterlogs::OStreamLogExporter(std::clog)); + auto exporter = std::unique_ptr( + new exporterlogs::OStreamLogRecordExporter(std::clog)); // Save original stream buffer, then redirect cout to our new stream buffer std::streambuf *original = std::clog.rdbuf(); @@ -270,13 +271,14 @@ TEST(OStreamLogExporter, LogWithVariantTypesToClog) // Test using the simple log processor and ostream exporter to cout // and use the rest of the logging pipeline (Logger, LoggerProvider, Provider) as well -TEST(OStreamLogExporter, IntegrationTest) +TEST(OStreamLogRecordExporter, IntegrationTest) { // Initialize a logger - auto exporter = std::unique_ptr(new exporterlogs::OStreamLogExporter); + auto exporter = + std::unique_ptr(new exporterlogs::OStreamLogRecordExporter); auto sdkProvider = std::shared_ptr(new sdklogs::LoggerProvider()); sdkProvider->AddProcessor(std::unique_ptr( - new sdklogs::SimpleLogProcessor(std::move(exporter)))); + new sdklogs::SimpleLogRecordProcessor(std::move(exporter)))); auto apiProvider = nostd::shared_ptr(sdkProvider); auto provider = nostd::shared_ptr(apiProvider); logs_api::Provider::SetLoggerProvider(provider); diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h index 7adcfa9976..05224550a3 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter.h @@ -26,19 +26,19 @@ namespace otlp /** * The OTLP exporter exports log data in OpenTelemetry Protocol (OTLP) format in gRPC. */ -class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogRecordExporter +class OtlpGrpcLogRecordExporter : public opentelemetry::sdk::logs::LogRecordExporter { public: /** - * Create an OtlpGrpcLogExporter with default exporter options. + * Create an OtlpGrpcLogRecordExporter with default exporter options. */ - OtlpGrpcLogExporter(); + OtlpGrpcLogRecordExporter(); /** - * Create an OtlpGrpcLogExporter with user specified options. + * Create an OtlpGrpcLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ - OtlpGrpcLogExporter(const OtlpGrpcExporterOptions &options); + OtlpGrpcLogRecordExporter(const OtlpGrpcExporterOptions &options); /** * Creates a recordable that stores the data in protobuf. @@ -67,17 +67,18 @@ class OtlpGrpcLogExporter : public opentelemetry::sdk::logs::LogRecordExporter const OtlpGrpcExporterOptions options_; // For testing - friend class OtlpGrpcLogExporterTestPeer; + friend class OtlpGrpcLogRecordExporterTestPeer; // Store service stub internally. Useful for testing. std::unique_ptr log_service_stub_; /** - * Create an OtlpGrpcLogExporter using the specified service stub. + * Create an OtlpGrpcLogRecordExporter using the specified service stub. * Only tests can call this constructor directly. * @param stub the service stub to be used for exporting */ - OtlpGrpcLogExporter(std::unique_ptr stub); + OtlpGrpcLogRecordExporter( + std::unique_ptr stub); bool is_shutdown_ = false; mutable opentelemetry::common::SpinLockMutex lock_; bool isShutdown() const noexcept; diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h index eac0877c2a..84e5aa1e96 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h @@ -15,18 +15,18 @@ namespace otlp { /** - * Factory class for OtlpGrpcLogExporter. + * Factory class for OtlpGrpcLogRecordExporter. */ -class OtlpGrpcLogExporterFactory +class OtlpGrpcLogRecordExporterFactory { public: /** - * Create a OtlpGrpcLogExporter. + * Create a OtlpGrpcLogRecordExporter. */ static std::unique_ptr Create(); /** - * Create a OtlpGrpcLogExporter. + * Create a OtlpGrpcLogRecordExporter. */ static std::unique_ptr Create( const OtlpGrpcExporterOptions &options); diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h index bf154b23a0..d230f64dae 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_client.h @@ -230,7 +230,7 @@ class OtlpHttpClient // For testing friend class OtlpHttpExporterTestPeer; - friend class OtlpHttpLogExporterTestPeer; + friend class OtlpHttpLogRecordExporterTestPeer; friend class OtlpHttpMetricExporterTestPeer; /** diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h index e35cde7671..2250cfe831 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter.h @@ -25,19 +25,19 @@ namespace otlp /** * The OTLP exporter exports log data in OpenTelemetry Protocol (OTLP) format. */ -class OtlpHttpLogExporter final : public opentelemetry::sdk::logs::LogRecordExporter +class OtlpHttpLogRecordExporter final : public opentelemetry::sdk::logs::LogRecordExporter { public: /** - * Create an OtlpHttpLogExporter with default exporter options. + * Create an OtlpHttpLogRecordExporter with default exporter options. */ - OtlpHttpLogExporter(); + OtlpHttpLogRecordExporter(); /** - * Create an OtlpHttpLogExporter with user specified options. + * Create an OtlpHttpLogRecordExporter with user specified options. * @param options An object containing the user's configuration options. */ - OtlpHttpLogExporter(const OtlpHttpLogExporterOptions &options); + OtlpHttpLogRecordExporter(const OtlpHttpLogRecordExporterOptions &options); /** * Creates a recordable that stores the data in a JSON object @@ -62,18 +62,18 @@ class OtlpHttpLogExporter final : public opentelemetry::sdk::logs::LogRecordExpo private: // Configuration options for the exporter - const OtlpHttpLogExporterOptions options_; + const OtlpHttpLogRecordExporterOptions options_; // Object that stores the HTTP sessions that have been created std::unique_ptr http_client_; // For testing - friend class OtlpHttpLogExporterTestPeer; + friend class OtlpHttpLogRecordExporterTestPeer; /** - * Create an OtlpHttpLogExporter using the specified http client. + * Create an OtlpHttpLogRecordExporter using the specified http client. * Only tests can call this constructor directly. * @param http_client the http client to be used for exporting */ - OtlpHttpLogExporter(std::unique_ptr http_client); + OtlpHttpLogRecordExporter(std::unique_ptr http_client); }; } // namespace otlp } // namespace exporter diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h index 1db6c776f2..d2ea095245 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_factory.h @@ -16,21 +16,21 @@ namespace otlp { /** - * Factory class for OtlpHttpLogExporter. + * Factory class for OtlpHttpLogRecordExporter. */ -class OtlpHttpLogExporterFactory +class OtlpHttpLogRecordExporterFactory { public: /** - * Create a OtlpHttpLogExporter. + * Create a OtlpHttpLogRecordExporter. */ static std::unique_ptr Create(); /** - * Create a OtlpHttpLogExporter. + * Create a OtlpHttpLogRecordExporter. */ static std::unique_ptr Create( - const OtlpHttpLogExporterOptions &options); + const OtlpHttpLogRecordExporterOptions &options); }; } // namespace otlp diff --git a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h index daea975b1c..4ad5d82005 100644 --- a/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h +++ b/exporters/otlp/include/opentelemetry/exporters/otlp/otlp_http_log_record_exporter_options.h @@ -22,7 +22,7 @@ namespace otlp /** * Struct to hold OTLP exporter options. */ -struct OtlpHttpLogExporterOptions +struct OtlpHttpLogRecordExporterOptions { // The endpoint to export to. By default // @see diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc index d8d0c44e6c..75e6b36597 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter.cc @@ -31,28 +31,31 @@ namespace otlp { // -------------------------------- Constructors -------------------------------- -OtlpGrpcLogExporter::OtlpGrpcLogExporter() : OtlpGrpcLogExporter(OtlpGrpcExporterOptions()) {} +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter() + : OtlpGrpcLogRecordExporter(OtlpGrpcExporterOptions()) +{} -OtlpGrpcLogExporter::OtlpGrpcLogExporter(const OtlpGrpcExporterOptions &options) +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter(const OtlpGrpcExporterOptions &options) : options_(options), log_service_stub_( OtlpGrpcClient::MakeServiceStub(options)) {} -OtlpGrpcLogExporter::OtlpGrpcLogExporter( +OtlpGrpcLogRecordExporter::OtlpGrpcLogRecordExporter( std::unique_ptr stub) : options_(OtlpGrpcExporterOptions()), log_service_stub_(std::move(stub)) {} // ----------------------------- Exporter methods ------------------------------ -std::unique_ptr OtlpGrpcLogExporter::MakeRecordable() noexcept +std::unique_ptr +OtlpGrpcLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr( new exporter::otlp::OtlpLogRecordable()); } -opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export( +opentelemetry::sdk::common::ExportResult OtlpGrpcLogRecordExporter::Export( const nostd::span> &logs) noexcept { if (isShutdown()) @@ -82,14 +85,14 @@ opentelemetry::sdk::common::ExportResult OtlpGrpcLogExporter::Export( return sdk::common::ExportResult::kSuccess; } -bool OtlpGrpcLogExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept +bool OtlpGrpcLogRecordExporter::Shutdown(std::chrono::microseconds /* timeout */) noexcept { const std::lock_guard locked(lock_); is_shutdown_ = true; return true; } -bool OtlpGrpcLogExporter::isShutdown() const noexcept +bool OtlpGrpcLogRecordExporter::isShutdown() const noexcept { const std::lock_guard locked(lock_); return is_shutdown_; diff --git a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc index bc015cfbee..d52a6269ba 100644 --- a/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc +++ b/exporters/otlp/src/otlp_grpc_log_record_exporter_factory.cc @@ -15,17 +15,18 @@ namespace exporter namespace otlp { -std::unique_ptr OtlpGrpcLogExporterFactory::Create() +std::unique_ptr +OtlpGrpcLogRecordExporterFactory::Create() { OtlpGrpcExporterOptions options; return Create(options); } -std::unique_ptr OtlpGrpcLogExporterFactory::Create( - const OtlpGrpcExporterOptions &options) +std::unique_ptr +OtlpGrpcLogRecordExporterFactory::Create(const OtlpGrpcExporterOptions &options) { std::unique_ptr exporter( - new OtlpGrpcLogExporter(options)); + new OtlpGrpcLogRecordExporter(options)); return exporter; } diff --git a/exporters/otlp/src/otlp_http_log_record_exporter.cc b/exporters/otlp/src/otlp_http_log_record_exporter.cc index 46aa7ec346..77c70b628c 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter.cc @@ -23,9 +23,12 @@ namespace exporter namespace otlp { -OtlpHttpLogExporter::OtlpHttpLogExporter() : OtlpHttpLogExporter(OtlpHttpLogExporterOptions()) {} +OtlpHttpLogRecordExporter::OtlpHttpLogRecordExporter() + : OtlpHttpLogRecordExporter(OtlpHttpLogRecordExporterOptions()) +{} -OtlpHttpLogExporter::OtlpHttpLogExporter(const OtlpHttpLogExporterOptions &options) +OtlpHttpLogRecordExporter::OtlpHttpLogRecordExporter( + const OtlpHttpLogRecordExporterOptions &options) : options_(options), http_client_(new OtlpHttpClient(OtlpHttpClientOptions(options.url, options.content_type, @@ -42,17 +45,18 @@ OtlpHttpLogExporter::OtlpHttpLogExporter(const OtlpHttpLogExporterOptions &optio ))) {} -OtlpHttpLogExporter::OtlpHttpLogExporter(std::unique_ptr http_client) - : options_(OtlpHttpLogExporterOptions()), http_client_(std::move(http_client)) +OtlpHttpLogRecordExporter::OtlpHttpLogRecordExporter(std::unique_ptr http_client) + : options_(OtlpHttpLogRecordExporterOptions()), http_client_(std::move(http_client)) { - OtlpHttpLogExporterOptions &options = const_cast(options_); - options.url = http_client_->GetOptions().url; - options.content_type = http_client_->GetOptions().content_type; - options.json_bytes_mapping = http_client_->GetOptions().json_bytes_mapping; - options.use_json_name = http_client_->GetOptions().use_json_name; - options.console_debug = http_client_->GetOptions().console_debug; - options.timeout = http_client_->GetOptions().timeout; - options.http_headers = http_client_->GetOptions().http_headers; + OtlpHttpLogRecordExporterOptions &options = + const_cast(options_); + options.url = http_client_->GetOptions().url; + options.content_type = http_client_->GetOptions().content_type; + options.json_bytes_mapping = http_client_->GetOptions().json_bytes_mapping; + options.use_json_name = http_client_->GetOptions().use_json_name; + options.console_debug = http_client_->GetOptions().console_debug; + options.timeout = http_client_->GetOptions().timeout; + options.http_headers = http_client_->GetOptions().http_headers; # ifdef ENABLE_ASYNC_EXPORT options.max_concurrent_requests = http_client_->GetOptions().max_concurrent_requests; options.max_requests_per_connection = http_client_->GetOptions().max_requests_per_connection; @@ -60,13 +64,14 @@ OtlpHttpLogExporter::OtlpHttpLogExporter(std::unique_ptr http_cl } // ----------------------------- Exporter methods ------------------------------ -std::unique_ptr OtlpHttpLogExporter::MakeRecordable() noexcept +std::unique_ptr +OtlpHttpLogRecordExporter::MakeRecordable() noexcept { return std::unique_ptr( new exporter::otlp::OtlpLogRecordable()); } -opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export( +opentelemetry::sdk::common::ExportResult OtlpHttpLogRecordExporter::Export( const nostd::span> &logs) noexcept { if (http_client_->IsShutdown()) @@ -115,7 +120,7 @@ opentelemetry::sdk::common::ExportResult OtlpHttpLogExporter::Export( # endif } -bool OtlpHttpLogExporter::Shutdown(std::chrono::microseconds timeout) noexcept +bool OtlpHttpLogRecordExporter::Shutdown(std::chrono::microseconds timeout) noexcept { return http_client_->Shutdown(timeout); } diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_factory.cc b/exporters/otlp/src/otlp_http_log_record_exporter_factory.cc index 4e9c27a249..d05d68ce26 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter_factory.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter_factory.cc @@ -13,17 +13,18 @@ namespace exporter namespace otlp { -std::unique_ptr OtlpHttpLogExporterFactory::Create() +std::unique_ptr +OtlpHttpLogRecordExporterFactory::Create() { - OtlpHttpLogExporterOptions options; + OtlpHttpLogRecordExporterOptions options; return Create(options); } -std::unique_ptr OtlpHttpLogExporterFactory::Create( - const OtlpHttpLogExporterOptions &options) +std::unique_ptr +OtlpHttpLogRecordExporterFactory::Create(const OtlpHttpLogRecordExporterOptions &options) { std::unique_ptr exporter( - new OtlpHttpLogExporter(options)); + new OtlpHttpLogRecordExporter(options)); return exporter; } diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc index bf50d8c99c..5219d22d14 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_factory_test.cc @@ -9,7 +9,7 @@ # include "opentelemetry/exporters/otlp/otlp_grpc_log_record_exporter_factory.h" /* - Make sure OtlpGrpcLogExporterFactory does not require, + Make sure OtlpGrpcLogRecordExporterFactory does not require, even indirectly, protobuf headers. */ # ifdef GOOGLE_PROTOBUF_VERSION @@ -22,13 +22,13 @@ namespace exporter namespace otlp { -TEST(OtlpGrpcLogExporterFactoryTest, BuildTest) +TEST(OtlpGrpcLogRecordExporterFactoryTest, BuildTest) { OtlpGrpcExporterOptions opts; opts.endpoint = "localhost:45454"; std::unique_ptr exporter = - OtlpGrpcLogExporterFactory::Create(opts); + OtlpGrpcLogRecordExporterFactory::Create(opts); EXPECT_TRUE(exporter != nullptr); } diff --git a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc index b6c796b5b6..34aee61a0c 100644 --- a/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_grpc_log_record_exporter_test.cc @@ -36,24 +36,24 @@ namespace exporter namespace otlp { -class OtlpGrpcLogExporterTestPeer : public ::testing::Test +class OtlpGrpcLogRecordExporterTestPeer : public ::testing::Test { public: std::unique_ptr GetExporter( std::unique_ptr &stub_interface) { return std::unique_ptr( - new OtlpGrpcLogExporter(std::move(stub_interface))); + new OtlpGrpcLogRecordExporter(std::move(stub_interface))); } // Get the options associated with the given exporter. - const OtlpGrpcExporterOptions &GetOptions(std::unique_ptr &exporter) + const OtlpGrpcExporterOptions &GetOptions(std::unique_ptr &exporter) { return exporter->options_; } }; -TEST_F(OtlpGrpcLogExporterTestPeer, ShutdownTest) +TEST_F(OtlpGrpcLogRecordExporterTestPeer, ShutdownTest) { auto mock_stub = new proto::collector::logs::v1::MockLogsServiceStub(); std::unique_ptr stub_interface(mock_stub); @@ -80,7 +80,7 @@ TEST_F(OtlpGrpcLogExporterTestPeer, ShutdownTest) } // Call Export() directly -TEST_F(OtlpGrpcLogExporterTestPeer, ExportUnitTest) +TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportUnitTest) { auto mock_stub = new proto::collector::logs::v1::MockLogsServiceStub(); std::unique_ptr stub_interface(mock_stub); @@ -105,7 +105,7 @@ TEST_F(OtlpGrpcLogExporterTestPeer, ExportUnitTest) } // Create spans, let processor call Export() -TEST_F(OtlpGrpcLogExporterTestPeer, ExportIntegrationTest) +TEST_F(OtlpGrpcLogRecordExporterTestPeer, ExportIntegrationTest) { auto mock_stub = new proto::collector::logs::v1::MockLogsServiceStub(); std::unique_ptr stub_interface(mock_stub); @@ -121,8 +121,9 @@ TEST_F(OtlpGrpcLogExporterTestPeer, ExportIntegrationTest) opentelemetry::nostd::string_view attribute_storage_string_value[] = {"vector", "string"}; auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); - provider->AddProcessor(std::unique_ptr( - new sdk::logs::BatchLogProcessor(std::move(exporter), 5, std::chrono::milliseconds(256), 1))); + provider->AddProcessor( + std::unique_ptr(new sdk::logs::BatchLogRecordProcessor( + std::move(exporter), 5, std::chrono::milliseconds(256), 1))); EXPECT_CALL(*mock_stub, Export(_, _, _)) .Times(AtLeast(1)) diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc index af4e1874b1..34b408d8a2 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_factory_test.cc @@ -30,13 +30,13 @@ namespace exporter namespace otlp { -TEST(OtlpHttpLogExporterFactoryTest, BuildTest) +TEST(OtlpHttpLogRecordExporterFactoryTest, BuildTest) { - OtlpHttpLogExporterOptions opts; + OtlpHttpLogRecordExporterOptions opts; opts.url = "localhost:45454"; std::unique_ptr exporter = - OtlpHttpLogExporterFactory::Create(opts); + OtlpHttpLogRecordExporterFactory::Create(opts); EXPECT_TRUE(exporter != nullptr); } diff --git a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc index 9c9d663f50..ca23fb7fe5 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -54,7 +54,7 @@ static nostd::span MakeSpan(T (&array)[N]) OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_type, bool async_mode) { - OtlpHttpLogExporterOptions options; + OtlpHttpLogRecordExporterOptions options; options.content_type = content_type; options.console_debug = true; options.http_headers.insert( @@ -71,18 +71,19 @@ OtlpHttpClientOptions MakeOtlpHttpClientOptions(HttpRequestContentType content_t namespace http_client = opentelemetry::ext::http::client; -class OtlpHttpLogExporterTestPeer : public ::testing::Test +class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test { public: std::unique_ptr GetExporter( std::unique_ptr http_client) { return std::unique_ptr( - new OtlpHttpLogExporter(std::move(http_client))); + new OtlpHttpLogRecordExporter(std::move(http_client))); } // Get the options associated with the given exporter. - const OtlpHttpLogExporterOptions &GetOptions(std::unique_ptr &exporter) + const OtlpHttpLogRecordExporterOptions &GetOptions( + std::unique_ptr &exporter) { return exporter->options_; } @@ -97,7 +98,7 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test void ExportJsonIntegrationTest() { auto mock_otlp_client = - OtlpHttpLogExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson); + OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson); auto mock_otlp_http_client = mock_otlp_client.first; auto client = mock_otlp_client.second; auto exporter = GetExporter(std::unique_ptr{mock_otlp_http_client}); @@ -113,7 +114,7 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); provider->AddProcessor( - std::unique_ptr(new sdk::logs::BatchLogProcessor( + std::unique_ptr(new sdk::logs::BatchLogRecordProcessor( std::move(exporter), 5, std::chrono::milliseconds(256), 5))); std::string report_trace_id; @@ -190,8 +191,8 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test # ifdef ENABLE_ASYNC_EXPORT void ExportJsonIntegrationTestAsync() { - auto mock_otlp_client = - OtlpHttpLogExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson, true); + auto mock_otlp_client = OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient( + HttpRequestContentType::kJson, true); auto mock_otlp_http_client = mock_otlp_client.first; auto client = mock_otlp_client.second; auto exporter = GetExporter(std::unique_ptr{mock_otlp_http_client}); @@ -205,13 +206,13 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test opentelemetry::nostd::string_view attribute_storage_string_value[] = {"vector", "string"}; auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); - sdk::logs::BatchLogProcessorOptions options; + sdk::logs::BatchLogRecordProcessorOptions options; options.max_queue_size = 5; options.schedule_delay_millis = std::chrono::milliseconds(256); options.max_export_batch_size = 5; provider->AddProcessor(std::unique_ptr( - new sdk::logs::BatchLogProcessor(std::move(exporter), options))); + new sdk::logs::BatchLogRecordProcessor(std::move(exporter), options))); std::string report_trace_id; std::string report_span_id; @@ -293,7 +294,7 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test void ExportBinaryIntegrationTest() { auto mock_otlp_client = - OtlpHttpLogExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary); + OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary); auto mock_otlp_http_client = mock_otlp_client.first; auto client = mock_otlp_client.second; auto exporter = GetExporter(std::unique_ptr{mock_otlp_http_client}); @@ -307,12 +308,12 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test opentelemetry::nostd::string_view attribute_storage_string_value[] = {"vector", "string"}; auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); - sdk::logs::BatchLogProcessorOptions processor_options; + sdk::logs::BatchLogRecordProcessorOptions processor_options; processor_options.max_export_batch_size = 5; processor_options.max_queue_size = 5; processor_options.schedule_delay_millis = std::chrono::milliseconds(256); provider->AddProcessor(std::unique_ptr( - new sdk::logs::BatchLogProcessor(std::move(exporter), processor_options))); + new sdk::logs::BatchLogRecordProcessor(std::move(exporter), processor_options))); std::string report_trace_id; std::string report_span_id; @@ -386,8 +387,8 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test # ifdef ENABLE_ASYNC_EXPORT void ExportBinaryIntegrationTestAsync() { - auto mock_otlp_client = - OtlpHttpLogExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary, true); + auto mock_otlp_client = OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient( + HttpRequestContentType::kBinary, true); auto mock_otlp_http_client = mock_otlp_client.first; auto client = mock_otlp_client.second; auto exporter = GetExporter(std::unique_ptr{mock_otlp_http_client}); @@ -402,12 +403,12 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test auto provider = nostd::shared_ptr(new sdk::logs::LoggerProvider()); - sdk::logs::BatchLogProcessorOptions processor_options; + sdk::logs::BatchLogRecordProcessorOptions processor_options; processor_options.max_export_batch_size = 5; processor_options.max_queue_size = 5; processor_options.schedule_delay_millis = std::chrono::milliseconds(256); provider->AddProcessor(std::unique_ptr( - new sdk::logs::BatchLogProcessor(std::move(exporter), processor_options))); + new sdk::logs::BatchLogRecordProcessor(std::move(exporter), processor_options))); std::string report_trace_id; std::string report_span_id; @@ -484,10 +485,10 @@ class OtlpHttpLogExporterTestPeer : public ::testing::Test # endif }; -TEST(OtlpHttpLogExporterTest, Shutdown) +TEST(OtlpHttpLogRecordExporterTest, Shutdown) { auto exporter = - std::unique_ptr(new OtlpHttpLogExporter()); + std::unique_ptr(new OtlpHttpLogRecordExporter()); ASSERT_TRUE(exporter->Shutdown()); nostd::span> logs = {}; @@ -497,61 +498,61 @@ TEST(OtlpHttpLogExporterTest, Shutdown) } // Create log records, let processor call Export() -TEST_F(OtlpHttpLogExporterTestPeer, ExportJsonIntegrationTestSync) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestSync) { ExportJsonIntegrationTest(); } # ifdef ENABLE_ASYNC_EXPORT -TEST_F(OtlpHttpLogExporterTestPeer, ExportJsonIntegrationTestAsync) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportJsonIntegrationTestAsync) { ExportJsonIntegrationTestAsync(); } # endif // Create log records, let processor call Export() -TEST_F(OtlpHttpLogExporterTestPeer, ExportBinaryIntegrationTestSync) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportBinaryIntegrationTestSync) { ExportBinaryIntegrationTest(); } # ifdef ENABLE_ASYNC_EXPORT -TEST_F(OtlpHttpLogExporterTestPeer, ExportBinaryIntegrationTestAsync) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ExportBinaryIntegrationTestAsync) { ExportBinaryIntegrationTestAsync(); } # endif // Test exporter configuration options -TEST_F(OtlpHttpLogExporterTestPeer, ConfigTest) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigTest) { - OtlpHttpLogExporterOptions opts; + OtlpHttpLogRecordExporterOptions opts; opts.url = "http://localhost:45456/v1/logs"; - std::unique_ptr exporter(new OtlpHttpLogExporter(opts)); + std::unique_ptr exporter(new OtlpHttpLogRecordExporter(opts)); EXPECT_EQ(GetOptions(exporter).url, "http://localhost:45456/v1/logs"); } // Test exporter configuration options with use_json_name -TEST_F(OtlpHttpLogExporterTestPeer, ConfigUseJsonNameTest) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigUseJsonNameTest) { - OtlpHttpLogExporterOptions opts; + OtlpHttpLogRecordExporterOptions opts; opts.use_json_name = true; - std::unique_ptr exporter(new OtlpHttpLogExporter(opts)); + std::unique_ptr exporter(new OtlpHttpLogRecordExporter(opts)); EXPECT_EQ(GetOptions(exporter).use_json_name, true); } // Test exporter configuration options with json_bytes_mapping=JsonBytesMappingKind::kHex -TEST_F(OtlpHttpLogExporterTestPeer, ConfigJsonBytesMappingTest) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigJsonBytesMappingTest) { - OtlpHttpLogExporterOptions opts; + OtlpHttpLogRecordExporterOptions opts; opts.json_bytes_mapping = JsonBytesMappingKind::kHex; - std::unique_ptr exporter(new OtlpHttpLogExporter(opts)); + std::unique_ptr exporter(new OtlpHttpLogRecordExporter(opts)); EXPECT_EQ(GetOptions(exporter).json_bytes_mapping, JsonBytesMappingKind::kHex); } # ifndef NO_GETENV // Test exporter configuration options with use_ssl_credentials -TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromEnv) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigFromEnv) { const std::string url = "http://localhost:9999/v1/logs"; setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:9999", 1); @@ -559,7 +560,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromEnv) setenv("OTEL_EXPORTER_OTLP_HEADERS", "k1=v1,k2=v2", 1); setenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS", "k1=v3,k1=v4", 1); - std::unique_ptr exporter(new OtlpHttpLogExporter()); + std::unique_ptr exporter(new OtlpHttpLogRecordExporter()); EXPECT_EQ(GetOptions(exporter).url, url); EXPECT_EQ( GetOptions(exporter).timeout.count(), @@ -591,7 +592,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromEnv) unsetenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS"); } -TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromLogsEnv) +TEST_F(OtlpHttpLogRecordExporterTestPeer, ConfigFromLogsEnv) { const std::string url = "http://localhost:9999/v1/logs"; setenv("OTEL_EXPORTER_OTLP_LOGS_ENDPOINT", url.c_str(), 1); @@ -599,7 +600,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromLogsEnv) setenv("OTEL_EXPORTER_OTLP_HEADERS", "k1=v1,k2=v2", 1); setenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS", "k1=v3,k1=v4", 1); - std::unique_ptr exporter(new OtlpHttpLogExporter()); + std::unique_ptr exporter(new OtlpHttpLogRecordExporter()); EXPECT_EQ(GetOptions(exporter).url, url); EXPECT_EQ( GetOptions(exporter).timeout.count(), @@ -631,7 +632,7 @@ TEST_F(OtlpHttpLogExporterTestPeer, ConfigFromLogsEnv) unsetenv("OTEL_EXPORTER_OTLP_LOGS_HEADERS"); } -TEST_F(OtlpHttpLogExporterTestPeer, DefaultEndpoint) +TEST_F(OtlpHttpLogRecordExporterTestPeer, DefaultEndpoint) { EXPECT_EQ("http://localhost:4318/v1/logs", GetOtlpDefaultHttpLogEndpoint()); EXPECT_EQ("http://localhost:4318/v1/traces", GetOtlpDefaultHttpEndpoint()); diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h index 122c9534e7..0621316dcd 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor.h @@ -26,7 +26,7 @@ namespace logs * This is an implementation of the LogRecordProcessor which creates batches of finished logs and * passes the export-friendly log data representations to the configured LogRecordExporter. */ -class BatchLogProcessor : public LogRecordProcessor +class BatchLogRecordProcessor : public LogRecordProcessor { public: /** @@ -40,7 +40,7 @@ class BatchLogProcessor : public LogRecordProcessor * @param max_export_batch_size - The maximum batch size of every export. It must be smaller or * equal to max_queue_size */ - explicit BatchLogProcessor( + explicit BatchLogRecordProcessor( std::unique_ptr &&exporter, const size_t max_queue_size = 2048, const std::chrono::milliseconds scheduled_delay_millis = std::chrono::milliseconds(5000), @@ -53,8 +53,8 @@ class BatchLogProcessor : public LogRecordProcessor * @param exporter - The backend exporter to pass the logs to * @param options - The batch SpanProcessor options. */ - explicit BatchLogProcessor(std::unique_ptr &&exporter, - const BatchLogProcessorOptions &options); + explicit BatchLogRecordProcessor(std::unique_ptr &&exporter, + const BatchLogRecordProcessorOptions &options); /** Makes a new recordable **/ std::unique_ptr MakeRecordable() noexcept override; @@ -87,7 +87,7 @@ class BatchLogProcessor : public LogRecordProcessor /** * Class destructor which invokes the Shutdown() method. */ - ~BatchLogProcessor() override; + ~BatchLogRecordProcessor() override; protected: /** diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h index d66e5471c9..a3ebb0e877 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_factory.h @@ -17,16 +17,16 @@ namespace logs { /** - * Factory class for BatchLogProcessor. + * Factory class for BatchLogRecordProcessor. */ -class BatchLogProcessorFactory +class BatchLogRecordProcessorFactory { public: /** - * Create a BatchLogProcessor. + * Create a BatchLogRecordProcessor. */ std::unique_ptr Create(std::unique_ptr &&exporter, - const BatchLogProcessorOptions &options); + const BatchLogRecordProcessorOptions &options); }; } // namespace logs diff --git a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h index 591e12af72..1449bb48dc 100644 --- a/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h +++ b/sdk/include/opentelemetry/sdk/logs/batch_log_record_processor_options.h @@ -20,7 +20,7 @@ namespace logs /** * Struct to hold batch SpanProcessor options. */ -struct BatchLogProcessorOptions +struct BatchLogRecordProcessorOptions { /** * The maximum buffer/queue size. After the size is reached, spans are diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h index 5c3981a4ce..54a7e7959e 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor.h @@ -25,11 +25,11 @@ namespace logs * Built-in log processors are responsible for batching and conversion of * logs to exportable representation and passing batches to exporters. */ -class MultiLogProcessor : public LogRecordProcessor +class MultiLogRecordProcessor : public LogRecordProcessor { public: - MultiLogProcessor(std::vector> &&processors); - ~MultiLogProcessor() override; + MultiLogRecordProcessor(std::vector> &&processors); + ~MultiLogRecordProcessor() override; void AddProcessor(std::unique_ptr &&processor); diff --git a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h index 3b94f675ac..0e8b9a5878 100644 --- a/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/multi_log_record_processor_factory.h @@ -17,9 +17,9 @@ namespace logs { /** - * Factory class for MultiLogProcessor. + * Factory class for MultiLogRecordProcessor. */ -class MultiLogProcessorFactory +class MultiLogRecordProcessorFactory { public: static std::unique_ptr Create( diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h index 5d4703d7f4..0e4ce3f2ab 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor.h @@ -24,12 +24,12 @@ namespace logs * All calls to the configured LogRecordExporter are synchronized using a * spin-lock on an atomic_flag. */ -class SimpleLogProcessor : public LogRecordProcessor +class SimpleLogRecordProcessor : public LogRecordProcessor { public: - explicit SimpleLogProcessor(std::unique_ptr &&exporter); - ~SimpleLogProcessor() override = default; + explicit SimpleLogRecordProcessor(std::unique_ptr &&exporter); + ~SimpleLogRecordProcessor() override = default; std::unique_ptr MakeRecordable() noexcept override; diff --git a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h index d808a38b98..7ba2c3ac0f 100644 --- a/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h +++ b/sdk/include/opentelemetry/sdk/logs/simple_log_record_processor_factory.h @@ -15,13 +15,13 @@ namespace logs { /** - * Factory class for SimpleLogProcessor. + * Factory class for SimpleLogRecordProcessor. */ -class SimpleLogProcessorFactory +class SimpleLogRecordProcessorFactory { public: /** - * Create a SimpleLogProcessor. + * Create a SimpleLogRecordProcessor. */ static std::unique_ptr Create(std::unique_ptr &&exporter); }; diff --git a/sdk/src/logs/batch_log_record_processor.cc b/sdk/src/logs/batch_log_record_processor.cc index c9d98ee45a..87992e7822 100644 --- a/sdk/src/logs/batch_log_record_processor.cc +++ b/sdk/src/logs/batch_log_record_processor.cc @@ -14,17 +14,18 @@ namespace sdk { namespace logs { -BatchLogProcessor::BatchLogProcessor(std::unique_ptr &&exporter, - const size_t max_queue_size, - const std::chrono::milliseconds scheduled_delay_millis, - const size_t max_export_batch_size) +BatchLogRecordProcessor::BatchLogRecordProcessor( + std::unique_ptr &&exporter, + const size_t max_queue_size, + const std::chrono::milliseconds scheduled_delay_millis, + const size_t max_export_batch_size) : exporter_(std::move(exporter)), max_queue_size_(max_queue_size), scheduled_delay_millis_(scheduled_delay_millis), max_export_batch_size_(max_export_batch_size), buffer_(max_queue_size_), synchronization_data_(std::make_shared()), - worker_thread_(&BatchLogProcessor::DoBackgroundWork, this) + worker_thread_(&BatchLogRecordProcessor::DoBackgroundWork, this) { synchronization_data_->is_force_wakeup_background_worker.store(false); synchronization_data_->is_force_flush_pending.store(false); @@ -32,15 +33,15 @@ BatchLogProcessor::BatchLogProcessor(std::unique_ptr &&export synchronization_data_->is_shutdown.store(false); } -BatchLogProcessor::BatchLogProcessor(std::unique_ptr &&exporter, - const BatchLogProcessorOptions &options) +BatchLogRecordProcessor::BatchLogRecordProcessor(std::unique_ptr &&exporter, + const BatchLogRecordProcessorOptions &options) : exporter_(std::move(exporter)), max_queue_size_(options.max_queue_size), scheduled_delay_millis_(options.schedule_delay_millis), max_export_batch_size_(options.max_export_batch_size), buffer_(options.max_queue_size), synchronization_data_(std::make_shared()), - worker_thread_(&BatchLogProcessor::DoBackgroundWork, this) + worker_thread_(&BatchLogRecordProcessor::DoBackgroundWork, this) { synchronization_data_->is_force_wakeup_background_worker.store(false); synchronization_data_->is_force_flush_pending.store(false); @@ -48,12 +49,12 @@ BatchLogProcessor::BatchLogProcessor(std::unique_ptr &&export synchronization_data_->is_shutdown.store(false); } -std::unique_ptr BatchLogProcessor::MakeRecordable() noexcept +std::unique_ptr BatchLogRecordProcessor::MakeRecordable() noexcept { return exporter_->MakeRecordable(); } -void BatchLogProcessor::OnEmit(std::unique_ptr &&record) noexcept +void BatchLogRecordProcessor::OnEmit(std::unique_ptr &&record) noexcept { if (synchronization_data_->is_shutdown.load() == true) { @@ -76,7 +77,7 @@ void BatchLogProcessor::OnEmit(std::unique_ptr &&record) noexcept } } -bool BatchLogProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept +bool BatchLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept { if (synchronization_data_->is_shutdown.load() == true) { @@ -146,7 +147,7 @@ bool BatchLogProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept return result; } -void BatchLogProcessor::DoBackgroundWork() +void BatchLogRecordProcessor::DoBackgroundWork() { auto timeout = scheduled_delay_millis_; @@ -181,7 +182,7 @@ void BatchLogProcessor::DoBackgroundWork() } } -void BatchLogProcessor::Export() +void BatchLogRecordProcessor::Export() { do { @@ -221,7 +222,7 @@ void BatchLogProcessor::Export() } while (true); } -void BatchLogProcessor::NotifyCompletion( +void BatchLogRecordProcessor::NotifyCompletion( bool notify_force_flush, const std::shared_ptr &synchronization_data) { @@ -237,7 +238,7 @@ void BatchLogProcessor::NotifyCompletion( } } -void BatchLogProcessor::DrainQueue() +void BatchLogRecordProcessor::DrainQueue() { while (true) { @@ -251,7 +252,7 @@ void BatchLogProcessor::DrainQueue() } } -void BatchLogProcessor::GetWaitAdjustedTime( +void BatchLogRecordProcessor::GetWaitAdjustedTime( std::chrono::microseconds &timeout, std::chrono::time_point &start_time) { @@ -271,7 +272,7 @@ void BatchLogProcessor::GetWaitAdjustedTime( } } -bool BatchLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +bool BatchLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { auto start_time = std::chrono::system_clock::now(); @@ -295,7 +296,7 @@ bool BatchLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept return true; } -BatchLogProcessor::~BatchLogProcessor() +BatchLogRecordProcessor::~BatchLogRecordProcessor() { if (synchronization_data_->is_shutdown.load() == false) { diff --git a/sdk/src/logs/batch_log_record_processor_factory.cc b/sdk/src/logs/batch_log_record_processor_factory.cc index 4292419053..67d0a677ab 100644 --- a/sdk/src/logs/batch_log_record_processor_factory.cc +++ b/sdk/src/logs/batch_log_record_processor_factory.cc @@ -12,12 +12,12 @@ namespace sdk namespace logs { -std::unique_ptr BatchLogProcessorFactory::Create( +std::unique_ptr BatchLogRecordProcessorFactory::Create( std::unique_ptr &&exporter, - const BatchLogProcessorOptions &options) + const BatchLogRecordProcessorOptions &options) { std::unique_ptr processor( - new BatchLogProcessor(std::move(exporter), options)); + new BatchLogRecordProcessor(std::move(exporter), options)); return processor; } diff --git a/sdk/src/logs/logger_context.cc b/sdk/src/logs/logger_context.cc index e0c916e4de..3421ad9999 100644 --- a/sdk/src/logs/logger_context.cc +++ b/sdk/src/logs/logger_context.cc @@ -18,12 +18,13 @@ namespace logs LoggerContext::LoggerContext(std::vector> &&processors, opentelemetry::sdk::resource::Resource resource) noexcept : resource_(resource), - processor_(std::unique_ptr(new MultiLogProcessor(std::move(processors)))) + processor_( + std::unique_ptr(new MultiLogRecordProcessor(std::move(processors)))) {} void LoggerContext::AddProcessor(std::unique_ptr processor) noexcept { - auto multi_processor = static_cast(processor_.get()); + auto multi_processor = static_cast(processor_.get()); multi_processor->AddProcessor(std::move(processor)); } diff --git a/sdk/src/logs/multi_log_record_processor.cc b/sdk/src/logs/multi_log_record_processor.cc index 2e374b83e5..a6f20be7eb 100644 --- a/sdk/src/logs/multi_log_record_processor.cc +++ b/sdk/src/logs/multi_log_record_processor.cc @@ -15,20 +15,21 @@ namespace sdk namespace logs { -MultiLogProcessor::MultiLogProcessor(std::vector> &&processors) +MultiLogRecordProcessor::MultiLogRecordProcessor( + std::vector> &&processors) { for (auto &processor : processors) { AddProcessor(std::move(processor)); } } -MultiLogProcessor::~MultiLogProcessor() +MultiLogRecordProcessor::~MultiLogRecordProcessor() { ForceFlush(); Shutdown(); } -void MultiLogProcessor::AddProcessor(std::unique_ptr &&processor) +void MultiLogRecordProcessor::AddProcessor(std::unique_ptr &&processor) { // Add preocessor to end of the list. if (processor) @@ -37,7 +38,7 @@ void MultiLogProcessor::AddProcessor(std::unique_ptr &&proce } } -std::unique_ptr MultiLogProcessor::MakeRecordable() noexcept +std::unique_ptr MultiLogRecordProcessor::MakeRecordable() noexcept { auto recordable = std::unique_ptr(new MultiRecordable); auto multi_recordable = static_cast(recordable.get()); @@ -48,7 +49,7 @@ std::unique_ptr MultiLogProcessor::MakeRecordable() noexcept return recordable; } -void MultiLogProcessor::OnEmit(std::unique_ptr &&record) noexcept +void MultiLogRecordProcessor::OnEmit(std::unique_ptr &&record) noexcept { if (!record) { @@ -66,7 +67,7 @@ void MultiLogProcessor::OnEmit(std::unique_ptr &&record) noexcept } } -bool MultiLogProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept +bool MultiLogRecordProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept { // Convert to nanos to prevent overflow std::chrono::nanoseconds timeout_ns = std::chrono::nanoseconds::max(); @@ -106,7 +107,7 @@ bool MultiLogProcessor::ForceFlush(std::chrono::microseconds timeout) noexcept return result; } -bool MultiLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +bool MultiLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { // Converto nanos to prevent overflow std::chrono::nanoseconds timeout_ns = std::chrono::nanoseconds::max(); diff --git a/sdk/src/logs/multi_log_record_processor_factory.cc b/sdk/src/logs/multi_log_record_processor_factory.cc index 77e2d1b089..3e0de46c32 100644 --- a/sdk/src/logs/multi_log_record_processor_factory.cc +++ b/sdk/src/logs/multi_log_record_processor_factory.cc @@ -16,10 +16,10 @@ namespace sdk namespace logs { -std::unique_ptr MultiLogProcessorFactory::Create( +std::unique_ptr MultiLogRecordProcessorFactory::Create( std::vector> &&processors) { - std::unique_ptr processor(new MultiLogProcessor(std::move(processors))); + std::unique_ptr processor(new MultiLogRecordProcessor(std::move(processors))); return processor; } diff --git a/sdk/src/logs/simple_log_record_processor.cc b/sdk/src/logs/simple_log_record_processor.cc index e970ceb5ba..ef923bc590 100644 --- a/sdk/src/logs/simple_log_record_processor.cc +++ b/sdk/src/logs/simple_log_record_processor.cc @@ -16,11 +16,11 @@ namespace logs * Initialize a simple log processor. * @param exporter the configured exporter where log records are sent */ -SimpleLogProcessor::SimpleLogProcessor(std::unique_ptr &&exporter) +SimpleLogRecordProcessor::SimpleLogRecordProcessor(std::unique_ptr &&exporter) : exporter_(std::move(exporter)), is_shutdown_(false) {} -std::unique_ptr SimpleLogProcessor::MakeRecordable() noexcept +std::unique_ptr SimpleLogRecordProcessor::MakeRecordable() noexcept { return exporter_->MakeRecordable(); } @@ -29,7 +29,7 @@ std::unique_ptr SimpleLogProcessor::MakeRecordable() noexcept * Batches the log record it receives in a batch of 1 and immediately sends it * to the configured exporter */ -void SimpleLogProcessor::OnEmit(std::unique_ptr &&record) noexcept +void SimpleLogRecordProcessor::OnEmit(std::unique_ptr &&record) noexcept { nostd::span> batch(&record, 1); // Get lock to ensure Export() is never called concurrently @@ -43,12 +43,12 @@ void SimpleLogProcessor::OnEmit(std::unique_ptr &&record) noexcept /** * The simple processor does not have any log records to flush so this method is not used */ -bool SimpleLogProcessor::ForceFlush(std::chrono::microseconds /* timeout */) noexcept +bool SimpleLogRecordProcessor::ForceFlush(std::chrono::microseconds /* timeout */) noexcept { return true; } -bool SimpleLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept +bool SimpleLogRecordProcessor::Shutdown(std::chrono::microseconds timeout) noexcept { // Should only shutdown exporter ONCE. if (!is_shutdown_.exchange(true, std::memory_order_acq_rel) && exporter_ != nullptr) @@ -59,7 +59,7 @@ bool SimpleLogProcessor::Shutdown(std::chrono::microseconds timeout) noexcept return true; } -bool SimpleLogProcessor::IsShutdown() const noexcept +bool SimpleLogRecordProcessor::IsShutdown() const noexcept { return is_shutdown_.load(std::memory_order_acquire); } diff --git a/sdk/src/logs/simple_log_record_processor_factory.cc b/sdk/src/logs/simple_log_record_processor_factory.cc index 9320ad7ff4..213f61e16c 100644 --- a/sdk/src/logs/simple_log_record_processor_factory.cc +++ b/sdk/src/logs/simple_log_record_processor_factory.cc @@ -12,10 +12,10 @@ namespace sdk namespace logs { -std::unique_ptr SimpleLogProcessorFactory::Create( +std::unique_ptr SimpleLogRecordProcessorFactory::Create( std::unique_ptr &&exporter) { - std::unique_ptr processor(new SimpleLogProcessor(std::move(exporter))); + std::unique_ptr processor(new SimpleLogRecordProcessor(std::move(exporter))); return processor; } diff --git a/sdk/test/logs/batch_log_record_processor_test.cc b/sdk/test/logs/batch_log_record_processor_test.cc index e8fc17dd26..bbf1fc3016 100644 --- a/sdk/test/logs/batch_log_record_processor_test.cc +++ b/sdk/test/logs/batch_log_record_processor_test.cc @@ -71,9 +71,10 @@ class MockLogExporter final : public LogRecordExporter }; /** - * A fixture class for testing the BatchLogProcessor class that uses the TestExporter defined above. + * A fixture class for testing the BatchLogRecordProcessor class that uses the TestExporter defined + * above. */ -class BatchLogProcessorTest : public testing::Test // ::testing::Test +class BatchLogRecordProcessorTest : public testing::Test // ::testing::Test { public: // returns a batch log processor that received a batch of log records, a shared pointer to a @@ -88,14 +89,14 @@ class BatchLogProcessorTest : public testing::Test // ::testing::Test const size_t max_queue_size = 2048, const size_t max_export_batch_size = 512) { - return std::shared_ptr( - new BatchLogProcessor(std::unique_ptr(new MockLogExporter( - logs_received, is_shutdown, is_export_completed, export_delay)), - max_queue_size, scheduled_delay_millis, max_export_batch_size)); + return std::shared_ptr(new BatchLogRecordProcessor( + std::unique_ptr( + new MockLogExporter(logs_received, is_shutdown, is_export_completed, export_delay)), + max_queue_size, scheduled_delay_millis, max_export_batch_size)); } }; -TEST_F(BatchLogProcessorTest, TestShutdown) +TEST_F(BatchLogRecordProcessorTest, TestShutdown) { // initialize a batch log processor with the test exporter std::shared_ptr>> logs_received( @@ -133,7 +134,7 @@ TEST_F(BatchLogProcessorTest, TestShutdown) EXPECT_TRUE(is_shutdown->load()); } -TEST_F(BatchLogProcessorTest, TestForceFlush) +TEST_F(BatchLogRecordProcessorTest, TestForceFlush) { std::shared_ptr> is_shutdown(new std::atomic(false)); std::shared_ptr>> logs_received( @@ -174,7 +175,7 @@ TEST_F(BatchLogProcessorTest, TestForceFlush) } } -TEST_F(BatchLogProcessorTest, TestManyLogsLoss) +TEST_F(BatchLogRecordProcessorTest, TestManyLogsLoss) { /* Test that when exporting more than max_queue_size logs, some are most likely lost*/ @@ -200,7 +201,7 @@ TEST_F(BatchLogProcessorTest, TestManyLogsLoss) EXPECT_GE(max_queue_size, logs_received->size()); } -TEST_F(BatchLogProcessorTest, TestManyLogsLossLess) +TEST_F(BatchLogRecordProcessorTest, TestManyLogsLossLess) { /* Test that no logs are lost when sending max_queue_size logs */ @@ -227,7 +228,7 @@ TEST_F(BatchLogProcessorTest, TestManyLogsLossLess) } } -TEST_F(BatchLogProcessorTest, TestScheduledDelayMillis) +TEST_F(BatchLogRecordProcessorTest, TestScheduledDelayMillis) { /* Test that max_export_batch_size logs are exported every scheduled_delay_millis seconds */ diff --git a/sdk/test/logs/logger_provider_sdk_test.cc b/sdk/test/logs/logger_provider_sdk_test.cc index 022fffe72d..4f517f8fd4 100644 --- a/sdk/test/logs/logger_provider_sdk_test.cc +++ b/sdk/test/logs/logger_provider_sdk_test.cc @@ -101,8 +101,8 @@ TEST(LoggerProviderSDK, GetResource) TEST(LoggerProviderSDK, Shutdown) { - std::unique_ptr processor(new SimpleLogProcessor(nullptr)); - SimpleLogProcessor *processor_ptr = processor.get(); + std::unique_ptr processor(new SimpleLogRecordProcessor(nullptr)); + SimpleLogRecordProcessor *processor_ptr = processor.get(); std::vector> processors; processors.push_back(std::move(processor)); @@ -117,7 +117,7 @@ TEST(LoggerProviderSDK, Shutdown) TEST(LoggerProviderSDK, ForceFlush) { - std::unique_ptr processor(new SimpleLogProcessor(nullptr)); + std::unique_ptr processor(new SimpleLogRecordProcessor(nullptr)); std::vector> processors; processors.push_back(std::move(processor)); diff --git a/sdk/test/logs/simple_log_record_processor_test.cc b/sdk/test/logs/simple_log_record_processor_test.cc index 99351881d9..47b16eab7e 100644 --- a/sdk/test/logs/simple_log_record_processor_test.cc +++ b/sdk/test/logs/simple_log_record_processor_test.cc @@ -68,7 +68,7 @@ class TestExporter final : public LogRecordExporter // Tests whether the simple processor successfully creates a batch of size 1 // and whether the contents of the record is sent to the exporter correctly -TEST(SimpleLogProcessorTest, SendReceivedLogsToExporter) +TEST(SimpleLogRecordProcessorTest, SendReceivedLogsToExporter) { // Create a simple processor with a TestExporter attached std::shared_ptr>> logs_received( @@ -78,7 +78,7 @@ TEST(SimpleLogProcessorTest, SendReceivedLogsToExporter) std::unique_ptr exporter( new TestExporter(nullptr, logs_received, &batch_size_received)); - SimpleLogProcessor processor(std::move(exporter)); + SimpleLogRecordProcessor processor(std::move(exporter)); // Send some log records to the processor (which should then send to the TestExporter) const int num_logs = 5; @@ -101,7 +101,7 @@ TEST(SimpleLogProcessorTest, SendReceivedLogsToExporter) } // Tests behavior when calling the processor's ShutDown() multiple times -TEST(SimpleLogProcessorTest, ShutdownCalledOnce) +TEST(SimpleLogRecordProcessorTest, ShutdownCalledOnce) { // Create a TestExporter int num_shutdowns = 0; @@ -109,7 +109,7 @@ TEST(SimpleLogProcessorTest, ShutdownCalledOnce) std::unique_ptr exporter(new TestExporter(&num_shutdowns, nullptr, nullptr)); // Create a processor with the previous test exporter - SimpleLogProcessor processor(std::move(exporter)); + SimpleLogRecordProcessor processor(std::move(exporter)); // The first time processor shutdown is called EXPECT_EQ(0, num_shutdowns); @@ -142,10 +142,10 @@ class FailShutDownExporter final : public LogRecordExporter }; // Tests for when when processor should fail to shutdown -TEST(SimpleLogProcessorTest, ShutDownFail) +TEST(SimpleLogRecordProcessorTest, ShutDownFail) { std::unique_ptr exporter(new FailShutDownExporter()); - SimpleLogProcessor processor(std::move(exporter)); + SimpleLogRecordProcessor processor(std::move(exporter)); // Expect failure result when exporter fails to shutdown EXPECT_EQ(false, processor.Shutdown());