@@ -62,8 +62,6 @@ public class LogProbe extends ProbeDefinition implements Sampled {
6262 private static final Limits LIMITS = new Limits (1 , 3 , 8192 , 5 );
6363 private static final int LOG_MSG_LIMIT = 8192 ;
6464
65- private static final AtomicInteger NO_BUDGET = new AtomicInteger ();
66-
6765 public static final int PROBE_BUDGET = 10 ;
6866
6967 /** Stores part of a templated message either a str or an expression */
@@ -591,12 +589,6 @@ public void commit(
591589 }
592590 }
593591
594- private void incrementBudget () {
595- if (getDebugSessionId () != null ) {
596- getBudgetLevel ().incrementAndGet ();
597- }
598- }
599-
600592 protected Snapshot createSnapshot () {
601593 int maxDepth = capture != null ? capture .maxReferenceDepth : -1 ;
602594 return new Snapshot (Thread .currentThread (), this , maxDepth );
@@ -873,17 +865,25 @@ public String toString() {
873865 }
874866
875867 private boolean inBudget () {
876- return getBudgetLevel ().get () < PROBE_BUDGET ;
868+ AtomicInteger budgetLevel = getBudgetLevel ();
869+ return budgetLevel == null || budgetLevel .get () < PROBE_BUDGET ;
877870 }
878871
879872 private AtomicInteger getBudgetLevel () {
880873 TracerAPI tracer = AgentTracer .get ();
881874 AgentSpan span = tracer != null ? tracer .activeSpan () : null ;
882875 return getDebugSessionId () == null || span == null
883- ? NO_BUDGET
876+ ? null
884877 : budget .computeIfAbsent (span .getLocalRootSpan ().getTraceId (), id -> new AtomicInteger ());
885878 }
886879
880+ private void incrementBudget () {
881+ AtomicInteger budgetLevel = getBudgetLevel ();
882+ if (budgetLevel != null ) {
883+ budgetLevel .incrementAndGet ();
884+ }
885+ }
886+
887887 @ Generated
888888 @ Override
889889 public boolean equals (Object o ) {
0 commit comments