Skip to content

Commit 8acfcbc

Browse files
porglezompktoso
authored andcommitted
Add documentation for @Traced
1 parent b8188a4 commit 8acfcbc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Sources/TracingMacros/TracedMacro.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,26 @@
1515
import Tracing
1616

1717
#if compiler(>=6.0)
18+
/// Instrument a function to place the entire body inside a span.
19+
///
20+
/// This macro is equivalent to calling ``/Tracing/withSpan`` in the body, but saves an
21+
/// indentation level and duplication. It introduces a `span` variable into the
22+
/// body of the function which can be used to add attributes to the span.
23+
///
24+
/// Parameters are passed directly to ``/Tracing/withSpan`` where applicable,
25+
/// and omitting the parameters from the macro omit them from the call, falling
26+
/// back to the default.
27+
///
28+
/// - Parameters:
29+
/// - operationName: The name of the operation being traced. Defaults to the name of the function.
30+
/// - context: The `ServiceContext` providing information on where to start the new ``/Tracing/Span``.
31+
/// - kind: The ``/Tracing/SpanKind`` of the new ``/Tracing/Span``.
32+
/// - spanName: The name of the span variable to introduce in the function. Pass `"_"` to omit it.
1833
@attached(body)
1934
public macro Traced(
2035
_ operationName: String? = nil,
2136
context: ServiceContext? = nil,
2237
ofKind kind: SpanKind? = nil,
23-
span spanName: String? = nil
38+
span spanName: String = "span"
2439
) = #externalMacro(module: "TracingMacrosImplementation", type: "TracedMacro")
2540
#endif

0 commit comments

Comments
 (0)