@@ -153,7 +153,7 @@ await StoreInHistoryAsync(
153153 /// <param name="executionContext">The context containing execution timing and metrics information.</param>
154154 /// <param name="result">The mutation result to finalize.</param>
155155 /// <returns>The mutation result with finalized execution metrics.</returns>
156- public async Task < MutationResult < TState > > FinalizeResultAsync < TState > (
156+ public Task < MutationResult < TState > > FinalizeResultAsync < TState > (
157157 MutationExecutionContext < TState > executionContext ,
158158 MutationResult < TState > result )
159159 {
@@ -162,12 +162,22 @@ public async Task<MutationResult<TState>> FinalizeResultAsync<TState>(
162162
163163 if ( executionContext . MetricsScope is not null )
164164 {
165- await _metricsCollector . RecordAsync (
166- executionContext . ExecutionId ,
167- executionContext . MetricsScope . Build ( ) ,
168- executionContext . CancellationToken ) . ConfigureAwait ( false ) ;
165+ return FinalizeWithMetricsAsync ( executionContext , result , totalElapsed ) ;
169166 }
170167
168+ return Task . FromResult ( result ) ;
169+ }
170+
171+ private async Task < MutationResult < TState > > FinalizeWithMetricsAsync < TState > (
172+ MutationExecutionContext < TState > executionContext ,
173+ MutationResult < TState > result ,
174+ TimeSpan totalElapsed )
175+ {
176+ await _metricsCollector . RecordAsync (
177+ executionContext . ExecutionId ,
178+ executionContext . MetricsScope ! . Build ( ) ,
179+ executionContext . CancellationToken ) . ConfigureAwait ( false ) ;
180+
171181 return result with
172182 {
173183 Metrics = result . Metrics with { ExecutionTime = totalElapsed }
0 commit comments