#endif
}
+void Tracer::Closer::setAttribute([[maybe_unused]] const std::string& key, [[maybe_unused]] const AnyValue& value)
+{
+#ifdef DISABLE_PROTOBUF
+ return;
+#else
+ return d_tracer->setSpanAttribute(d_spanID, key, value);
+#endif
+}
+
} // namespace pdns::trace::dnsdist
*/
[[nodiscard]] SpanID getSpanID() const;
+ /**
+ * @brief Set an attribute on the Span
+ *
+ * @param key
+ * @param value
+ * @return
+ */
+ void setAttribute(const std::string& key, const AnyValue& value);
+
private:
#ifndef DISABLE_PROTOBUF
std::shared_ptr<Tracer> d_tracer{nullptr};
auto closer = tracer->openSpan("myspan");
auto spanid = closer.getSpanID();
tracer->setSpanAttribute(spanid, "foo", AnyValue{42});
+ closer.setAttribute("bar", AnyValue{"hello"});
auto trace = tracer->getTracesData();
BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.size(), 1U);
- BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.size(), 1U);
+
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.size(), 2U);
BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.at(0).key, "foo");
BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.at(0).value, AnyValue{42});
+
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.at(1).key, "bar");
+ BOOST_CHECK_EQUAL(trace.resource_spans.at(0).scope_spans.at(0).spans.at(0).attributes.at(1).value, AnyValue{"hello"});
}
BOOST_AUTO_TEST_CASE(rootSpanAttributes)