@@ -379,23 +379,27 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
379379#endif
380380 });
381381
382- luaCtx.registerFunction <void (DNSQuestion::*)(const std::string& name, const std::function<void (const pdns::trace::dnsdist::Tracer::Closer& closer )>& func)>(
382+ luaCtx.registerFunction <void (DNSQuestion::*)(const std::string& name, const std::function<void ()>& func)>(
383383 " withTraceSpan" ,
384- [](const DNSQuestion& dnsQuestion, const std::string& name, const std::function<void (const pdns::trace::dnsdist::Tracer::Closer& closer)> func) {
384+ [](const DNSQuestion& dnsQuestion, const std::string& name, const std::function<void ()>& func) {
385385#ifndef DISABLE_PROTOBUF
386386 if (auto tracer = dnsQuestion.ids .getTracer (); tracer != nullptr ) {
387387 auto closer = tracer->openSpan (name);
388- func (closer );
388+ func ();
389389 return ;
390390 }
391391#endif
392- func (pdns::trace::dnsdist::Tracer::Closer () );
392+ func ();
393393 });
394394
395- luaCtx.registerFunction <void (pdns::trace::dnsdist::Tracer::Closer ::*)(const std::string& key, const std::string& value)>(
395+ luaCtx.registerFunction <void (DNSQuestion ::*)(const std::string& key, const std::string& value)>(
396396 " setSpanAttribute" ,
397- [](pdns::trace::dnsdist::Tracer::Closer& closer, const std::string& key, const std::string& value) {
398- closer.setAttribute (key, AnyValue{value});
397+ [](const DNSQuestion& dnsQuestion, const std::string& key, const std::string& value) {
398+ #ifndef DISABLE_PROTOBUF
399+ if (auto tracer = dnsQuestion.ids .getTracer (); tracer != nullptr ) {
400+ tracer->setSpanAttribute (tracer->getLastSpanID (), key, AnyValue{value});
401+ }
402+ #endif
399403 });
400404
401405 class AsynchronousObject
@@ -739,17 +743,27 @@ void setupLuaBindingsDNSQuestion([[maybe_unused]] LuaContext& luaCtx)
739743 return dnsdist::suspendResponse (dnsResponse, asyncID, queryID, timeoutMs);
740744 });
741745
742- luaCtx.registerFunction <void (DNSResponse::*)(const std::string& name , const std::function<void (const pdns::trace::dnsdist::Tracer::Closer& closer )>& func )>(
746+ luaCtx.registerFunction <void (DNSResponse::*)(const std::string&, const std::function<void ()>&)>(
743747 " withTraceSpan" ,
744- [](const DNSResponse& dnsResponse, const std::string& name, const std::function<void (const pdns::trace::dnsdist::Tracer::Closer& closer)> func) {
748+ [](const DNSResponse& dnsResponse, const std::string& name, const std::function<void ()>& func) {
745749#ifndef DISABLE_PROTOBUF
746750 if (auto tracer = dnsResponse.ids .getTracer (); tracer != nullptr ) {
747751 auto closer = tracer->openSpan (name);
748- func (closer );
752+ func ();
749753 return ;
750754 }
751755#endif
752- func (pdns::trace::dnsdist::Tracer::Closer ());
756+ func ();
757+ });
758+
759+ luaCtx.registerFunction <void (DNSResponse::*)(const std::string& key, const std::string& value)>(
760+ " setSpanAttribute" ,
761+ [](const DNSResponse& dnsResponse, const std::string& key, const std::string& value) {
762+ #ifndef DISABLE_PROTOBUF
763+ if (auto tracer = dnsResponse.ids .getTracer (); tracer != nullptr ) {
764+ tracer->setSpanAttribute (tracer->getLastSpanID (), key, AnyValue{value});
765+ }
766+ #endif
753767 });
754768
755769 luaCtx.registerFunction <bool (DNSResponse::*)(const DNSName& newName)>(" changeName" , [](DNSResponse& dnsResponse, const DNSName& newName) -> bool {
0 commit comments