Skip to content

Commit a618ced

Browse files
Can pass keywords to with-tracing.
These keywords get passed to trace-push.
1 parent a960eea commit a618ced

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

documentation/source/index.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,18 @@ tasks may find it easier to track their own spans separately.
194194
with-tracing ("Span description")
195195
trace-add-data("Table", "users");
196196
...
197-
end with-tracing
197+
end with-tracing;
198+
199+
:description:
200+
201+
The ``with-tracing`` macro can also take any keywords that :gf:`trace-push`
202+
takes and will pass them along:
203+
204+
.. code-block:: dylan
205+
206+
with-tracing ("Span description", sampler: never-sample)
207+
...
208+
end with-tracing;
198209
199210
Spans
200211
-----

tests/tracing-core/tracing-core-test-suite.dylan

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ define suite tracing-core-test-suite ()
1818
test test-nested-traces;
1919
test test-trace-host;
2020
test test-with-tracing;
21+
test test-with-tracing-never-sampling;
2122
test test-add-duration-to-timestamp;
2223
end suite;
2324

@@ -181,6 +182,12 @@ define test test-with-tracing ()
181182
end with-tracing;
182183
end test;
183184

185+
define test test-with-tracing-never-sampling ()
186+
with-tracing ("Outer", sampler: never-sample)
187+
assert-equal(0, trace-current-spans().size);
188+
end with-tracing;
189+
end test;
190+
184191
define test test-add-duration-to-timestamp ()
185192
let timestamp = make(<timestamp>, days: 0, seconds: 86398, microseconds: 500000);
186193
let new-timestamp = add-duration-to-timestamp(timestamp, 1, 500000);

tracing-core/trace.dylan

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ define function trace-set-host (host :: <string>) => ();
6363
end function trace-set-host;
6464

6565
define macro with-tracing
66-
{ with-tracing (?description:expression) ?:body end }
66+
{ with-tracing (?description:expression, #rest ?keys:expression) ?:body end }
6767
=>
6868
{
69-
let span = trace-push(?description);
69+
let span = trace-push(?description, ?keys);
7070
block ()
7171
?body
7272
cleanup

0 commit comments

Comments
 (0)