Skip to content

Commit

Permalink
Add Resource test to OTLP recordable test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomsonTan committed May 16, 2021
1 parent b99dbbc commit bb95dd1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions exporters/otlp/test/recordable_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,28 @@ TEST(Recordable, AddLink)
}
}

TEST(Recordable, SetResource)
{
Recordable rec;
const std::string service_name_key = "service.name";
std::string service_name = "test-otlp";
auto resource =
opentelemetry::sdk::resource::Resource::Create({{service_name_key, service_name}});
rec.SetResource(resource);

auto proto_resource = rec.ProtoResource();
bool found_service_name = false;
for (size_t i = 0; i < proto_resource.attributes_size(); i++)
{
auto attr = proto_resource.attributes(static_cast<int>(i));
if (attr.key() == service_name_key && attr.value().string_value() == service_name)
{
found_service_name = true;
}
}
EXPECT_TRUE(found_service_name);
}

// Test non-int single types. Int single types are tested using templates (see IntAttributeTest)
TEST(Recordable, SetSingleAtrribute)
{
Expand Down

0 comments on commit bb95dd1

Please sign in to comment.