fun <- function() {
# start span, do not activate
spn <- otel::start_span("myfun")
# do not leak resources
on.exit(otel::end_span(spn), add = TRUE)
myfun <- function() {
otel::with_active_span(spn, {
# create child span
spn2 <- otel::start_local_active_span("myfun/2")
})
}
myfun2 <- function() {
otel::with_active_span(spn, {
# create child span
spn3 <- otel::start_local_active_span("myfun/3")
})
}
myfun()
myfun2()
end_span(spn)
}
fun()
Run the code above in your browser using DataLab