public ApiCallMetricBuilder WithApiMetricRequestContext(ApiMetricRequestContext context) { // TODO: [TESTS] (ApiCallMetricBuilder.WithApiMetricRequestContext) Add tests if (context == null) { return(this); } _builder .WithField(Fields.RequestContentLength, context.RequestContentLength) .WithField(Fields.RequestCookieCount, context.RequestCookieCount) .WithField(Fields.RequestHeaderCount, context.RequestHeaderCount) .WithField(Fields.RequestPort, context.RequestPort) .WithField(Fields.ResponseContentLength, context.ResponseContentLength) .WithField(Fields.ResponseHeaderCount, context.ResponseHeaderCount); return(WithRequestRunTime(context) .WithActionTime(context) .WithResultTime(context) .WithMiddlewareTime(context) .WithExceptionTime(context) .WithController(context.Controller) .WithAction(context.Action) .WithExceptionName(context.ExceptionName) .WithRequestMethod(context.RequestMethod) .WithRequestContentType(context.RequestContentType) .WithRequestProtocol(context.RequestProtocol) .WithRequestScheme(context.RequestScheme) .WithRequestHost(context.RequestHost) .WithResponseCode(context.ResponseCode) .WithResponseContentType(context.RequestContentType)); }
public ApiCallMetricBuilder WithRequestRunTime(ApiMetricRequestContext context) { // TODO: [TESTS] (ApiCallMetricBuilder.WithRequestRunTime) Add tests if (context?.RequestStartTime == null || !context.RequestEndTime.HasValue) { return(this); } if (context.RequestStartTime > context.RequestEndTime) { return(this); } _builder.WithField( CoreMetricField.Value, (context.RequestEndTime.Value - context.RequestStartTime.Value).TotalMilliseconds ); return(this); }
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); }
// Builder Methods public ApiCallMetricBuilder WithActionTime(ApiMetricRequestContext context) { // TODO: [TESTS] (ApiCallMetricBuilder.WithActionTime) Add tests if (context?.ActionStartTime == null || !context.ActionEndTime.HasValue) { return(this); } if (context.ActionStartTime.Value > context.ActionEndTime.Value) { return(this); } _builder.WithTag(Tags.RanAction, true) .WithField( Fields.ActionTime, (context.ActionEndTime.Value - context.ActionStartTime.Value).TotalMilliseconds ); return(this); }
public ApiCallMetricBuilder WithExceptionTime(ApiMetricRequestContext context) { // TODO: [TESTS] (ApiCallMetricBuilder.WithExceptionTime) Add tests if (context?.ExThrownTime == null || !context.RequestStartTime.HasValue) { return(this); } if (context.RequestStartTime.Value > context.ExThrownTime.Value) { return(this); } _builder.WithTag(CoreMetricTag.HasException, true) .WithField( Fields.ExceptionTime, (context.ExThrownTime.Value - context.RequestStartTime.Value).TotalMilliseconds ); return(this); }
public ApiCallMetricBuilder(ApiMetricRequestContext metricContext) : this() { // TODO: [TESTS] (ApiCallMetricBuilder.ApiCallMetricBuilder) Add tests WithApiMetricRequestContext(metricContext); }