pdns::trace::KeyValue{
"service.name", pdns::trace::AnyValue{"dnsdist"}},
}},
- .scope_spans = std::vector<pdns::trace::ScopeSpans>{{}}}}};
-
- otTrace.resource_spans.at(0).resource.attributes.insert(
- otTrace.resource_spans.at(0).resource.attributes.end(),
- d_attributes.begin(),
- d_attributes.end());
+ .scope_spans = std::vector<pdns::trace::ScopeSpans>{{.scope = {
+ .attributes = {d_attributes.begin(), d_attributes.end()},
+ },
+ .spans = {}}}}}};
{
auto lockedPre = d_preActivationSpans.read_only_lock();
BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.size(), 1);
BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.at(0).key, "service.name");
+ BOOST_ASSERT(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.size() == 0);
+
// Now activate and add 2 attributes
tracer->activate();
tracer->setTraceAttribute("foo", AnyValue{"bar"});
trace = tracer->getTracesData();
- BOOST_ASSERT(trace.resource_spans.at(0).resource.attributes.size() == 3);
- BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.at(1).key, "foo");
- BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.at(1).value, AnyValue{"bar"});
+ BOOST_ASSERT(trace.resource_spans.at(0).resource.attributes.size() == 1);
+ BOOST_ASSERT(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.size() == 2);
+
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.at(0).key, "foo");
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.at(0).value, AnyValue{"bar"});
- BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.at(2).key, "baz");
- BOOST_CHECK_EQUAL(trace.resource_spans.at(0).resource.attributes.at(2).value, AnyValue{256});
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.at(1).key, "baz");
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).scope.attributes.at(1).value, AnyValue{256});
// Add a span and some attributes
auto spanid = tracer->openSpan("anEvent").getSpanID();
tracer->activate();
tracer->setTraceAttribute("foo", AnyValue{"bar"});
data = tracer->getOTProtobuf();
- BOOST_TEST(data.size() == 45U);
+ BOOST_TEST(data.size() == 49U);
}
BOOST_AUTO_TEST_SUITE_END()
)
self.assertEqual(len(ot_data["resource_spans"]), 1)
- self.assertEqual(len(ot_data["resource_spans"][0]["resource"]["attributes"]), 4)
+ self.assertEqual(len(ot_data["resource_spans"][0]["resource"]["attributes"]), 1)
# Ensure all attributes exist
for field in ot_data["resource_spans"][0]["resource"]["attributes"]:
- self.assertTrue(
- field["key"]
- in ["service.name", "query.qname", "query.qtype", "query.remote"]
- )
+ self.assertTrue(field["key"] in ["service.name"])
# Ensure the values are correct
# TODO: query.remote with port
- msg_attrs = {
+ msg_scope_attrs = {
v["key"]: v["value"]["string_value"]
- for v in ot_data["resource_spans"][0]["resource"]["attributes"]
+ for v in ot_data["resource_spans"][0]["scope_spans"][0]["scope"][
+ "attributes"
+ ]
if v["key"] != "query.remote"
}
self.assertDictEqual(
- msg_attrs,
+ msg_scope_attrs,
{
- "service.name": "dnsdist",
"query.qname": "query.ot.tests.powerdns.com",
"query.qtype": "A",
},