Skip to content

Commit 13bfe39

Browse files
committed
Upgrade to use links
1 parent ba4016d commit 13bfe39

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

R/daemon.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ eval_mirai <- function(._mirai_.) {
216216
{
217217
list2env(._mirai_.[["._globals_."]], envir = .GlobalEnv)
218218
if (otel_tracing && length(._mirai_.[["._otel_."]])) {
219-
currid <- otel::get_active_span_context()$get_span_id()
220219
prtctx <- otel::extract_http_context(._mirai_.[["._otel_."]])
221220
spn <- otel::start_local_active_span(
222221
"mirai::daemon->eval",
223-
attributes = otel::as_attributes(list(daemon_id = currid)),
222+
links = list(daemon = dynGet("spn")),
224223
options = list(parent = prtctx)
225224
)
226225
}

R/daemons.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ daemons <- function(
304304
attributes = otel::as_attributes(list(
305305
url = envir[["url"]],
306306
n = envir[["n"]],
307-
dispatcher = envir[["dispatcher"]],
307+
dispatcher = if (is.null(envir[["dispatcher"]])) "false" else "true",
308308
compute_profile = .compute
309309
))
310310
)

R/map.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,11 @@ mirai_map <- function(.x, .f, ..., .args = list(), .promise = NULL, .compute = N
159159
if (is.null(.compute)) .compute <- .[["cp"]]
160160

161161
if (otel_tracing) {
162-
if (!otel::get_active_span_context()$is_valid()) {
163-
otel::local_active_span(..[[.compute]][["otel_span"]])
164-
}
162+
active <- otel::get_active_span_context()$is_valid()
165163
spn <- otel::start_local_active_span(
166164
"mirai::mirai_map",
167-
attributes = otel::as_attributes(list(compute_profile = .compute))
165+
links = if (active) list(compute_profile = ..[[.compute]][["otel_span"]]),
166+
options = if (!active) list(parent = ..[[.compute]][["otel_span"]])
168167
)
169168
}
170169

R/mirai.R

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@
142142
#'
143143
mirai <- function(.expr, ..., .args = list(), .timeout = NULL, .compute = NULL) {
144144
missing(.expr) && stop(._[["missing_expression"]])
145+
envir <- compute_env(.compute)
145146

146-
if (is.null(.compute)) .compute <- .[["cp"]]
147-
envir <- ..[[.compute]]
148147
expr <- substitute(.expr)
149148
globals <- list(...)
150149
length(globals) && {
@@ -166,12 +165,11 @@ mirai <- function(.expr, ..., .args = list(), .timeout = NULL, .compute = NULL)
166165
) .expr else expr,
167166
._globals_. = globals,
168167
._otel_. = if (otel_tracing && length(envir)) {
169-
if (!otel::get_active_span_context()$is_valid()) {
170-
otel::local_active_span(envir[["otel_span"]])
171-
}
168+
active <- otel::get_active_span_context()$is_valid()
172169
spn <- otel::start_local_active_span(
173170
"mirai::mirai",
174-
attributes = otel::as_attributes(list(compute_profile = .compute))
171+
links = if (active) list(compute_profile = envir[["otel_span"]]),
172+
options = if (!active) list(parent = envir[["otel_span"]])
175173
)
176174
otel::pack_http_context()
177175
}

0 commit comments

Comments
 (0)