File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
server/src/main/java/org/elasticsearch Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,10 @@ public Stage getStage() {
191191 return stage .get ();
192192 }
193193
194+ public long getTotalTime () {
195+ return totalTime ;
196+ }
197+
194198 public void addAbortListener (ActionListener <AbortStatus > listener ) {
195199 abortListeners .addListener (listener );
196200 }
Original file line number Diff line number Diff line change @@ -3214,13 +3214,8 @@ public void snapshotShard(SnapshotShardContext context) {
32143214 }
32153215
32163216 private void doSnapshotShard (SnapshotShardContext context ) {
3217- final long startTimeInMillis = threadPool .absoluteTimeInMillis ();
32183217 blobStoreSnapshotMetrics .shardSnapshotStarted ();
3219- context .addListener (
3220- ActionListener .running (
3221- () -> blobStoreSnapshotMetrics .shardSnapshotCompleted (threadPool .absoluteTimeInMillis () - startTimeInMillis )
3222- )
3223- );
3218+ context .addListener (ActionListener .running (() -> blobStoreSnapshotMetrics .shardSnapshotCompleted (context .status ().getTotalTime ())));
32243219 if (isReadOnly ()) {
32253220 context .onFailure (new RepositoryException (metadata .name (), "cannot snapshot shard on a readonly repository" ));
32263221 return ;
@@ -3230,6 +3225,7 @@ private void doSnapshotShard(SnapshotShardContext context) {
32303225 final SnapshotId snapshotId = context .snapshotId ();
32313226 final IndexShardSnapshotStatus snapshotStatus = context .status ();
32323227 snapshotStatus .updateStatusDescription ("snapshot task runner: setting up shard snapshot" );
3228+ final long startTime = threadPool .absoluteTimeInMillis ();
32333229 try {
32343230 final ShardGeneration generation = snapshotStatus .generation ();
32353231 final BlobContainer shardContainer = shardContainer (context .indexId (), shardId );
@@ -3351,7 +3347,7 @@ private void doSnapshotShard(SnapshotShardContext context) {
33513347
33523348 snapshotStatus .updateStatusDescription ("snapshot task runner: starting shard snapshot" );
33533349 snapshotStatus .moveToStarted (
3354- startTimeInMillis ,
3350+ startTime ,
33553351 indexIncrementalFileCount ,
33563352 indexTotalNumberOfFiles ,
33573353 indexIncrementalSize ,
Original file line number Diff line number Diff line change @@ -73,7 +73,9 @@ public void shardSnapshotStarted() {
7373
7474 public void shardSnapshotCompleted (long durationInMillis ) {
7575 snapshotMetrics .snapshotsShardsCompletedCounter ().increment ();
76- snapshotMetrics .snapshotShardsDurationHistogram ().record (durationInMillis / 1_000f );
76+ if (durationInMillis > 0 ) {
77+ snapshotMetrics .snapshotShardsDurationHistogram ().record (durationInMillis / 1_000f );
78+ }
7779 numberOfShardSnapshotsCompleted .inc ();
7880 shardSnapshotsInProgress .dec ();
7981 }
You can’t perform that action at this time.
0 commit comments