11test_that(" named and unnamed spans" , {
22 spns <- with_otel_record({
33 trc <- otel :: get_tracer(" mytracer" )
4- spn1 <- trc $ start_span ()
5- spn2 <- trc $ start_span (" my" )
4+ spn1 <- trc $ start_local_active_span ()
5+ spn2 <- trc $ start_local_active_span (" my" )
66 spn2 $ end()
77 spn1 $ end()
88 })[[" traces" ]]
@@ -15,7 +15,7 @@ test_that("close span automatically", {
1515 spns <- with_otel_record({
1616 trc <- otel :: get_tracer(" mytracer" )
1717 do <- function (name = NULL ) {
18- spn1 <- trc $ start_span (name )
18+ spn1 <- trc $ start_local_active_span (name )
1919 }
2020 do(" 1" )
2121 do(" 2" )
@@ -32,7 +32,7 @@ test_that("close span automatically, on error", {
3232 spns <- with_otel_record({
3333 trc <- otel :: get_tracer(" mytracer" )
3434 do <- function (name = NULL ) {
35- spn1 <- trc $ start_span (name )
35+ spn1 <- trc $ start_local_active_span (name )
3636 stop(" oops" )
3737 }
3838 try(do(" 1" ), silent = TRUE )
@@ -49,15 +49,15 @@ test_that("close span automatically, on error", {
4949test_that(" is_recording" , {
5050 trc_prv <- tracer_provider_memory_new()
5151 trc <- trc_prv $ get_tracer(" mytracer" )
52- spn1 <- trc $ start_span ()
52+ spn1 <- trc $ start_local_active_span ()
5353 expect_true(spn1 $ is_recording())
5454})
5555
5656test_that(" set_attribute" , {
5757 spns <- with_otel_record({
5858 trc <- otel :: get_tracer(" mytracer" )
59- spn1 <- trc $ start_span ()
60- spn2 <- trc $ start_span (" my" )
59+ spn1 <- trc $ start_local_active_span ()
60+ spn2 <- trc $ start_local_active_span (" my" )
6161 spn2 $ set_attribute(" key" , letters [1 : 3 ])
6262 spn1 $ set_attribute(" key" , " gone" )
6363 spn2 $ end()
@@ -78,8 +78,8 @@ test_that("set_attribute", {
7878test_that(" add_event" , {
7979 spns <- with_otel_record({
8080 trc <- otel :: get_tracer(" mytracer" )
81- spn1 <- trc $ start_span ()
82- spn2 <- trc $ start_span (" my" )
81+ spn1 <- trc $ start_local_active_span ()
82+ spn2 <- trc $ start_local_active_span (" my" )
8383 spn2 $ add_event(" ev" , attributes = list (key = " value" , key2 = 1 : 5 ))
8484 spn2 $ add_event(" ev2" , attributes = list (x = letters [1 : 4 ]))
8585 spn2 $ end()
@@ -103,7 +103,7 @@ test_that("set_status", {
103103 spns <- with_otel_record({
104104 trc <- otel :: get_tracer(" mytracer" )
105105 do <- function () {
106- spn1 <- trc $ start_span ()
106+ spn1 <- trc $ start_local_active_span ()
107107 spn1 $ set_status(" Unset" , description = " Testing preset Unset" )
108108 }
109109 do()
@@ -117,7 +117,7 @@ test_that("set_status", {
117117test_that(" update_name" , {
118118 spns <- with_otel_record({
119119 trc <- otel :: get_tracer(" mytracer" )
120- spn1 <- trc $ start_span ()
120+ spn1 <- trc $ start_local_active_span ()
121121 spn1 $ update_name(" good" )
122122 spn1 $ end()
123123 })[[" traces" ]]
@@ -131,7 +131,7 @@ test_that("record_exception", {
131131 error_obj <- base_error()
132132 spns <- with_otel_record({
133133 trc <- otel :: get_tracer(" mytracer" )
134- spn1 <- trc $ start_span ()
134+ spn1 <- trc $ start_local_active_span ()
135135 spn1 $ record_exception(error_obj )
136136 spn1 $ end()
137137 })[[" traces" ]]
@@ -173,8 +173,8 @@ test_that("format_exception", {
173173test_that(" create a root span" , {
174174 spns <- with_otel_record({
175175 trc <- otel :: get_tracer(" mytracer" )
176- spn1 <- trc $ start_span (" 1" )
177- spn2 <- trc $ start_span (" 2" , options = list (parent = NA ))
176+ spn1 <- trc $ start_local_active_span (" 1" )
177+ spn2 <- trc $ start_local_active_span (" 2" , options = list (parent = NA ))
178178 spn2 $ end()
179179 spn1 $ end()
180180 })[[" traces" ]]
@@ -188,7 +188,7 @@ test_that("get_context", {
188188 spid1 <- spid2 <- NULL
189189 spns <- with_otel_record(function () {
190190 trc <- otel :: get_tracer()
191- spn <- trc $ start_span (" 1" )
191+ spn <- trc $ start_local_active_span (" 1" )
192192 spid1 <<- spn $ get_context()$ get_span_id()
193193 spid2 <<- trc $ get_active_span_context()$ get_span_id()
194194 })[[" traces" ]]
@@ -202,15 +202,15 @@ test_that("get_context", {
202202test_that(" is_valid" , {
203203 spns <- with_otel_record(function () {
204204 trc <- otel :: get_tracer()
205- spn <- trc $ start_span (" 1" )
205+ spn <- trc $ start_local_active_span (" 1" )
206206 expect_true(spn $ is_valid())
207207 })[[" traces" ]]
208208})
209209
210210test_that(" span_context" , {
211211 spns <- with_otel_record(function () {
212212 trc <- otel :: get_tracer()
213- spn <- trc $ start_span (" 1" )
213+ spn <- trc $ start_local_active_span (" 1" )
214214 ctx <- spn $ get_context()
215215 expect_true(ctx $ is_valid())
216216 expect_snapshot(ctx $ get_trace_flags())
0 commit comments