From cb937db5f8db0977068c3e8681d09f1228ed49b9 Mon Sep 17 00:00:00 2001 From: kirby-mimic <135686938+kirby-mimic@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:27:07 -0800 Subject: [PATCH 1/5] Change content_type default from HttpRequestContentType::kJson to HttpRequestContentType::kBinary https://github.com/open-telemetry/opentelemetry-proto/blob/main/docs/specification.md --- exporters/otlp/src/otlp_http_exporter_options.cc | 2 +- exporters/otlp/src/otlp_http_log_record_exporter_options.cc | 2 +- exporters/otlp/src/otlp_http_metric_exporter_options.cc | 2 +- exporters/otlp/test/otlp_http_exporter_test.cc | 4 ++-- exporters/otlp/test/otlp_http_log_record_exporter_test.cc | 4 ++-- exporters/otlp/test/otlp_http_metric_exporter_test.cc | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/exporters/otlp/src/otlp_http_exporter_options.cc b/exporters/otlp/src/otlp_http_exporter_options.cc index 3b8c6ad5b8..e605d0b260 100644 --- a/exporters/otlp/src/otlp_http_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_exporter_options.cc @@ -17,7 +17,7 @@ namespace otlp OtlpHttpExporterOptions::OtlpHttpExporterOptions() { url = GetOtlpDefaultHttpTracesEndpoint(); - content_type = HttpRequestContentType::kJson; + content_type = HttpRequestContentType::kBinary; json_bytes_mapping = JsonBytesMappingKind::kHexId; use_json_name = false; console_debug = false; diff --git a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc index 2f58bce768..5042701377 100644 --- a/exporters/otlp/src/otlp_http_log_record_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_log_record_exporter_options.cc @@ -17,7 +17,7 @@ namespace otlp OtlpHttpLogRecordExporterOptions::OtlpHttpLogRecordExporterOptions() { url = GetOtlpDefaultHttpLogsEndpoint(); - content_type = HttpRequestContentType::kJson; + content_type = HttpRequestContentType::kBinary; json_bytes_mapping = JsonBytesMappingKind::kHexId; use_json_name = false; console_debug = false; diff --git a/exporters/otlp/src/otlp_http_metric_exporter_options.cc b/exporters/otlp/src/otlp_http_metric_exporter_options.cc index ffcd502bd4..27dcfd7ccb 100644 --- a/exporters/otlp/src/otlp_http_metric_exporter_options.cc +++ b/exporters/otlp/src/otlp_http_metric_exporter_options.cc @@ -17,7 +17,7 @@ namespace otlp OtlpHttpMetricExporterOptions::OtlpHttpMetricExporterOptions() { url = GetOtlpDefaultMetricsEndpoint(); - content_type = HttpRequestContentType::kJson; + content_type = HttpRequestContentType::kBinary; json_bytes_mapping = JsonBytesMappingKind::kHexId; use_json_name = false; console_debug = false; diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 63f919c6cc..dd8bc588af 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -106,7 +106,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test void ExportJsonIntegrationTest() { auto mock_otlp_client = - OtlpHttpExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson); + OtlpHttpExporterTestPeer::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}); @@ -197,7 +197,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test void ExportJsonIntegrationTestAsync() { auto mock_otlp_client = - OtlpHttpExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson, true); + OtlpHttpExporterTestPeer::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}); 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 611bebb541..3239dc58ba 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -107,7 +107,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test void ExportJsonIntegrationTest() { auto mock_otlp_client = - OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson); + 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}); @@ -221,7 +221,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test void ExportJsonIntegrationTestAsync() { auto mock_otlp_client = OtlpHttpLogRecordExporterTestPeer::GetMockOtlpHttpClient( - HttpRequestContentType::kJson, true); + 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}); diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index def56682d3..0279cc40e0 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -117,7 +117,7 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test ) { auto mock_otlp_client = - OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson + OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary #ifdef ENABLE_ASYNC_EXPORT , async_mode @@ -293,7 +293,7 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test ) { auto mock_otlp_client = - OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson + OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary #ifdef ENABLE_ASYNC_EXPORT , async_mode @@ -483,7 +483,7 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test ) { auto mock_otlp_client = - OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kJson + OtlpHttpMetricExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary #ifdef ENABLE_ASYNC_EXPORT , async_mode From ba5f22ee5377af58e0904c976d83a8d760d39866 Mon Sep 17 00:00:00 2001 From: kirby-mimic <135686938+kirby-mimic@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:53:45 -0800 Subject: [PATCH 2/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8379620fb..33c0050e52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,7 @@ Breaking changes: * CMake options `WITH_OTLP_HTTP_SSL_PREVIEW` and `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` are removed. Building opentelemetry-cpp without SSL support is no longer possible. - +* [#240] Change default OTLP Http Exporter content type from kJson to kBInary ## [1.13.0] 2023-12-06 * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead From 97c6120da0a2697a03f7c432e86d6d9c4cd80b4b Mon Sep 17 00:00:00 2001 From: kirby-mimic <135686938+kirby-mimic@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:55:11 -0800 Subject: [PATCH 3/5] Change the name of the test from ExportJsonIntegratorTest to ExportBinaryIntegrationTest --- exporters/otlp/test/otlp_http_exporter_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index dd8bc588af..73cc75ff34 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -103,7 +103,7 @@ class OtlpHttpExporterTestPeer : public ::testing::Test http_client}; } - void ExportJsonIntegrationTest() + void ExportBinaryIntegrationTest() { auto mock_otlp_client = OtlpHttpExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary); From 3d4eadd64dd535c2a9452bcbb1f5c65ed84b1ffa Mon Sep 17 00:00:00 2001 From: kirby-mimic <135686938+kirby-mimic@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:50:22 -0800 Subject: [PATCH 4/5] Fix CHANGELONG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33c0050e52..4e6f37e89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,7 +33,9 @@ Breaking changes: * CMake options `WITH_OTLP_HTTP_SSL_PREVIEW` and `WITH_OTLP_HTTP_SSL_TLS_PREVIEW` are removed. Building opentelemetry-cpp without SSL support is no longer possible. -* [#240] Change default OTLP Http Exporter content type from kJson to kBInary +* [#2480] Change default OTLP Http Exporter content type from kJson to kBInary + See The default is http/protobuf, which means binary, [HERE](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md#specify-protocol + ## [1.13.0] 2023-12-06 * [BUILD] Remove WITH_REMOVE_METER_PREVIEW, use WITH_ABI_VERSION_2 instead From d7168ce94f7a4355e43700a9c71948fa1223dc0c Mon Sep 17 00:00:00 2001 From: kirby-mimic <135686938+kirby-mimic@users.noreply.github.com> Date: Tue, 9 Jan 2024 14:39:54 -0800 Subject: [PATCH 5/5] Revert unnecessary function change. --- exporters/otlp/test/otlp_http_exporter_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 73cc75ff34..dd35122715 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -103,10 +103,10 @@ class OtlpHttpExporterTestPeer : public ::testing::Test http_client}; } - void ExportBinaryIntegrationTest() + void ExportJsonIntegrationTest() { auto mock_otlp_client = - OtlpHttpExporterTestPeer::GetMockOtlpHttpClient(HttpRequestContentType::kBinary); + OtlpHttpExporterTestPeer::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});