Skip to content

Commit b046b86

Browse files
authored
Minor test changes to avoid deprecated API (#8574)
1 parent 1c3133b commit b046b86

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

dd-java-agent/instrumentation/akka-concurrent/src/akka23Test/scala/AkkaActors.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import akka.util.Timeout
66
import datadog.trace.api.Trace
77
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{
88
activateSpan,
9-
activeScope,
9+
setAsyncPropagationEnabled,
1010
activeSpan,
1111
startSpan
1212
}
@@ -57,7 +57,7 @@ class AkkaActors extends AutoCloseable {
5757
@Trace
5858
def send(name: String, who: String): Unit = {
5959
val actor = actors(name)
60-
activeScope().setAsyncPropagation(true)
60+
setAsyncPropagationEnabled(true)
6161
activeSpan().setSpanName(name)
6262
actor ! WhoToGreet(who)
6363
if (name == "ask") {
@@ -69,7 +69,7 @@ class AkkaActors extends AutoCloseable {
6969

7070
@Trace
7171
def leak(who: String, leak: String): Unit = {
72-
activeScope().setAsyncPropagation(true)
72+
setAsyncPropagationEnabled(true)
7373
activeSpan().setSpanName("leak all the things")
7474
tellGreeter ! WhoToGreet(who)
7575
tellGreeter ! Leak(leak)

dd-java-agent/instrumentation/pekko-concurrent/src/test/scala/PekkoActors.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import org.apache.pekko.util.Timeout
66
import datadog.trace.api.Trace
77
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{
88
activateSpan,
9-
activeScope,
9+
setAsyncPropagationEnabled,
1010
activeSpan,
1111
startSpan
1212
}
@@ -55,7 +55,7 @@ class PekkoActors extends AutoCloseable {
5555
@Trace
5656
def send(name: String, who: String): Unit = {
5757
val actor = actors(name)
58-
activeScope().setAsyncPropagation(true)
58+
setAsyncPropagationEnabled(true)
5959
activeSpan().setSpanName(name)
6060
actor ! WhoToGreet(who)
6161
if (name == "ask") {
@@ -67,7 +67,7 @@ class PekkoActors extends AutoCloseable {
6767

6868
@Trace
6969
def leak(who: String, leak: String): Unit = {
70-
activeScope().setAsyncPropagation(true)
70+
setAsyncPropagationEnabled(true)
7171
activeSpan().setSpanName("leak all the things")
7272
tellGreeter ! WhoToGreet(who)
7373
tellGreeter ! Leak(leak)

dd-java-agent/instrumentation/scala-concurrent/src/latestDepTest/scala/ScalaConcurrentTests.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datadog.trace.agent.test.AgentTestRunner.blockUntilChildSpansFinished
22
import datadog.trace.api.Trace
3-
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{activeScope, activeSpan}
3+
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{setAsyncPropagationEnabled, activeSpan}
44

55
import scala.concurrent.ExecutionContext.Implicits.global
66
import scala.concurrent.duration._
@@ -13,7 +13,7 @@ class ScalaConcurrentTests {
1313
*/
1414
@Trace
1515
def traceWithFutureAndCallbacks(): Integer = {
16-
activeScope().setAsyncPropagation(true)
16+
setAsyncPropagationEnabled(true)
1717
val goodFuture: Future[Integer] = Future {
1818
tracedChild("goodFuture")
1919
1
@@ -31,7 +31,7 @@ class ScalaConcurrentTests {
3131

3232
@Trace
3333
def tracedAcrossThreadsWithNoTrace(): Integer = {
34-
activeScope().setAsyncPropagation(true)
34+
setAsyncPropagationEnabled(true)
3535
val goodFuture: Future[Integer] = Future {
3636
1
3737
}
@@ -51,7 +51,7 @@ class ScalaConcurrentTests {
5151
*/
5252
@Trace
5353
def traceWithPromises(): Integer = {
54-
activeScope().setAsyncPropagation(true)
54+
setAsyncPropagationEnabled(true)
5555
val keptPromise = Promise[Boolean]()
5656
val brokenPromise = Promise[Boolean]()
5757
val afterPromise = keptPromise.future
@@ -78,7 +78,7 @@ class ScalaConcurrentTests {
7878
*/
7979
@Trace
8080
def tracedWithFutureFirstCompletions(): Integer = {
81-
activeScope().setAsyncPropagation(true)
81+
setAsyncPropagationEnabled(true)
8282
val completedVal = Future.firstCompletedOf(List(Future {
8383
tracedChild("timeout1")
8484
false
@@ -100,7 +100,7 @@ class ScalaConcurrentTests {
100100
*/
101101
@Trace
102102
def tracedTimeout(): Integer = {
103-
activeScope().setAsyncPropagation(true)
103+
setAsyncPropagationEnabled(true)
104104
val f: Future[String] = Future {
105105
tracedChild("timeoutChild")
106106
while (true) {

dd-java-agent/instrumentation/scala-concurrent/src/test/scala/ScalaConcurrentTests.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datadog.trace.agent.test.AgentTestRunner.blockUntilChildSpansFinished
22
import datadog.trace.api.Trace
3-
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{activeScope, activeSpan}
3+
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{setAsyncPropagationEnabled, activeSpan}
44

55
import scala.concurrent.ExecutionContext.Implicits.global
66
import scala.concurrent.duration._
@@ -13,7 +13,7 @@ class ScalaConcurrentTests {
1313
*/
1414
@Trace
1515
def traceWithFutureAndCallbacks(): Integer = {
16-
activeScope().setAsyncPropagation(true)
16+
setAsyncPropagationEnabled(true)
1717
val goodFuture: Future[Integer] = Future {
1818
tracedChild("goodFuture")
1919
1
@@ -31,7 +31,7 @@ class ScalaConcurrentTests {
3131

3232
@Trace
3333
def tracedAcrossThreadsWithNoTrace(): Integer = {
34-
activeScope().setAsyncPropagation(true)
34+
setAsyncPropagationEnabled(true)
3535
val goodFuture: Future[Integer] = Future {
3636
1
3737
}
@@ -51,7 +51,7 @@ class ScalaConcurrentTests {
5151
*/
5252
@Trace
5353
def traceWithPromises(): Integer = {
54-
activeScope().setAsyncPropagation(true)
54+
setAsyncPropagationEnabled(true)
5555
val keptPromise = Promise[Boolean]()
5656
val brokenPromise = Promise[Boolean]()
5757
val afterPromise = keptPromise.future
@@ -78,7 +78,7 @@ class ScalaConcurrentTests {
7878
*/
7979
@Trace
8080
def tracedWithFutureFirstCompletions(): Integer = {
81-
activeScope().setAsyncPropagation(true)
81+
setAsyncPropagationEnabled(true)
8282
val completedVal = Future.firstCompletedOf(List(Future {
8383
tracedChild("timeout1")
8484
false
@@ -100,7 +100,7 @@ class ScalaConcurrentTests {
100100
*/
101101
@Trace
102102
def tracedTimeout(): Integer = {
103-
activeScope().setAsyncPropagation(true)
103+
setAsyncPropagationEnabled(true)
104104
val f: Future[String] = Future {
105105
tracedChild("timeoutChild")
106106
while (true) {

dd-java-agent/instrumentation/slick/src/test/scala/SlickUtils.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import datadog.trace.agent.test.AgentTestRunner.blockUntilChildSpansFinished
22
import datadog.trace.api.Trace
3-
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{activeScope, activeSpan}
3+
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.{setAsyncPropagationEnabled, activeSpan}
44
import datadog.trace.common.writer.ListWriter
55
import datadog.trace.core.DDSpan
66
import slick.jdbc.H2Profile.api._
@@ -26,7 +26,7 @@ class SlickUtils(TEST_WRITER: ListWriter) {
2626

2727
@Trace
2828
def setup(): DDSpan = {
29-
activeScope().setAsyncPropagation(true)
29+
setAsyncPropagationEnabled(true)
3030
Await.result(
3131
database.run(
3232
sqlu"""CREATE ALIAS IF NOT EXISTS SLEEP FOR "java.lang.Thread.sleep(long)""""
@@ -39,7 +39,7 @@ class SlickUtils(TEST_WRITER: ListWriter) {
3939
@Trace
4040
def startQuery(query: String): Future[Vector[Int]] = {
4141
try {
42-
activeScope().setAsyncPropagation(true)
42+
setAsyncPropagationEnabled(true)
4343
database.run(sql"#$query".as[Int])
4444
} finally {
4545
blockUntilChildSpansFinished(activeSpan(), 1)

dd-trace-core/src/test/groovy/datadog/trace/core/scopemanager/ScopeManagerTest.groovy

+8-8
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ class ScopeManagerTest extends DDCoreSpecification {
541541

542542
def "closing scope out of order - complex"() {
543543
// Events are checked twice in each case to ensure a call to
544-
// tracer.activeScope() or tracer.activeSpan() doesn't change the count
544+
// scopeManager.active() or tracer.activeSpan() doesn't change the count
545545

546546
when:
547547
AgentSpan firstSpan = tracer.buildSpan("test", "foo").start()
@@ -550,7 +550,7 @@ class ScopeManagerTest extends DDCoreSpecification {
550550
then:
551551
assertEvents([ACTIVATE])
552552
tracer.activeSpan() == firstSpan
553-
tracer.activeScope() == firstScope
553+
scopeManager.active() == firstScope
554554
assertEvents([ACTIVATE])
555555
1 * profilingContext.onRootSpanStarted(_)
556556
1 * profilingContext.onAttach()
@@ -565,7 +565,7 @@ class ScopeManagerTest extends DDCoreSpecification {
565565
then:
566566
assertEvents([ACTIVATE, ACTIVATE])
567567
tracer.activeSpan() == secondSpan
568-
tracer.activeScope() == secondScope
568+
scopeManager.active() == secondScope
569569
assertEvents([ACTIVATE, ACTIVATE])
570570
1 * profilingContext.encodeOperationName("bar")
571571
1 * profilingContext.newScopeState(_) >> Stub(Stateful)
@@ -578,7 +578,7 @@ class ScopeManagerTest extends DDCoreSpecification {
578578
then:
579579
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
580580
tracer.activeSpan() == thirdSpan
581-
tracer.activeScope() == thirdScope
581+
scopeManager.active() == thirdScope
582582
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
583583
1 * profilingContext.encodeOperationName("quux")
584584
1 * profilingContext.newScopeState(_) >> Stub(Stateful)
@@ -590,7 +590,7 @@ class ScopeManagerTest extends DDCoreSpecification {
590590
then:
591591
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
592592
tracer.activeSpan() == thirdSpan
593-
tracer.activeScope() == thirdScope
593+
scopeManager.active() == thirdScope
594594
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
595595
0 * _
596596

@@ -600,7 +600,7 @@ class ScopeManagerTest extends DDCoreSpecification {
600600
then:
601601
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE, CLOSE, CLOSE, ACTIVATE])
602602
tracer.activeSpan() == firstSpan
603-
tracer.activeScope() == firstScope
603+
scopeManager.active() == firstScope
604604

605605
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE, CLOSE, CLOSE, ACTIVATE])
606606
0 * _
@@ -618,7 +618,7 @@ class ScopeManagerTest extends DDCoreSpecification {
618618
ACTIVATE,
619619
CLOSE
620620
])
621-
tracer.activeScope() == null
621+
scopeManager.active() == null
622622
assertEvents([
623623
ACTIVATE,
624624
ACTIVATE,
@@ -656,7 +656,7 @@ class ScopeManagerTest extends DDCoreSpecification {
656656
then:
657657
assertEvents([ACTIVATE, ACTIVATE])
658658
tracer.activeSpan() == thirdSpan
659-
tracer.activeScope() == thirdScope
659+
scopeManager.active() == thirdScope
660660
assertEvents([ACTIVATE, ACTIVATE])
661661
1 * profilingContext.encodeOperationName("quux")
662662
1 * profilingContext.newScopeState(_) >> Stub(Stateful)

0 commit comments

Comments
 (0)