Skip to content

Commit 7646ccb

Browse files
committed
docs(dnsdist): Update docs for OT Tracing from Lua
1 parent f49a64e commit 7646ccb

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

pdns/dnsdistdist/docs/reference/dq.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,28 @@ This state can be modified from the various hooks.
449449

450450
:param string key: The tag's key
451451

452+
.. method:: withTraceSpan(name, func)
453+
454+
.. versionadded:: 2.2.0
455+
456+
Open an :doc:`OpenTelemetry Trace Span <ottrace>` called ``name`` that instruments function ``func``.
457+
This method can be called safely when Tracing is not enabled for the query or when :prog:`dnsdist` is built without Protobuf support.
458+
459+
:param string name: The name for this Span
460+
:param func function: The function to run. This function takes no parameters
461+
462+
.. method:: setSpanAttribute(key, value)
463+
464+
.. versionadded:: 2.2.0
465+
466+
Add an OpenTelemetry Trace Span attribute to the current span.
467+
In the context of a :func:`LuaAction`, this sets an attribute on the Rule's Span.
468+
When used inside the function passed to :meth:`DNSQuestion:withTraceSpan`, it will set the Attribute on the enclosed span.
469+
470+
This method can be called safely when Tracing is not enabled for the query or when :prog:`dnsdist` is built without Protobuf support.
471+
:param string key: The key for attribute
472+
:param string value: The value of the attribute
473+
452474

453475
.. _DNSResponse:
454476

pdns/dnsdistdist/docs/reference/ottrace.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,20 @@ The following example makes :program:`dnsdist` accept a TRACEPARENT, and update
143143
Creating Trace Spans from LuaActions
144144
====================================
145145

146-
It is possible to create Spans inside :func:`LuaRules <LuaRule>` in order to track performance of your Lua code.
146+
.. versionadded:: 2.2.0
147+
148+
It is possible to create Spans inside :func:`LuaRules <LuaRule>` or :func:`LuaResponseRules <LuaResponseRule>` in order to track performance of your Lua code.
147149
To do this, you can call the :func:`DNSQuestion:withTraceSpan` function of the :class:`DNSQuestion` object.
148-
This function takes a string that is the name of the Span and a function that accepts a single :class:`Closer` object.
150+
This function takes a string that is the name of the Span and the function with will be instrumented.
149151

150152
.. code-block:: lua
151153
152154
function myLuaAction(dq)
155+
dq:setSpanAttribute("attr-in-the-rule-span", "hello from Lua!")
153156
dq:withTraceSpan(
154157
'my-trace-span',
155-
function (closer)
156-
closer:setAttribute("some.key", "some-value")
158+
function ()
159+
dq:setSpanAttribute("some.key", "some-value")
157160
-- Do some actual things with the DNSQuestion here
158161
end
159162
)
@@ -167,14 +170,14 @@ Within the function body, you can create more spans by calling :func:`DNSQuestio
167170
function myLuaAction(dq)
168171
dq:withTraceSpan(
169172
'my-trace-span',
170-
function (closer)
173+
function ()
171174
-- Some set up
172-
closer:setAttribute("some.key", "some-value")
175+
dq:setSpanAttribute("some.key", "some-value")
173176
174177
-- This will create a child span of 'my-trace-span'
175178
dq:withTraceSpan(
176179
'inner-span',
177-
function (_) -- We're not using closer functions, so no need to assign it
180+
function ()
178181
-- Do some longer-running thing
179182
end
180183
)

0 commit comments

Comments
 (0)