Properly clears the scopes (#2280)

without this fix when calling `maybeScope(null)` or `withSpan(null)` or `newScope(null)` we ended up with creating a null scope that would allocate additional resources and not clear things.

with this fix we're clearing all the scopes and removing thread locals
This commit is contained in:
Marcin Grzejszczak
2023-04-14 13:35:35 +02:00
committed by GitHub
parent d05059a106
commit 3d198306ea
6 changed files with 344 additions and 20 deletions

View File

@@ -94,6 +94,13 @@ public interface CurrentTraceContext {
*/
interface Scope extends Closeable {
/**
* Noop instance.
*/
Scope NOOP = () -> {
};
@Override
void close();

View File

@@ -170,6 +170,13 @@ public interface Tracer extends BaggageManager {
*/
interface SpanInScope extends Closeable {
/**
* Noop instance.
*/
SpanInScope NOOP = () -> {
};
@Override
void close();