Line data Source code
1 : using System;
2 : using System.Collections.Generic;
3 : using cdmdotnet.Logging;
4 : using Cqrs.Authentication;
5 :
6 : namespace Cqrs.Configuration
7 : {
8 : public static class ITelemetryHelperExtensions
9 0 : {
10 : /// <summary>
11 : /// Send information about a request handled by the application.
12 : /// </summary>
13 : /// <param name="telemetryHelper">The <see cref="ITelemetryHelper"/> being extended.s</param>
14 : /// <param name="name">The request name.</param>
15 : /// <param name="token">The token with user identifiable information.</param>
16 : /// <param name="startTime">The time when the page was requested.</param>
17 : /// <param name="duration">The time taken by the application to handle the request.</param>
18 : /// <param name="responseCode">The response status code.</param>
19 : /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
20 : /// <param name="properties">Named string values you can use to search and classify events.</param>
21 1 : public static void TrackRequest<TAuthenticationToken>(this ITelemetryHelper telemetryHelper, string name, TAuthenticationToken token, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool wasSuccessfull, IDictionary<string, string> properties = null)
22 : where TAuthenticationToken : ISingleSignOnToken
23 : {
24 : Uri url;
25 : try
26 : {
27 : url = new Uri(string.Format("cqrs://{0}", name));
28 : }
29 : catch
30 : {
31 : url = null;
32 : }
33 :
34 : telemetryHelper.TrackRequest(name, url, token == null ? null : token.Serialise(), startTime, duration, responseCode, wasSuccessfull, properties);
35 : }
36 : }
37 : }
|