private static void CollectOperationId(IAppBuilder app) { app.Use(new Func <AppFunc, AppFunc>(next => (async env => { ActualOperationId = OperationIdContext.Get(); await next.Invoke(env); }))); }
public void Can_Set_Operation_Id_On_Telemetry() { var telemetry = new TraceTelemetry(); var sut = new OperationIdTelemetryInitializer(); OperationIdContext.Create(); sut.Initialize(telemetry); telemetry.Context.Operation.Id.Should().Be(OperationIdContext.Get()); }
public async Task Should_Not_Substitue_Existing_Operation_Id_If_Context_Contains_Null() { OperationIdContext.Set("test"); var context = new MockOwinContext(); var collector = new OperationIdCollectingMiddleware(); var sut = new RestoreOperationIdContextMiddleware(collector); await sut.Invoke(context); collector.OperationIdFromAmbientContext.Should().Be("test"); }
public override Task Invoke(IOwinContext context) { OperationIdFromEnvironment = context.Get <string>(Consts.OperationIdContextKey); OperationIdFromAmbientContext = OperationIdContext.Get(); if (Next == null) { return(Task.FromResult <object>(null)); } return(Next.Invoke(context)); }
public async Task Can_Clean_Context() { var context = new MockOwinContext(); var sut = new OperationIdContextMiddleware( new NoopMiddleware(), new OperationIdContextMiddlewareConfiguration()); await sut.Invoke(context); context.Get <string>(Consts.OperationIdContextKey).Should().BeNull(); OperationIdContext.Get().Should().BeNull(); }
private static void ServeRequest(IAppBuilder app) { app.Run(async context => { ActualOperationId = OperationIdContext.Get(); using (var client = new HttpClient()) await client.GetAsync("http://google.com"); context.Response.StatusCode = 200; context.Response.Write("ok"); }); }
public async Task Operation_Context_Flows_With_Async() { OperationIdContext.Create(); var expected = OperationIdContext.Get(); using (var client = new HttpClient()) await client.GetAsync("http://google.com"); var actual = OperationIdContext.Get(); actual.Should().NotBeNullOrEmpty(); actual.Should().Be(expected); }
private static void ServeRequest(IAppBuilder app) { app.Run(async context => { ActualOperationId = OperationIdContext.Get(); if (context.Request.Path.Value.EndsWith("exception")) { throw new OlabogaException(); } else { using (var client = new HttpClient()) await client.GetAsync("http://google.com").ConfigureAwait(false); context.Response.StatusCode = 200; context.Response.Write("ok"); } }); }
public void Dispose() { OperationIdContext.Clear(); }
public RestoreOperationIdContextMiddlewareTests() { OperationIdContext.Clear(); }
public OperationContextTelemetryInitializerTests() { OperationIdContext.Clear(); }
public void Can_Set_Context() { OperationIdContext.Set("test"); OperationIdContext.Get().Should().Be("test"); }
public void Can_Clear_Context() { OperationIdContext.Create(); OperationIdContext.Clear(); OperationIdContext.Get().Should().BeNull(); }
public void Can_Create_Context() { OperationIdContext.Create(); OperationIdContext.Get().Should().NotBeNullOrEmpty(); }
public OperationIdContextTests() { OperationIdContext.Clear(); }