JfrScopeDecorator implements ScopeDecorator { @Override public Scope decorateScope(@Nullable TraceContext context, Scope scope) { if (scope == Scope.NOOP) return scope; ScopeEvent event = new ScopeEvent(); if (!event.isEnabled()) return scope; if (context != null) { event.traceId = context.traceIdString(); event.parentId = context.parentIdString(); event.spanId = context.spanIdString(); } event.begin(); class JfrCurrentTraceContextScope implements Scope { @Override public void close() { scope.close(); event.commit(); } } return new JfrCurrentTraceContextScope(); } JfrScopeDecorator(); static ScopeDecorator get(); @Deprecated static ScopeDecorator create(); @Override Scope decorateScope(@Nullable TraceContext context, Scope scope);  }
@Test public void doesntDecorateNoop() { assertThat(decorator.decorateScope(context, Scope.NOOP)).isSameAs(Scope.NOOP); assertThat(decorator.decorateScope(null, Scope.NOOP)).isSameAs(Scope.NOOP); }