public ApiCallMetricBuilder WithMiddlewareTime(ApiMetricRequestContext context) { // TODO: [TESTS] (ApiCallMetricBuilder.WithMiddlewareTime) Add tests if (context?.MiddlewareStartTime == null || !context.MiddlewareEndTime.HasValue) { return(this); } if (context.MiddlewareStartTime.Value > context.MiddlewareEndTime.Value) { return(this); } _builder.WithField( Fields.MiddlewareTime, (context.MiddlewareEndTime.Value - context.MiddlewareStartTime.Value).TotalMilliseconds ); return(this); }
public void Dispose() { _builder.WithField(FieldName, _stopwatch.ElapsedMilliseconds); }