test: Add a test for the UDS opentelemetry trace sink
What changed, and why it matters
This commit adds a new automated test that checks whether Core Lightning can send tracing data over a Unix domain socket. It is purely a test file change and does not modify any production code, configuration defaults, or network behavior. There is no security-relevant change.
No action required. This is a test-only addition with no security implications.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds test_tracing_socket to tests/test_misc.py. The test creates a SOCK_DGRAM Unix socket, sets CLN_TRACE_SOCKET to that path, starts and stops a Core Lightning node, then reads Zipkin-format JSON spans and asserts required fields. No implementation code is changed; the commit only exercises an existing tracing feature.
Changed components
tests/test_misc.pyInspect captured patch +40 / −0
diff --git a/tests/test_misc.py b/tests/test_misc.py
index bbfbd80c..e229a385 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -5143,3 +5143,43 @@ def test_filter_with_invalid_json(node_factory):
stdout=subprocess.PIPE)
assert 'filter: Expected object: invalid token' in out.stdout.decode('utf-8')
assert out.returncode == 1
+
+
+def test_tracing_socket(node_factory):
+ """Test UDS datagram tracing backend via CLN_TRACE_SOCKET."""
+ l1 = node_factory.get_node(start=False)
+ sock_path = os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "trace.sock")
+
+ # Create a SOCK_DGRAM UDS listener
+ sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
+ sock.bind(sock_path)
+ sock.settimeout(5)
+
+ l1.daemon.env["CLN_TRACE_SOCKET"] = sock_path
+ l1.start()
+ l1.stop()
+
+ # Collect all datagrams that were sent
+ spans = []
+ while True:
+ try:
+ data = sock.recv(4096)
+ spans.append(json.loads(data.decode("utf-8")))
+ except socket.timeout:
+ break
+
+ sock.close()
+
+ # We should have received at least some spans from startup
+ assert len(spans) > 0, "No spans received via UDS socket"
+
+ for span_array in spans:
+ # Each datagram is a Zipkin JSON array with one span
+ assert isinstance(span_array, list)
+ assert len(span_array) == 1
+ span = span_array[0]
+
+ # Validate required Zipkin fields are present
+ for key in ("id", "name", "timestamp", "duration", "traceId"):
+ assert key in span, f"Missing key {key} in span {span}"
+ assert span["localEndpoint"] == {"serviceName": "lightningd"}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.