Skip to content

Commit

Permalink
Remove shared ThreadLocal scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
xgouchet committed Dec 17, 2024
1 parent e7f82e3 commit 32afc41
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.concurrent.CopyOnWriteArrayList;

public class ContextualScopeManager implements ScopeManager {
static final ThreadLocal<DDScope> tlsScope = new ThreadLocal<>();
final ThreadLocal<DDScope> tlsScope = new ThreadLocal<>();
final Deque<ScopeContext> scopeContexts = new LinkedList<>();
final List<ScopeListener> scopeListeners = new CopyOnWriteArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.datadog.legacy.trace.api.Config
import com.datadog.legacy.trace.common.writer.Writer
import com.datadog.opentracing.DDSpan
import com.datadog.opentracing.LogHandler
import com.datadog.opentracing.scopemanager.ScopeTestHelper
import fr.xgouchet.elmyr.Forge
import fr.xgouchet.elmyr.annotation.DoubleForgery
import fr.xgouchet.elmyr.annotation.Forgery
Expand Down Expand Up @@ -134,8 +133,6 @@ internal class AndroidTracerTest {
val activeScope = tracer?.scopeManager()?.active()
activeSpan?.finish()
activeScope?.close()

ScopeTestHelper.removeThreadLocalScope()
}

// region Tracer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.datadog.android.api.feature.FeatureSdkCore
import com.datadog.android.trace.AndroidTracer
import com.datadog.android.utils.forge.Configurator
import com.datadog.opentracing.DDSpan
import com.datadog.opentracing.scopemanager.ScopeTestHelper
import fr.xgouchet.elmyr.Forge
import fr.xgouchet.elmyr.junit5.ForgeConfiguration
import fr.xgouchet.elmyr.junit5.ForgeExtension
Expand Down Expand Up @@ -58,8 +57,6 @@ internal class TracerExtensionsTest {
val activeScope = tracer.scopeManager().active()
activeSpan?.finish()
activeScope?.close()

ScopeTestHelper.removeThreadLocalScope()
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PendingTraceTest {
PendingTrace::class.java,
mockTracer,
fakeTraceId,
mockInternalLogger as InternalLogger
mockInternalLogger
)
val rootSpan =
forge.fakeSpan(pendingTrace, mockTracer, fakeTraceId, BigInteger.ZERO, "rootSpan", mockInternalLogger)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private fun <R> setFieldValue(instance: Any?, field: Field, fieldValue: R): Bool
* @param params the parameters to provide the constructor
* @return the instance of the class
*/
@Suppress("SpreadOperator")
@Suppress("SpreadOperator", "UNCHECKED_CAST")
fun <T : Any> createInstance(clazz: Class<T>, vararg params: Any?): T {
val toTypedArray = params.map { it?.javaClass ?: Any::class.java }.toTypedArray()
val constructor = clazz.declaredConstructors
Expand Down

0 comments on commit 32afc41

Please sign in to comment.