/// <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; }
/// <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"); }
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); } }
/// <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. } }
/// <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)); }
/// <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"); }
/// <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) { }
private static void SetSegmentNamingStrategy(SegmentNamingStrategy value) { segmentNamingStrategy = value; }
/// <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"); }
/// <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) { }
/// <summary> /// Set up segment naming strategy /// </summary> internal static void SetSegmentNamingStrategy(SegmentNamingStrategy segmentNamingStrategy) { SegmentNamingStrategy = segmentNamingStrategy ?? throw new ArgumentNullException("segmentNamingStrategy"); }