There is no packet cache hit, so SyncRes is called which does a couple of outgoing queries.
+.. _opentelemetry_tracing:
OpenTelemetry Traces
^^^^^^^^^^^^^^^^^^^^
-OpenTelemetry Traces are generated by setting :ref:`setting-yaml-recursor.event_trace_enabled` or by using the :doc:`rec_control <manpages/rec_control.1>` subcommand ``set-event-trace-enabled``.
+OpenTelemetry Traces are generated by setting :ref:`setting-yaml-recursor.event_trace_enabled` or by using the :doc:`rec_control <manpages/rec_control.1>` subcommand ``set-event-trace-enabled`` to a value that includes 4.
+
:program:`Recursor` will set the ``openTelemetryData`` field of ``dnsmessage.proto`` messages generated to contain OpenTelemetry Traces, encoded as Protobuf data.
The encoding used is defined in https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto.
+OpenTelemetry Trace Conditions
+""""""""""""""""""""""""""""""
+
+Starting with version 5.4.0, the OpenTelemetry Trace data is only generated if :ref:`setting-yaml-recursor.event_trace_enabled` includes 4 *and* a matching condition from :ref:`setting-yaml-logging.opentelemetry_trace_conditions` evaluates to ``true``.
+
+For a match to occur, the origin address of the query should match a subnet in `acls`.
+If the proxy protocol is used, the source specified by the proxy protocol header is used to match.
+If Table Based Proxy Mapping is active, the mapped address is used.
+
+If a matching condition is found, the corresponding subconditions are evaluated.
+If all mentioned subconditions are satisfied, the condittion evalutes to ``true`` and OpenTelemetry Trace data is generated.
+If a subcondition is absent, it is not relevant.
+The following subcondtions can be specified:
+
+- ``qnames``: a suffixmatch with the incoming qname is done against the suffixes specified in ``qnames``.
+- ``qtypes``: the qtype of the incoming query must be listed in ``qtypes``
+- ``qid``: the query id of the incoming query must match ``qid``.
+- ``edns_option_required``: the incoing query must have an EDSN option specifying the TraceID.
+- ``traceid_only`` if ``true`` only the TraceID is picked up from EDNS data (if present) and placed into the protobuf `openTelemetryTraceID` field; no detailed `openTelemetryData` is produced.
+
+In the following example two conditions are specified:
+
+.. code-block:: yaml
+
+ logging:
+ opentelemetry_trace_conditions:
+ - acls: [127.0.0.1, '::1']
+ - acls: [192.168.178.0/24]
+ qnames: [a.very.specific.suffix]
+ qtypes: ['A', 'AAAA']
+ qid: 1234
+ edns_option_required: true
+
+The first condition specifies that all queries coming from ``127.0.0.1`` or ``::1`` should generate trace information.
+No subconditionss are relevant.
+
+The second condition specifies that queries coming from the ``192.167.178.0/24`` subnet should generate trace info only if the query name is ``a.very.specific.suffix`` (or has that suffix), the query type is ``A`` or ``AAAA``, the query id is ``1234`` and the EDNS option containing a TraceID is present.
+
+Queries coming from an IP not matching any of the mentioned subnets will not generate OpenTelemetry Trace information.
+
+Note that only the source IP is used to select a condition to evaluate.
+It is undefined what happens if a subnet occurs multiple times in all :ref:`setting-yaml-logging.opentelemetry_trace_conditions`.
+
+To generate OpenTelemetry Trace information for all queries (the 5.3.x behaviour), the follwing condition can be used:
+
+.. code-block:: yaml
+
+ logging:
+ opentelemetry_trace_conditions:
+ - acls: ['0.0.0.0/0', '::/0']
+
+To generate OpenTelemetry Trace information for all queries coming from ``127.0.0.1`` but only pick up the EDNS specified TraceID from all other queries:
+
+.. code-block:: yaml
+
+ logging:
+ opentelemetry_trace_conditions:
+ - acls: ['0.0.0.0/0', '::/0']
+ traceid_only: true
+ - acls: [127.0.0.1]
+
+To include a TraceID in a query ``sdig`` can be used, or a modern ``dig``, specifying the EDNS option code in decimal and the payload in hex:
+
+.. code-block:: sh
+
+ dig +ednsopt=65500:00000102030405060708090a0b0c0d0e0fff ...
+
+The first 4 zeroes after the colon specify the version byte and a reserved byte, followed by a 16 byte (32 hex characters) TraceID.
+Note that the EDNS option number 65500 is subject to change in the future.
+To also add a parent SpanID to the EDNS value, append 8 bytes (16 hex characters) more.
+
+Example OpenTelemetry Trace in in JSON representation
+"""""""""""""""""""""""""""""""""""""""""""""""""""""
+
The example decoder in https://github.com/PowerDNS/pdns/blob/master/contrib/ProtobufLogger.py displays a JSON representation of the data and optionally submits the data (in Protobuf format) to an OpenTelemetry trace collector using a POST to a URL given on the command line.
An example, encoded in JSON:
return false;
}
}
- cerr << "MC: true " << qname << ' ' << qtype << endl;
+
eventTrace.setThisOTTraceEnabled();
return true;
}
If no match is found on IP, a suffix match against the names in the ``suffixes`` lists is done using the nameserver name as key.
If again no match is found, the default configuration is used, this mean using the ``openssl`` provider, no certificate validation and no verbose logging.
+OpenTelemetryTraceCondition
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+As of version 5.4.0, an OpenTelemetry Trace condition is defined as
+
+.. code-block:: yaml
+
+ acls: sequence of string representing subnets, required
+ qnames: sequence of string representing DNS names
+ qtypes: a sequence of string representing Query Type names
+ qid: an integer specyfying a Query ID
+ edns_option_required: bool, default false
+ traceid_only: bool, default false
+
+A :ref:`setting-yaml-logging.opentelemetry_trace_conditions` section contains a sequence of `OpenTelemetryTraceCondition`_, for example:
+
+.. code-block:: yaml
+
+ logging:
+ opentelemetry_trace_conditions:
+ - acls: [127.0.0.1]
+ - acls: [192.168.178.0/24]
+ qnames: [a.very.specific.suffix]
+ qtypes: ['A', 'AAAA']
+ qid: 1234
+ edns_option_required: true
+ traceid_only: false
+
+See :ref:`opentelemetry_tracing` for an explanation how to use OpenTelemetry Trace Conditions.
+
The YAML settings
-----------------
'default' : '',
'help' : 'Sequence of OpenTelemetryTraceCondition',
'doc' : '''
- XXX
+ List of conditions specifying when to generate :ref:`opentelemetry_tracing`.
''',
'skip-old' : 'No equivalent old style setting',
'versionadded': '5.4.0',
}
runtime->d_writer.write(data);
+#ifdef RECURSOR
+ extern bool g_regressionTestMode;
+ if (g_regressionTestMode) {
+ runtime->d_writer.flush(runtime->d_socket->getHandle());
+ }
+#endif
++runtime->d_stats.d_queued;
return Result::Queued;
}
-void RemoteLogger::maintenanceThread()
+void RemoteLogger::maintenanceThread()
{
try {
#ifdef RECURSOR
- zone: example
file: configs/%s/example.zone
event_trace_enabled: 4
+ devonly_regression_test_mode: true
logging:
protobuf_servers:
- servers: [127.0.0.1:%s, 127.0.0.1:%s]
_config_template = """
auth-zones=example=configs/%s/example.zone
allow-from=3.4.5.0/24
+ devonly-regression-test-mode
""" % _confdir
_lua_config_file = """
_confdir = 'ProtobufProxyMappingLogMapped'
_config_template = """
auth-zones=example=configs/%s/example.zone
- allow-from=3.4.5.0/0"
+ devonly-regression-test-mode
+ allow-from=3.4.5.0/0v
""" % _confdir
_lua_config_file = """
auth-zones=example=configs/%s/example.zone
proxy-protocol-from=127.0.0.1/32
allow-from=127.0.0.1,6.6.6.6
+devonly-regression-test-mode
""" % _confdir
def testA(self):
auth-zones=example=configs/%s/example.zone
proxy-protocol-from=127.0.0.1/32
allow-from=3.4.5.6
+devonly-regression-test-mode
""" % _confdir
_lua_config_file = """
auth-zones=example=configs/%s/example.zone
proxy-protocol-from=127.0.0.1/32
allow-from=3.4.5.6
+devonly-regression-test-mode
""" % _confdir
_lua_config_file = """
qname-minimization=no
max-cache-ttl=600
loglevel=9
+ devonly-regression-test-mode
"""
_lua_config_file = """
outgoingProtobufServer({"127.0.0.1:%d", "127.0.0.1:%d"})
# this is to not let . queries interfere
max-cache-ttl=600
loglevel=9
+ devonly-regression-test-mode
"""
_lua_config_file = """
outgoingProtobufServer({"127.0.0.1:%d", "127.0.0.1:%d"})
qname-minimization=no
max-cache-ttl=600
loglevel=9
+ devonly-regression-test-mode
"""
_lua_config_file = """
outgoingProtobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=false, logResponses=true })
_confdir = 'ProtobufMasks'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_protobufMaskV4 = 4
_protobufMaskV6 = 128
_confdir = 'ProtobufQueriesOnly'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=false } )
_confdir = 'ProtobufTaggedOnly'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=true, taggedOnly=true } )
__test__ = True
_confdir = 'ProtobufTagCacheFFI'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=false, logResponses=true } )
_confdir = 'ProtobufExportTypes'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { exportTypes={"AAAA", "MX", "SPF", "SRV", "TXT"} } )
_confdir = 'ProtobufTaggedExtraFields'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=true } )
"""
_confdir = 'ProtobufTaggedExtraFieldsFFI'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=true } )
_confdir = 'ProtobufRPZ'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.rpz.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=true } )
_confdir = 'ProtobufRPZTags'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.rpz.zone""" % _confdir
_tags = ['tag1', 'tag2']
_tags_from_gettag = ['tag1-from-gettag', 'tag2-from-gettag']
"""
_confdir = 'ProtobufMetaFFI'
_config_template = """
+ devonly-regression-test-mode
auth-zones=example=configs/%s/example.zone""" % _confdir
_lua_config_file = """
protobufServer({"127.0.0.1:%d", "127.0.0.1:%d"}, { logQueries=true, logResponses=true } )