Skip to content

Commit a60055a

Browse files
committed
Remove unused activeScope method (#8531)
1 parent 3236f5a commit a60055a

File tree

8 files changed

+29
-47
lines changed

8 files changed

+29
-47
lines changed

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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 3 additions & 3 deletions
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/main/java/datadog/trace/core/CoreTracer.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -951,11 +951,6 @@ public AgentSpan activeSpan() {
951951
return scopeManager.activeSpan();
952952
}
953953

954-
@Override
955-
public AgentScope activeScope() {
956-
return scopeManager.active();
957-
}
958-
959954
@Override
960955
public void checkpointActiveForRollback() {
961956
this.scopeManager.checkpointActiveForRollback();

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ class ScopeManagerTest extends DDCoreSpecification {
456456

457457
def "closing scope out of order - complex"() {
458458
// Events are checked twice in each case to ensure a call to
459-
// tracer.activeScope() or tracer.activeSpan() doesn't change the count
459+
// activeScope() or tracer.activeSpan() doesn't change the count
460460

461461
when:
462462
AgentSpan firstSpan = tracer.buildSpan("test", "foo").start()
@@ -465,7 +465,7 @@ class ScopeManagerTest extends DDCoreSpecification {
465465
then:
466466
assertEvents([ACTIVATE])
467467
tracer.activeSpan() == firstSpan
468-
tracer.activeScope() == firstScope
468+
scopeManager.active() == firstScope
469469
assertEvents([ACTIVATE])
470470
1 * profilingContext.onRootSpanStarted(_)
471471
1 * profilingContext.onAttach()
@@ -480,7 +480,7 @@ class ScopeManagerTest extends DDCoreSpecification {
480480
then:
481481
assertEvents([ACTIVATE, ACTIVATE])
482482
tracer.activeSpan() == secondSpan
483-
tracer.activeScope() == secondScope
483+
scopeManager.active() == secondScope
484484
assertEvents([ACTIVATE, ACTIVATE])
485485
1 * profilingContext.encodeOperationName("bar")
486486
1 * profilingContext.newScopeState(_) >> Stub(Stateful)
@@ -493,7 +493,7 @@ class ScopeManagerTest extends DDCoreSpecification {
493493
then:
494494
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
495495
tracer.activeSpan() == thirdSpan
496-
tracer.activeScope() == thirdScope
496+
scopeManager.active() == thirdScope
497497
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
498498
1 * profilingContext.encodeOperationName("quux")
499499
1 * profilingContext.newScopeState(_) >> Stub(Stateful)
@@ -505,7 +505,7 @@ class ScopeManagerTest extends DDCoreSpecification {
505505
then:
506506
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
507507
tracer.activeSpan() == thirdSpan
508-
tracer.activeScope() == thirdScope
508+
scopeManager.active() == thirdScope
509509
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE])
510510
0 * _
511511

@@ -515,7 +515,7 @@ class ScopeManagerTest extends DDCoreSpecification {
515515
then:
516516
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE, CLOSE, CLOSE, ACTIVATE])
517517
tracer.activeSpan() == firstSpan
518-
tracer.activeScope() == firstScope
518+
scopeManager.active() == firstScope
519519

520520
assertEvents([ACTIVATE, ACTIVATE, ACTIVATE, CLOSE, CLOSE, ACTIVATE])
521521
0 * _
@@ -533,7 +533,7 @@ class ScopeManagerTest extends DDCoreSpecification {
533533
ACTIVATE,
534534
CLOSE
535535
])
536-
tracer.activeScope() == null
536+
scopeManager.active() == null
537537
assertEvents([
538538
ACTIVATE,
539539
ACTIVATE,
@@ -571,7 +571,7 @@ class ScopeManagerTest extends DDCoreSpecification {
571571
then:
572572
assertEvents([ACTIVATE, ACTIVATE])
573573
tracer.activeSpan() == thirdSpan
574-
tracer.activeScope() == thirdScope
574+
scopeManager.active() == thirdScope
575575
assertEvents([ACTIVATE, ACTIVATE])
576576
1 * profilingContext.encodeOperationName("quux")
577577
1 * profilingContext.newScopeState(_) >> Stub(Stateful)

internal-api/src/main/java/datadog/trace/bootstrap/instrumentation/api/AgentTracer.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ public static AgentSpan activeSpan() {
179179
return get().activeSpan();
180180
}
181181

182-
/** @deprecated To be removed, do not use. */
183-
@Deprecated
184-
public static AgentScope activeScope() {
185-
return get().activeScope();
186-
}
187-
188182
/**
189183
* Checks whether asynchronous propagation is enabled, meaning this context will propagate across
190184
* asynchronous boundaries.
@@ -355,8 +349,6 @@ AgentSpan startSpan(
355349

356350
AgentSpan activeSpan();
357351

358-
AgentScope activeScope();
359-
360352
default AgentSpan blackholeSpan() {
361353
final AgentSpan active = activeSpan();
362354
return new BlackHoleSpan(active != null ? active.getTraceId() : DDTraceId.ZERO);
@@ -523,11 +515,6 @@ public AgentSpan activeSpan() {
523515
return NoopSpan.INSTANCE;
524516
}
525517

526-
@Override
527-
public AgentScope activeScope() {
528-
return null;
529-
}
530-
531518
@Override
532519
public AgentSpan blackholeSpan() {
533520
return NoopSpan.INSTANCE; // no-op tracer stays no-op

0 commit comments

Comments
 (0)