File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
opentelemetry-instrumentation/tests Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -116,15 +116,15 @@ def test_thread_safety_atomic_increment(self):
116116 num_threads = 100
117117 increments_per_thread = 50
118118 expected_final_value = num_threads * increments_per_thread
119-
119+
120120 def increment_worker ():
121121 for _ in range (increments_per_thread ):
122122 # read-modify-write to increase contention
123123 attrs = labeler .get_attributes () # Read
124- current = attrs ["counter" ] # Extract
125- new_value = current + 1 # Modify
126- labeler .add ("counter" , new_value ) # Write
127-
124+ current = attrs ["counter" ] # Extract
125+ new_value = current + 1 # Modify
126+ labeler .add ("counter" , new_value ) # Write
127+
128128 threads = []
129129 for _ in range (num_threads ):
130130 thread = threading .Thread (target = increment_worker )
@@ -133,12 +133,13 @@ def increment_worker():
133133 thread .start ()
134134 for thread in threads :
135135 thread .join ()
136-
136+
137137 final_value = labeler .get_attributes ()["counter" ]
138138 self .assertEqual (
139- final_value , expected_final_value ,
139+ final_value ,
140+ expected_final_value ,
140141 f"Expected { expected_final_value } , got { final_value } . "
141- f"Lost { expected_final_value - final_value } updates due to race conditions."
142+ f"Lost { expected_final_value - final_value } updates due to race conditions." ,
142143 )
143144
144145
You can’t perform that action at this time.
0 commit comments