private static void CollectOperationId(IAppBuilder app)
 {
     app.Use(new Func <AppFunc, AppFunc>(next => (async env =>
     {
         ActualOperationId = OperationIdContext.Get();
         await next.Invoke(env);
     })));
 }
示例#2
0
        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");
        }
示例#4
0
        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));
        }
示例#5
0
        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");
                });
            }
示例#7
0
        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);
        }
示例#8
0
            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();
 }
示例#11
0
 public OperationContextTelemetryInitializerTests()
 {
     OperationIdContext.Clear();
 }
示例#12
0
 public void Can_Set_Context()
 {
     OperationIdContext.Set("test");
     OperationIdContext.Get().Should().Be("test");
 }
示例#13
0
 public void Can_Clear_Context()
 {
     OperationIdContext.Create();
     OperationIdContext.Clear();
     OperationIdContext.Get().Should().BeNull();
 }
示例#14
0
 public void Can_Create_Context()
 {
     OperationIdContext.Create();
     OperationIdContext.Get().Should().NotBeNullOrEmpty();
 }
示例#15
0
 public OperationIdContextTests()
 {
     OperationIdContext.Clear();
 }