コード例 #1
0
 /// <summary>
 /// Registers X-Ray for the current object of  <see cref="HttpApplication"/> class. <see cref="HttpApplication.BeginRequest"/>,
 /// <see cref="HttpApplication.EndRequest"/>, <see cref="HttpApplication.Error"/> event handlers are registered with X-Ray function.
 /// </summary>
 /// <param name="httpApplication">Instance of  <see cref="HttpApplication"/> class.</param>
 /// <param name="segmentNamingStrategy">Instance of  <see cref="SegmentNamingStrategy"/> class. Defines segment naming strategy.</param>
 public static void RegisterXRay(HttpApplication httpApplication, SegmentNamingStrategy segmentNamingStrategy)
 {
     InitializeASPNET(segmentNamingStrategy);
     httpApplication.BeginRequest += ProcessHTTPRequest;
     httpApplication.EndRequest   += ProcessHTTPResponse;
     httpApplication.Error        += ProcessHTTPError;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayMiddleware" /> class.
 /// </summary>
 /// <param name="next">Instance of <see cref="RequestDelegate"/></param>
 /// <param name="segmentNamingStrategy">The segment naming strategy.</param>
 /// <param name="configuration">The instance of <see cref="IConfiguration" />.</param>
 /// <exception cref="ArgumentNullException">segmentNamingStrategy is null.</exception>
 public AWSXRayMiddleware(RequestDelegate next, SegmentNamingStrategy segmentNamingStrategy, IConfiguration configuration)
 {
     AWSXRayRecorder.InitializeInstance(configuration);
     _recorder             = AWSXRayRecorder.Instance;
     _next                 = next;
     SegmentNamingStrategy = segmentNamingStrategy ?? throw new ArgumentNullException("segmentNamingStrategy");
 }
コード例 #3
0
        private static void InitializeASPNET(SegmentNamingStrategy segmentNamingStrategy)
        {
            if (segmentNamingStrategy == null)
            {
                throw new ArgumentNullException("segmentNamingStrategy");
            }

            if (GetSegmentNamingStrategy() == null) // ensures only one time initialization among many HTTPApplication instances
            {
                SetSegmentNamingStrategy(segmentNamingStrategy);
            }
        }
コード例 #4
0
 /// <summary>
 /// Gets or sets the segment naming strategy.
 /// </summary>
 private static void SetSegmentNamingStrategy(SegmentNamingStrategy value)
 {
     rwLock.EnterWriteLock();
     try
     {
         // It is safe for this thread to write to the shared resource.
         segmentNamingStrategy = value;
     }
     finally
     {
         rwLock.ExitWriteLock(); // Ensure that the lock is released.
     }
 }
コード例 #5
0
 /// <summary>
 /// Adds <see cref="AWSXRayMiddleware"/> to the applicaion's request pipeline.
 /// </summary>
 /// <param name="builder">Instance of <see cref="IApplicationBuilder"/>.</param>
 /// <param name="segmentNamingStrategy"></param>
 /// <param name="configuration"></param>
 /// <returns>Instance of <see cref="IApplicationBuilder"/> instrumented with X-Ray middleware.</returns>
 public static IApplicationBuilder UseXRay(this IApplicationBuilder builder, SegmentNamingStrategy segmentNamingStrategy, IConfiguration configuration)
 {
     return(builder.UseMiddleware <AWSXRayMiddleware>(segmentNamingStrategy, configuration));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayMiddleware" /> class with a provided instance of <see cref="AWSXRayRecorder" />.
 /// </summary>
 /// <param name="next">Instance of <see cref="RequestDelegate"/></param>
 /// <param name="segmentNamingStrategy">The segment naming strategy.</param>
 /// <param name="recorder">The provided instance of <see cref="AWSXRayRecorder" />.</param>
 /// <exception cref="ArgumentNullException">segmentNamingStrategy is null.</exception>
 public AWSXRayMiddleware(RequestDelegate next, SegmentNamingStrategy segmentNamingStrategy, AWSXRayRecorder recorder)
 {
     _next = next;
     SegmentNamingStrategy = segmentNamingStrategy ?? throw new ArgumentNullException("segmentNamingStrategy");
     _recorder             = recorder ?? throw new ArgumentNullException("recorder");
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AWSXRayMiddleware" /> class with default instance <see cref="AWSXRayRecorder" />.
 /// </summary>
 /// <param name="next">Instance of <see cref="RequestDelegate"/></param>
 /// <param name="segmentNamingStrategy">The segment naming strategy.</param>
 /// <exception cref="ArgumentNullException">segmentNamingStrategy is null.</exception>
 public AWSXRayMiddleware(RequestDelegate next, SegmentNamingStrategy segmentNamingStrategy) : this(next, segmentNamingStrategy, AWSXRayRecorder.Instance)
 {
 }
コード例 #8
0
 private static void SetSegmentNamingStrategy(SegmentNamingStrategy value)
 {
     segmentNamingStrategy = value;
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TracingMessageHandler" /> class with a provided instance of <see cref="AWSXRayRecorder" />.
 /// </summary>
 /// <param name="segmentNamingStrategy">The segment naming strategy.</param>
 /// <param name="recorder">The provided instance of <see cref="AWSXRayRecorder" />.</param>
 /// <exception cref="System.ArgumentNullException">segmentNamingStrategy is null.</exception>
 public TracingMessageHandler(SegmentNamingStrategy segmentNamingStrategy, AWSXRayRecorder recorder)
 {
     SegmentNamingStrategy = segmentNamingStrategy ?? throw new ArgumentNullException("segmentNamingStrategy");
     _recorder             = recorder ?? throw new ArgumentNullException("recorder");
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TracingMessageHandler" /> class with default instance <see cref="AWSXRayRecorder" />.
 /// </summary>
 /// <param name="segmentNamingStrategy">The segment naming strategy.</param>
 /// <exception cref="System.ArgumentNullException">segmentNamingStrategy is null.</exception>
 public TracingMessageHandler(SegmentNamingStrategy segmentNamingStrategy)
     : this(segmentNamingStrategy, AWSXRayRecorder.Instance)
 {
 }
コード例 #11
0
 /// <summary>
 /// Set up segment naming strategy
 /// </summary>
 internal static void SetSegmentNamingStrategy(SegmentNamingStrategy segmentNamingStrategy)
 {
     SegmentNamingStrategy = segmentNamingStrategy ?? throw new ArgumentNullException("segmentNamingStrategy");
 }