@@ -130,7 +130,6 @@ public static boolean shouldBuildIndexRemotely(IndexSettings indexSettings, long
130
130
@ Override
131
131
public void buildAndWriteIndex (BuildIndexParams indexInfo ) throws IOException {
132
132
metrics .startRemoteIndexBuildMetrics (indexInfo );
133
- boolean success = false ;
134
133
try {
135
134
RepositoryContext repositoryContext = getRepositoryContext (indexInfo );
136
135
@@ -147,11 +146,10 @@ public void buildAndWriteIndex(BuildIndexParams indexInfo) throws IOException {
147
146
// 4. Download index file and write to indexOutput
148
147
readFromRepository (indexInfo , repositoryContext , remoteBuildStatusResponse );
149
148
150
- success = true ;
149
+ metrics . endRemoteIndexBuildMetrics ( true ) ;
151
150
} catch (Exception e ) {
151
+ metrics .endRemoteIndexBuildMetrics (false );
152
152
fallbackStrategy .buildAndWriteIndex (indexInfo );
153
- } finally {
154
- metrics .endRemoteIndexBuildMetrics (success );
155
153
}
156
154
}
157
155
@@ -172,7 +170,7 @@ private void writeToRepository(RepositoryContext repositoryContext, BuildIndexPa
172
170
);
173
171
success = true ;
174
172
} catch (InterruptedException | IOException e ) {
175
- log .debug ("Repository write failed for vector field [{}]" , indexInfo .getFieldName ());
173
+ log .debug ("Repository write failed for vector field [{}]" , indexInfo .getFieldName (), e );
176
174
throw e ;
177
175
} finally {
178
176
metrics .endRepositoryWriteMetrics (success );
@@ -200,7 +198,7 @@ private RemoteBuildResponse submitBuild(RepositoryContext repositoryContext, Bui
200
198
success = true ;
201
199
return remoteBuildResponse ;
202
200
} catch (IOException e ) {
203
- log .debug ("Submit vector build failed for vector field [{}]" , indexInfo .getFieldName ());
201
+ log .debug ("Submit vector build failed for vector field [{}]" , indexInfo .getFieldName (), e );
204
202
throw e ;
205
203
} finally {
206
204
metrics .endBuildRequestMetrics (success );
@@ -250,7 +248,7 @@ private void readFromRepository(
250
248
);
251
249
success = true ;
252
250
} catch (Exception e ) {
253
- log .debug ("Repository read failed for vector field [{}]" , indexInfo .getFieldName ());
251
+ log .debug ("Repository read failed for vector field [{}]" , indexInfo .getFieldName (), e );
254
252
throw e ;
255
253
} finally {
256
254
metrics .endRepositoryReadMetrics (success );
0 commit comments