Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] Fix sync problems in OTLP File exporter tests. #3031

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion exporters/otlp/test/otlp_file_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ class OtlpFileExporterTestPeer : public ::testing::Test

provider->ForceFlush();

output.flush();
output.sync();
auto check_json_text = output.str();
if (!check_json_text.empty())
{
auto check_json = nlohmann::json::parse(output.str(), nullptr, false);
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);
auto resource_span = *check_json["resourceSpans"].begin();
auto scope_span = *resource_span["scopeSpans"].begin();
auto span = *scope_span["spans"].begin();
Expand Down
6 changes: 5 additions & 1 deletion exporters/otlp/test/otlp_file_log_record_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ class OtlpFileLogRecordExporterTestPeer : public ::testing::Test

provider->ForceFlush();

output.flush();
output.sync();
auto check_json_text = output.str();
if (!check_json_text.empty())
{
auto check_json = nlohmann::json::parse(output.str(), nullptr, false);
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);
auto resource_logs = *check_json["resourceLogs"].begin();
auto scope_logs = *resource_logs["scopeLogs"].begin();
auto scope = scope_logs["scope"];
Expand Down
18 changes: 15 additions & 3 deletions exporters/otlp/test/otlp_file_metric_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test

exporter->ForceFlush();

output.flush();
output.sync();
auto check_json_text = output.str();
if (!check_json_text.empty())
{
auto check_json = nlohmann::json::parse(output.str(), nullptr, false);
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);

auto resource_metrics = *check_json["resourceMetrics"].begin();
auto scope_metrics = *resource_metrics["scopeMetrics"].begin();
Expand Down Expand Up @@ -167,8 +171,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test

exporter->ForceFlush();

output.flush();
output.sync();
auto check_json_text = output.str();
if (!check_json_text.empty())
{
auto check_json = nlohmann::json::parse(output.str(), nullptr, false);
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);

auto resource_metrics = *check_json["resourceMetrics"].begin();
auto scope_metrics = *resource_metrics["scopeMetrics"].begin();
Expand Down Expand Up @@ -233,8 +241,12 @@ class OtlpFileMetricExporterTestPeer : public ::testing::Test

exporter->ForceFlush();

output.flush();
output.sync();
auto check_json_text = output.str();
if (!check_json_text.empty())
{
auto check_json = nlohmann::json::parse(output.str(), nullptr, false);
auto check_json = nlohmann::json::parse(check_json_text, nullptr, false);

auto resource_metrics = *check_json["resourceMetrics"].begin();
auto scope_metrics = *resource_metrics["scopeMetrics"].begin();
Expand Down
Loading