@@ -151,7 +151,7 @@ public void onFailure(Exception e) {
151151 e .fillInStackTrace ();
152152 assertThat (e .getStackTrace ().length , is (not (0 )));
153153 listener .onFailure (e );
154- listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), "node" , shardId , threadPool );
154+ listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), "node" , shardId , 123L , threadPool );
155155 isWrapped .set (true );
156156 listener .onFailure (e );
157157 }
@@ -160,16 +160,17 @@ public void testMaybeWrapListenerForStackTraceDebugLog() {
160160 final String nodeId = "node" ;
161161 final String index = "index" ;
162162 ShardId shardId = new ShardId (index , index , 0 );
163+ final long taskId = 123L ;
163164
164165 try (var mockLog = MockLog .capture (SearchService .class )) {
165166 Configurator .setLevel (SearchService .class , Level .DEBUG );
166167 final String exceptionMessage = "test exception message" ;
167168 mockLog .addExpectation (
168169 new MockLog .ExceptionSeenEventExpectation (
169- format ("\" [%s]%s: failed to execute search request\" and an exception logged" , nodeId , shardId ),
170+ format ("\" [%s]%s: failed to execute search request for task [%d] \" and an exception logged" , nodeId , shardId , taskId ),
170171 SearchService .class .getCanonicalName (),
171172 Level .DEBUG , // We will throw a 400-level exception, so it should only be logged at the debug level
172- format ("[%s]%s: failed to execute search request" , nodeId , shardId ),
173+ format ("[%s]%s: failed to execute search request for task [%d] " , nodeId , shardId , taskId ),
173174 IllegalArgumentException .class ,
174175 exceptionMessage
175176 )
@@ -188,7 +189,7 @@ public void onFailure(Exception e) {
188189 }
189190 };
190191 IllegalArgumentException e = new IllegalArgumentException (exceptionMessage ); // 400-level exception
191- listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), nodeId , shardId , threadPool );
192+ listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), nodeId , shardId , taskId , threadPool );
192193 listener .onFailure (e );
193194 }
194195 }
@@ -197,15 +198,16 @@ public void testMaybeWrapListenerForStackTraceWarnLog() {
197198 final String nodeId = "node" ;
198199 final String index = "index" ;
199200 ShardId shardId = new ShardId (index , index , 0 );
201+ final long taskId = 123L ;
200202
201203 try (var mockLog = MockLog .capture (SearchService .class )) {
202204 final String exceptionMessage = "test exception message" ;
203205 mockLog .addExpectation (
204206 new MockLog .ExceptionSeenEventExpectation (
205- format ("\" [%s]%s: failed to execute search request\" and an exception logged" , nodeId , shardId ),
207+ format ("\" [%s]%s: failed to execute search request for task [%d] \" and an exception logged" , nodeId , shardId , taskId ),
206208 SearchService .class .getCanonicalName (),
207209 Level .WARN , // We will throw a 500-level exception, so it should be logged at the warn level
208- format ("[%s]%s: failed to execute search request" , nodeId , shardId ),
210+ format ("[%s]%s: failed to execute search request for task [%d] " , nodeId , shardId , taskId ),
209211 IllegalStateException .class ,
210212 exceptionMessage
211213 )
@@ -224,7 +226,7 @@ public void onFailure(Exception e) {
224226 }
225227 };
226228 IllegalStateException e = new IllegalStateException (exceptionMessage ); // 500-level exception
227- listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), nodeId , shardId , threadPool );
229+ listener = maybeWrapListenerForStackTrace (listener , TransportVersion .current (), nodeId , shardId , taskId , threadPool );
228230 listener .onFailure (e );
229231 }
230232 }
0 commit comments