@@ -499,11 +499,14 @@ internal void UpdateWithExemplar(long number, ReadOnlySpan<KeyValuePair<string,
499499
500500 this . runningValue . AsLong = number ;
501501
502- Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
502+ if ( isSampled )
503+ {
504+ Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
503505
504- // TODO: Need to ensure that the lock is always released.
505- // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
506- this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
506+ // TODO: Need to ensure that the lock is always released.
507+ // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
508+ this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
509+ }
507510
508511 ReleaseLock ( ref this . mpComponents ! . IsCriticalSectionOccupied ) ;
509512
@@ -516,11 +519,14 @@ internal void UpdateWithExemplar(long number, ReadOnlySpan<KeyValuePair<string,
516519
517520 this . runningValue . AsLong = number ;
518521
519- Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
522+ if ( isSampled )
523+ {
524+ Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
520525
521- // TODO: Need to ensure that the lock is always released.
522- // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
523- this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
526+ // TODO: Need to ensure that the lock is always released.
527+ // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
528+ this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
529+ }
524530
525531 ReleaseLock ( ref this . mpComponents ! . IsCriticalSectionOccupied ) ;
526532
@@ -717,11 +723,14 @@ internal void UpdateWithExemplar(double number, ReadOnlySpan<KeyValuePair<string
717723 this . runningValue . AsDouble = number ;
718724 }
719725
720- Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
726+ if ( isSampled )
727+ {
728+ Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
721729
722- // TODO: Need to ensure that the lock is always released.
723- // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
724- this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
730+ // TODO: Need to ensure that the lock is always released.
731+ // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
732+ this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
733+ }
725734
726735 ReleaseLock ( ref this . mpComponents ! . IsCriticalSectionOccupied ) ;
727736
@@ -737,11 +746,14 @@ internal void UpdateWithExemplar(double number, ReadOnlySpan<KeyValuePair<string
737746 this . runningValue . AsDouble = number ;
738747 }
739748
740- Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
749+ if ( isSampled )
750+ {
751+ Debug . Assert ( this . mpComponents . ExemplarReservoir != null , "ExemplarReservoir was null" ) ;
741752
742- // TODO: Need to ensure that the lock is always released.
743- // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
744- this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
753+ // TODO: Need to ensure that the lock is always released.
754+ // A custom implementation of `ExemplarReservoir.Offer` might throw an exception.
755+ this . mpComponents . ExemplarReservoir ! . Offer ( number , tags ) ;
756+ }
745757
746758 ReleaseLock ( ref this . mpComponents ! . IsCriticalSectionOccupied ) ;
747759
0 commit comments