Skip to content

Commit c2917af

Browse files
committed
Move instrumentation to within test_code()
1 parent efbf819 commit c2917af

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

R/otel.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,11 @@ local({
1818
otel_local_active_span <<- function(
1919
name,
2020
label,
21-
attributes = list(),
22-
links = NULL,
23-
options = NULL,
2421
scope = parent.frame()
2522
) {
2623
otel_is_tracing || return()
27-
spn <- otel::start_local_active_span(
24+
otel::start_local_active_span(
2825
sprintf("%s %s", name, label),
29-
attributes = otel::as_attributes(attributes),
30-
links = links,
31-
options = options,
3226
tracer = otel_tracer,
3327
activation_scope = scope
3428
)

R/test-that.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#' }
3636
test_that <- function(desc, code) {
3737
local_description_push(desc)
38-
otel_local_active_span("test that", desc)
3938

4039
code <- substitute(code)
4140
test_code(code, parent.frame())
@@ -52,6 +51,7 @@ test_code <- function(code, env, reporter = NULL, skip_on_empty = TRUE) {
5251

5352
test <- test_description()
5453
if (!is.null(test)) {
54+
otel_local_active_span("test that", test, scope = frame)
5555
reporter$start_test(context = reporter$.context, test = test)
5656
withr::defer(reporter$end_test(context = reporter$.context, test = test))
5757
}

tests/testthat/test-otel.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ test_that("otel instrumentation works", {
1010

1111
traces <- record$traces
1212
expect_length(traces, 1L)
13-
expect_equal(traces[[1L]]$name, "test that otel testing")
13+
expect_equal(traces[[1L]]$name, "test that otel instrumentation works / otel testing")
1414
expect_equal(traces[[1L]]$instrumentation_scope$name , "org.r-lib.testthat")
1515
})

0 commit comments

Comments
 (0)