Skip to content

Commit

Permalink
Merge pull request #14887 from rgacogne/ddist19-backport-14850
Browse files Browse the repository at this point in the history
dnsdist-1.9.x: Backport of #14850 - add elapsed time to dq object
  • Loading branch information
rgacogne authored Dec 13, 2024
2 parents 691c57f + 9fd070b commit df6510b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pdns/dnsdist-lua-bindings-dnsquestion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx)
return dq.ids.queryRealTime.getStartTime();
});

luaCtx.registerFunction<double (DNSQuestion::*)() const>("getElapsedUs", [](const DNSQuestion& dnsQuestion) {
return dnsQuestion.ids.queryRealTime.udiff();
});

luaCtx.registerFunction<void(DNSQuestion::*)(std::string)>("sendTrap", [](const DNSQuestion& dq, boost::optional<std::string> reason) {
#ifdef HAVE_NET_SNMP
if (g_snmpAgent && g_snmpTrapsEnabled) {
Expand Down Expand Up @@ -450,6 +454,10 @@ class AsynchronousObject
return dr.ids.queryRealTime.getStartTime();
});

luaCtx.registerFunction<double (DNSResponse::*)() const>("getElapsedUs", [](const DNSResponse& dnsResponse) {
return dnsResponse.ids.queryRealTime.udiff();
});

luaCtx.registerFunction<void(DNSResponse::*)(std::string)>("sendTrap", [](const DNSResponse& dr, boost::optional<std::string> reason) {
#ifdef HAVE_NET_SNMP
if (g_snmpAgent && g_snmpTrapsEnabled) {
Expand Down
8 changes: 8 additions & 0 deletions pdns/dnsdistdist/docs/reference/dq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ This state can be modified from the various hooks.

:returns: A table of EDNSOptionView objects, indexed on the ECS Option code

.. method:: DNSQuestion::getElapsedUs -> double

.. versionadded:: 2.0.0

Return the amount of time that has elapsed since the query was received.

:returns: A double indicating elapsed time in microseconds

.. method:: DNSQuestion:getHTTPHeaders() -> table

.. versionadded:: 1.4.0
Expand Down

0 comments on commit df6510b

Please sign in to comment.