Documentation Coverage Report
Current view: top level - Cqrs/Configuration - ITelemetryHelperExtensions.cs Hit Total Coverage
Version: 2.2 Artefacts: 5 5 100.0 %
Date: 2017-09-22

          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             :         /// <summary>
       9             :         /// A collection of extension methods for <see cref="ITelemetryHelper"/>.
      10             :         /// </summary>
      11             :         public static class ITelemetryHelperExtensions
      12           1 :         {
      13             :                 /// <summary>
      14             :                 /// Send information about a request handled by the application.
      15             :                 /// </summary>
      16             :                 /// <param name="telemetryHelper">The <see cref="ITelemetryHelper"/> being extended.s</param>
      17             :                 /// <param name="name">The request name.</param>
      18             :                 /// <param name="token">The token with user identifiable information.</param>
      19             :                 /// <param name="startTime">The time when the page was requested.</param>
      20             :                 /// <param name="duration">The time taken by the application to handle the request.</param>
      21             :                 /// <param name="responseCode">The response status code.</param>
      22             :                 /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
      23             :                 /// <param name="properties">Named string values you can use to search and classify events.</param>
      24           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)
      25             :                         where TAuthenticationToken : ISingleSignOnToken
      26             :                 {
      27             :                         TrackRequest(telemetryHelper, name, token == null ? null : token.Serialise(), startTime, duration, responseCode, wasSuccessfull, properties);
      28             :                 }
      29             : 
      30             :                 /// <summary>
      31             :                 /// Send information about a request handled by the application.
      32             :                 /// </summary>
      33             :                 /// <param name="telemetryHelper">The <see cref="ITelemetryHelper"/> being extended.s</param>
      34             :                 /// <param name="name">The request name.</param>
      35             :                 /// <param name="token">The token with user identifiable information.</param>
      36             :                 /// <param name="startTime">The time when the page was requested.</param>
      37             :                 /// <param name="duration">The time taken by the application to handle the request.</param>
      38             :                 /// <param name="responseCode">The response status code.</param>
      39             :                 /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
      40             :                 /// <param name="properties">Named string values you can use to search and classify events.</param>
      41           1 :                 public static void TrackRequest(this ITelemetryHelper telemetryHelper, string name, Guid? token, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool wasSuccessfull, IDictionary<string, string> properties = null)
      42             :                 {
      43             :                         TrackRequest(telemetryHelper, name, token == null ? null : token.Value.ToString("N"), startTime, duration, responseCode, wasSuccessfull, properties);
      44             :                 }
      45             : 
      46             :                 /// <summary>
      47             :                 /// Send information about a request handled by the application.
      48             :                 /// </summary>
      49             :                 /// <param name="telemetryHelper">The <see cref="ITelemetryHelper"/> being extended.s</param>
      50             :                 /// <param name="name">The request name.</param>
      51             :                 /// <param name="token">The token with user identifiable information.</param>
      52             :                 /// <param name="startTime">The time when the page was requested.</param>
      53             :                 /// <param name="duration">The time taken by the application to handle the request.</param>
      54             :                 /// <param name="responseCode">The response status code.</param>
      55             :                 /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
      56             :                 /// <param name="properties">Named string values you can use to search and classify events.</param>
      57           1 :                 public static void TrackRequest(this ITelemetryHelper telemetryHelper, string name, int? token, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool wasSuccessfull, IDictionary<string, string> properties = null)
      58             :                 {
      59             :                         TrackRequest(telemetryHelper, name, token == null ? null : token.Value.ToString(), startTime, duration, responseCode, wasSuccessfull, properties);
      60             :                 }
      61             : 
      62             :                 /// <summary>
      63             :                 /// Send information about a request handled by the application.
      64             :                 /// </summary>
      65             :                 /// <param name="telemetryHelper">The <see cref="ITelemetryHelper"/> being extended.s</param>
      66             :                 /// <param name="name">The request name.</param>
      67             :                 /// <param name="token">The token with user identifiable information.</param>
      68             :                 /// <param name="startTime">The time when the page was requested.</param>
      69             :                 /// <param name="duration">The time taken by the application to handle the request.</param>
      70             :                 /// <param name="responseCode">The response status code.</param>
      71             :                 /// <param name="wasSuccessfull">True if the request was handled successfully by the application.</param>
      72             :                 /// <param name="properties">Named string values you can use to search and classify events.</param>
      73           1 :                 public static void TrackRequest(this ITelemetryHelper telemetryHelper, string name, string token, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool wasSuccessfull, IDictionary<string, string> properties = null)
      74             :                 {
      75             :                         Uri url;
      76             :                         try
      77             :                         {
      78             :                                 url = new Uri(string.Format("cqrs://{0}", name));
      79             :                         }
      80             :                         catch
      81             :                         {
      82             :                                 url = null;
      83             :                         }
      84             : 
      85             :                         telemetryHelper.TrackRequest(name, url, token, startTime, duration, responseCode, wasSuccessfull, properties);
      86             :                 }
      87             :         }
      88             : }

Generated by: LCOV version 1.10