Description
Typically we trace at function level by wrapping the whole implementation in a span, as demonstrated by the sample.
func makeDinner() async throws -> Meal {
try await withSpan("makeDinner") { _ in
async let veggies = try chopVegetables()
async let meat = marinateMeat()
async let oven = preheatOven(temperature: 350)
// ...
return try await cook(veggies, meat, oven)
}
}
It makes me think if we can have an @Traced
macro attached to functions, which handles the span automatically for users. Eventually such macro should be configurable (explicit tracer, span name, extracting context from parameters, etc.), but AFAIK Swift macros seem not having such level of expressiveness yet.
@Traced
func makeDinner() async throws -> Meal {
async let veggies = try chopVegetables()
async let meat = marinateMeat()
async let oven = preheatOven(temperature: 350)
// ...
return try await cook(veggies, meat, oven)
}
Metadata
Metadata
Assignees
Labels
No labels