Skip to content

Commit f90d20a

Browse files
committed
Add mirai_map() spans
1 parent 4e778e7 commit f90d20a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

R/map.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,16 @@ mirai_map <- function(.x, .f, ..., .args = list(), .promise = NULL, .compute = N
157157
require_daemons(.compute = .compute, call = environment())
158158
is.function(.f) || stop(sprintf(._[["function_required"]], typeof(.f)))
159159

160+
if (otel_tracing) {
161+
if (is.null(.compute)) .compute <- .[["cp"]]
162+
envir <- ..[[.compute]]
163+
parent_span <- envir[["otel_span"]]
164+
on.exit(`[[<-`(envir, "otel_span", parent_span))
165+
otel::local_active_span(parent_span)
166+
spn <- otel::start_local_active_span("mirai::mirai_map")
167+
`[[<-`(envir, "otel_span", spn)
168+
}
169+
160170
dx <- dim(.x)
161171
vec <- if (is.null(dx)) {
162172
`names<-`(

0 commit comments

Comments
 (0)