Skip to content

Commit 4b2c5a1

Browse files
committed
docs(dnsdist): Update docs for OT Tracing from Lua
1 parent 431a8df commit 4b2c5a1

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
@@ -141,17 +141,20 @@ The following example makes :program:`dnsdist` accept a TRACEPARENT, and update
141141
Creating Trace Spans from LuaActions
142142
====================================
143143

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

148150
.. code-block:: lua
149151
150152
function myLuaAction(dq)
153+
dq:setSpanAttribute("attr-in-the-rule-span", "hello from Lua!")
151154
dq:withTraceSpan(
152155
'my-trace-span',
153-
function (closer)
154-
closer:setAttribute("some.key", "some-value")
156+
function ()
157+
dq:setSpanAttribute("some.key", "some-value")
155158
-- Do some actual things with the DNSQuestion here
156159
end
157160
)
@@ -165,14 +168,14 @@ Within the function body, you can create more spans by calling :func:`DNSQuestio
165168
function myLuaAction(dq)
166169
dq:withTraceSpan(
167170
'my-trace-span',
168-
function (closer)
171+
function ()
169172
-- Some set up
170-
closer:setAttribute("some.key", "some-value")
173+
dq:setSpanAttribute("some.key", "some-value")
171174
172175
-- This will create a child span of 'my-trace-span'
173176
dq:withTraceSpan(
174177
'inner-span',
175-
function (_) -- We're not using closer functions, so no need to assign it
178+
function ()
176179
-- Do some longer-running thing
177180
end
178181
)

0 commit comments

Comments
 (0)