Skip to content

Commit

Permalink
Use std::make_unique
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrobbel committed Sep 27, 2023
1 parent b125116 commit ed3e87e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions exporters/otlp/test/otlp_recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,20 @@ TEST(OtlpRecordable, SetArrayAttribute)
// Test otlp resource populate request util
TEST(OtlpRecordable, PopulateRequest)
{
auto rec1 = std::unique_ptr<sdk::trace::Recordable>(new OtlpRecordable);
const std::string service_name_key = "service.name";
std::string service_name1 = "one";
auto resource1 = resource::Resource::Create({{service_name_key, service_name1}});
std::unique_ptr<sdk::trace::Recordable> rec1 = std::make_unique<OtlpRecordable>();
auto resource1 = resource::Resource::Create({{"service.name", "one"}});
rec1->SetResource(resource1);
auto inst_lib1 = trace_sdk::InstrumentationScope::Create("one", "1");
rec1->SetInstrumentationScope(*inst_lib1);

auto rec2 = std::unique_ptr<sdk::trace::Recordable>(new OtlpRecordable);
std::string service_name2 = "two";
auto resource2 = resource::Resource::Create({{service_name_key, service_name2}});
std::unique_ptr<sdk::trace::Recordable> rec2 = std::make_unique<OtlpRecordable>();
auto resource2 = resource::Resource::Create({{"service.name", "two"}});
rec2->SetResource(resource2);
auto inst_lib2 = trace_sdk::InstrumentationScope::Create("two", "2");
rec2->SetInstrumentationScope(*inst_lib2);

// This has the same resource as rec2, but a different scope
auto rec3 = std::unique_ptr<sdk::trace::Recordable>(new OtlpRecordable);
std::unique_ptr<sdk::trace::Recordable> rec3 = std::make_unique<OtlpRecordable>();
rec3->SetResource(resource2);
auto inst_lib3 = trace_sdk::InstrumentationScope::Create("three", "3");
rec3->SetInstrumentationScope(*inst_lib3);
Expand Down

0 comments on commit ed3e87e

Please sign in to comment.