Show / Hide Table of Contents

Class ServerTimingExtensions

Extensions for easier logging of server timing performance metric.

Inheritance
System.Object
ServerTimingExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Lib.ServerTiming
Assembly: Lib.ServerTiming.Abstractions.dll
Syntax
public static class ServerTimingExtensions

Methods

AddMetric(IServerTiming, Decimal, String, String, String, Int32)

Add a timed metric to the timing, if present.

Declaration
public static void AddMetric(this IServerTiming serverTiming, decimal duration, string metricName = null, string functionName = null, string filePath = null, int lineNumber = 0)
Parameters
Type Name Description
IServerTiming serverTiming

The IServerTiming to add metric to.

System.Decimal duration

The duration to log in ms.

System.String metricName

The name of the metric to log.

System.String functionName

Optional, populated compile-time with the name of the calling function

System.String filePath

Optional, populated compile-time with the path to the calling file

System.Int32 lineNumber

Optional, populated compile-time with line number in the calling file

AddMetric(IServerTiming, String, String, String, String, Int32)

Add an untimed metric to the timing, if present.

Declaration
public static void AddMetric(this IServerTiming serverTiming, string metricName = null, string description = null, string functionName = null, string filePath = null, int lineNumber = 0)
Parameters
Type Name Description
IServerTiming serverTiming

The IServerTiming to add metric to.

System.String metricName

The name of the metric to log.

System.String description

The description of the metric

System.String functionName

Optional, populated compile-time with the name of the calling function

System.String filePath

Optional, populated compile-time with the path to the calling file

System.Int32 lineNumber

Optional, populated compile-time with line number in the calling file

TimeAction(IServerTiming, String, String, String, Int32)

Time a block of code.

Declaration
public static IDisposable TimeAction(this IServerTiming serverTiming, string metricName = null, string functionName = null, string filePath = null, int lineNumber = 0)
Parameters
Type Name Description
IServerTiming serverTiming

The IServerTiming to add metric to.

System.String metricName

Optional, metric name, if passed will override any caller name.

System.String functionName

Optional, populated compile-time with the name of the calling function.

System.String filePath

Optional, populated compile-time with the path to the calling file.

System.Int32 lineNumber

Optional, populated compile-time with line number in the calling file.

Returns
Type Description
System.IDisposable

TimeTask(IServerTiming, Task, String, String, String, Int32)

Time an async task.

Declaration
public static async Task TimeTask(this IServerTiming serverTiming, Task task, string metricName = null, string functionName = null, string filePath = null, int lineNumber = 0)
Parameters
Type Name Description
IServerTiming serverTiming

The IServerTiming to add metric to.

System.Threading.Tasks.Task task

The System.Threading.Tasks.Task to time.

System.String metricName

Optional, metric name, if passed will override any caller name.

System.String functionName

Optional, populated compile-time with the name of the calling function.

System.String filePath

Optional, populated compile-time with the path to the calling file.

System.Int32 lineNumber

Optional, populated compile-time with line number in the calling file.

Returns
Type Description
System.Threading.Tasks.Task

TimeTask<T>(IServerTiming, Task<T>, String, String, String, Int32)

Time an async task.

Declaration
public static async Task<T> TimeTask<T>(this IServerTiming serverTiming, Task<T> task, string metricName = null, string functionName = null, string filePath = null, int lineNumber = 0)
Parameters
Type Name Description
IServerTiming serverTiming

The IServerTiming to add metric to.

System.Threading.Tasks.Task<T> task

The System.Threading.Tasks.Task to time.

System.String metricName

Optional, metric name, if passed will override any caller name.

System.String functionName

Optional, populated compile-time with the name of the calling function.

System.String filePath

Optional, populated compile-time with the path to the calling file.

System.Int32 lineNumber

Optional, populated compile-time with line number in the calling file.

Returns
Type Description
System.Threading.Tasks.Task<T>
Type Parameters
Name Description
T

Type of the task.

Back to top Copyright © 2017 - 2023 Tomasz Pęczek