diff --git a/exporters/otlp/src/otlp_http_client.cc b/exporters/otlp/src/otlp_http_client.cc index 5cbc65952c2..efb60ff982d 100644 --- a/exporters/otlp/src/otlp_http_client.cc +++ b/exporters/otlp/src/otlp_http_client.cc @@ -451,7 +451,7 @@ static void ConvertGenericMessageToJson(nlohmann::json &value, { const google::protobuf::FieldDescriptor *field_descriptor = fields_with_data[i]; nlohmann::json &child_value = options.use_json_name ? value[field_descriptor->json_name()] - : value[field_descriptor->name()]; + : value[field_descriptor->camelcase_name()]; if (field_descriptor->is_repeated()) { ConvertListFieldToJson(child_value, message, field_descriptor, options); diff --git a/exporters/otlp/test/otlp_http_exporter_test.cc b/exporters/otlp/test/otlp_http_exporter_test.cc index 007cd562496..9c5bfe1766c 100644 --- a/exporters/otlp/test/otlp_http_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_exporter_test.cc @@ -165,10 +165,10 @@ class OtlpHttpExporterTestPeer : public ::testing::Test std::shared_ptr callback) { auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resource_spans"].begin(); - auto scope_span = *resource_span["scope_spans"].begin(); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["trace_id"].get(); + auto received_trace_id = span["traceId"].get(); EXPECT_EQ(received_trace_id, report_trace_id); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); @@ -256,10 +256,10 @@ class OtlpHttpExporterTestPeer : public ::testing::Test std::shared_ptr callback) { auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_span = *check_json["resource_spans"].begin(); - auto scope_span = *resource_span["scope_spans"].begin(); + auto resource_span = *check_json["resourceSpans"].begin(); + auto scope_span = *resource_span["scopeSpans"].begin(); auto span = *scope_span["spans"].begin(); - auto received_trace_id = span["trace_id"].get(); + auto received_trace_id = span["traceId"].get(); EXPECT_EQ(received_trace_id, report_trace_id); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); 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 aa55e7fc7c3..aba1c9c503e 100644 --- a/exporters/otlp/test/otlp_http_log_record_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_log_record_exporter_test.cc @@ -160,15 +160,15 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test std::shared_ptr callback) { auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resource_logs"].begin(); - auto scope_logs = *resource_logs["scope_logs"].begin(); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); auto scope = scope_logs["scope"]; - auto log = *scope_logs["log_records"].begin(); - auto received_trace_id = log["trace_id"].get(); - auto received_span_id = log["span_id"].get(); + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); EXPECT_EQ(received_trace_id, report_trace_id); EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["string_value"].get()); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); EXPECT_LE(15, log["attributes"].size()); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); @@ -188,7 +188,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test if ("scope_key1" == attribute["key"]) { check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["string_value"].get()); + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); } } ASSERT_TRUE(check_scope_attribute); @@ -277,21 +277,21 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test std::shared_ptr callback) { auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_logs = *check_json["resource_logs"].begin(); - auto scope_logs = *resource_logs["scope_logs"].begin(); - auto schema_url = scope_logs["schema_url"].get(); + auto resource_logs = *check_json["resourceLogs"].begin(); + auto scope_logs = *resource_logs["scopeLogs"].begin(); + auto schema_url = scope_logs["schemaUrl"].get(); auto scope = scope_logs["scope"]; auto scope_name = scope["name"]; auto scope_version = scope["version"]; - auto log = *scope_logs["log_records"].begin(); - auto received_trace_id = log["trace_id"].get(); - auto received_span_id = log["span_id"].get(); + auto log = *scope_logs["logRecords"].begin(); + auto received_trace_id = log["traceId"].get(); + auto received_span_id = log["spanId"].get(); EXPECT_EQ(schema_url, "https://opentelemetry.io/schemas/1.2.0"); EXPECT_EQ(scope_name, "opentelelemtry_library"); EXPECT_EQ(scope_version, "1.2.0"); EXPECT_EQ(received_trace_id, report_trace_id); EXPECT_EQ(received_span_id, report_span_id); - EXPECT_EQ("Log message", log["body"]["string_value"].get()); + EXPECT_EQ("Log message", log["body"]["stringValue"].get()); EXPECT_LE(15, log["attributes"].size()); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); @@ -311,7 +311,7 @@ class OtlpHttpLogRecordExporterTestPeer : public ::testing::Test if ("scope_key1" == attribute["key"]) { check_scope_attribute = true; - EXPECT_EQ("scope_value", attribute["value"]["string_value"].get()); + EXPECT_EQ("scope_value", attribute["value"]["stringValue"].get()); } } ASSERT_TRUE(check_scope_attribute); diff --git a/exporters/otlp/test/otlp_http_metric_exporter_test.cc b/exporters/otlp/test/otlp_http_metric_exporter_test.cc index 27f46141570..c47c86e110a 100644 --- a/exporters/otlp/test/otlp_http_metric_exporter_test.cc +++ b/exporters/otlp/test/otlp_http_metric_exporter_test.cc @@ -160,8 +160,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_metrics = *check_json["resource_metrics"].begin(); - auto scope_metrics = *resource_metrics["scope_metrics"].begin(); + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); auto scope = scope_metrics["scope"]; EXPECT_EQ("library_name", scope["name"].get()); EXPECT_EQ("1.5.0", scope["version"].get()); @@ -171,9 +171,9 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_EQ("metrics_description", metric["description"].get()); EXPECT_EQ("metrics_unit", metric["unit"].get()); - auto data_points = metric["sum"]["data_points"]; - EXPECT_EQ(10.0, data_points[0]["as_double"].get()); - EXPECT_EQ(20.0, data_points[1]["as_double"].get()); + auto data_points = metric["sum"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20.0, data_points[1]["asDouble"].get()); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); @@ -341,8 +341,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_metrics = *check_json["resource_metrics"].begin(); - auto scope_metrics = *resource_metrics["scope_metrics"].begin(); + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); auto scope = scope_metrics["scope"]; EXPECT_EQ("library_name", scope["name"].get()); EXPECT_EQ("1.5.0", scope["version"].get()); @@ -352,9 +352,9 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_EQ("metrics_description", metric["description"].get()); EXPECT_EQ("metrics_unit", metric["unit"].get()); - auto data_points = metric["gauge"]["data_points"]; - EXPECT_EQ(10.0, data_points[0]["as_double"].get()); - EXPECT_EQ(20l, JsonToInteger(data_points[1]["as_int"])); + auto data_points = metric["gauge"]["dataPoints"]; + EXPECT_EQ(10.0, data_points[0]["asDouble"].get()); + EXPECT_EQ(20l, JsonToInteger(data_points[1]["asInt"])); auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key"); ASSERT_TRUE(custom_header != mock_session->GetRequest()->headers_.end()); @@ -536,8 +536,8 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test auto check_json = nlohmann::json::parse(mock_session->GetRequest()->body_, nullptr, false); - auto resource_metrics = *check_json["resource_metrics"].begin(); - auto scope_metrics = *resource_metrics["scope_metrics"].begin(); + auto resource_metrics = *check_json["resourceMetrics"].begin(); + auto scope_metrics = *resource_metrics["scopeMetrics"].begin(); auto scope = scope_metrics["scope"]; EXPECT_EQ("library_name", scope["name"].get()); EXPECT_EQ("1.5.0", scope["version"].get()); @@ -547,43 +547,43 @@ class OtlpHttpMetricExporterTestPeer : public ::testing::Test EXPECT_EQ("metrics_description", metric["description"].get()); EXPECT_EQ("metrics_unit", metric["unit"].get()); - auto data_points = metric["histogram"]["data_points"]; + auto data_points = metric["histogram"]["dataPoints"]; EXPECT_EQ(3, JsonToInteger(data_points[0]["count"])); EXPECT_EQ(900.5, data_points[0]["sum"].get()); EXPECT_EQ(1.8, data_points[0]["min"].get()); EXPECT_EQ(19, data_points[0]["max"].get()); - EXPECT_EQ(4, data_points[0]["bucket_counts"].size()); - if (4 == data_points[0]["bucket_counts"].size()) + EXPECT_EQ(4, data_points[0]["bucketCounts"].size()); + if (4 == data_points[0]["bucketCounts"].size()) { - EXPECT_EQ(200, JsonToInteger(data_points[0]["bucket_counts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[0]["bucket_counts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[0]["bucket_counts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[0]["bucket_counts"][3])); + EXPECT_EQ(200, JsonToInteger(data_points[0]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[0]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[0]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[0]["bucketCounts"][3])); } - EXPECT_EQ(3, data_points[0]["explicit_bounds"].size()); - if (3 == data_points[0]["explicit_bounds"].size()) + EXPECT_EQ(3, data_points[0]["explicitBounds"].size()); + if (3 == data_points[0]["explicitBounds"].size()) { - EXPECT_EQ(10.1, data_points[0]["explicit_bounds"][0].get()); - EXPECT_EQ(20.2, data_points[0]["explicit_bounds"][1].get()); - EXPECT_EQ(30.2, data_points[0]["explicit_bounds"][2].get()); + EXPECT_EQ(10.1, data_points[0]["explicitBounds"][0].get()); + EXPECT_EQ(20.2, data_points[0]["explicitBounds"][1].get()); + EXPECT_EQ(30.2, data_points[0]["explicitBounds"][2].get()); } EXPECT_EQ(3, JsonToInteger(data_points[1]["count"])); EXPECT_EQ(900.0, data_points[1]["sum"].get()); - EXPECT_EQ(4, data_points[1]["bucket_counts"].size()); - if (4 == data_points[1]["bucket_counts"].size()) + EXPECT_EQ(4, data_points[1]["bucketCounts"].size()); + if (4 == data_points[1]["bucketCounts"].size()) { - EXPECT_EQ(200, JsonToInteger(data_points[1]["bucket_counts"][0])); - EXPECT_EQ(300, JsonToInteger(data_points[1]["bucket_counts"][1])); - EXPECT_EQ(400, JsonToInteger(data_points[1]["bucket_counts"][2])); - EXPECT_EQ(500, JsonToInteger(data_points[1]["bucket_counts"][3])); + EXPECT_EQ(200, JsonToInteger(data_points[1]["bucketCounts"][0])); + EXPECT_EQ(300, JsonToInteger(data_points[1]["bucketCounts"][1])); + EXPECT_EQ(400, JsonToInteger(data_points[1]["bucketCounts"][2])); + EXPECT_EQ(500, JsonToInteger(data_points[1]["bucketCounts"][3])); } - EXPECT_EQ(3, data_points[1]["explicit_bounds"].size()); - if (3 == data_points[1]["explicit_bounds"].size()) + EXPECT_EQ(3, data_points[1]["explicitBounds"].size()); + if (3 == data_points[1]["explicitBounds"].size()) { - EXPECT_EQ(10.0, data_points[1]["explicit_bounds"][0].get()); - EXPECT_EQ(20.0, data_points[1]["explicit_bounds"][1].get()); - EXPECT_EQ(30.0, data_points[1]["explicit_bounds"][2].get()); + EXPECT_EQ(10.0, data_points[1]["explicitBounds"][0].get()); + EXPECT_EQ(20.0, data_points[1]["explicitBounds"][1].get()); + EXPECT_EQ(30.0, data_points[1]["explicitBounds"][2].get()); } auto custom_header = mock_session->GetRequest()->headers_.find("Custom-Header-Key");