Inheritance: IRequestLog, ISubject, IChainExecutionLog
        public void map_from_execution_when_the_request_was_redirected()
        {
            var log = new ChainExecutionLog();
            log.Request.Add(OwinConstants.ResponseStatusCodeKey, 302);
            log.Request.ResponseHeaders().Add(HttpResponseHeaders.ContentType, new[] { "text/plain" });
            log.Request.ResponseHeaders().Add(HttpResponseHeaders.Location, new[] { "/new/place" });

            var request = new OwinHttpRequest(log.Request);
            request.HttpMethod("GET");
            request.FullUrl("http://server/foo");

            log.MarkFinished();

            var summary = new HttpRequestSummary(log);

            summary.id.ShouldBe(log.Id.ToString());
            summary.time.ShouldBe(log.Time.ToHttpDateString());
            summary.url.ShouldBe("/foo");
            summary.method.ShouldBe("GET");
            summary.status.ShouldBe(302);
            summary.contentType.ShouldBe("text/plain");
            summary.duration.ShouldBe(log.ExecutionTime);

            summary.description.ShouldBe("/new/place");
        }
 public bool IsWarning(ChainExecutionLog report)
 {
     var max = MaxTime;
     var avg = Average;
     var p1 = 1 - report.ExecutionTime / max;
     var p2 = 1 - (double)avg / max;
     return (p2 - p1) > 0.25;
 }
        public ProductionDiagnosticEnvelopeContext(ILogger logger, ISystemTime systemTime, IChainInvoker invoker, IOutgoingSender outgoing, IHandlerPipeline pipeline, Envelope envelope, IExecutionLogger executionLogger)
            : base(logger, systemTime, invoker, outgoing, pipeline)
        {
            _envelope = envelope;
            _executionLogger = executionLogger;
            _log = new ChainExecutionLog();

            _envelope.Log = _log;
        }
        public bool IsWarning(ChainExecutionLog report)
        {
            var max = MaxTime;
            var avg = Average;
            var p1  = 1 - report.ExecutionTime / max;
            var p2  = 1 - (double)avg / max;

            return((p2 - p1) > 0.25);
        }
        public void Store(ChainExecutionLog log)
        {
            log.SessionTag = CurrentSessionTag;

            _reports.Enqueue(log);
            while (_reports.Count > _settings.MaxRequests)
            {
                ChainExecutionLog _;
                _reports.TryDequeue(out _);
            }
        }
        public void Store(ChainExecutionLog log)
        {
            log.SessionTag = CurrentSessionTag;

            _reports.Enqueue(log);
            while (_reports.Count > _settings.MaxRequests)
            {
                ChainExecutionLog _;
                _reports.TryDequeue(out _);
            }
        }
        public void set_the_chain_execution_log()
        {
            var source = new Dictionary<string, object>();
            source.Log().ShouldBeNull();

            var log = new ChainExecutionLog();

            source.Log(log);

            source.RequestId().ShouldBe(log.Id.ToString());

            source.Log().ShouldBeSameAs(log);
        }
        public void register_the_execution_log_if_it_exists()
        {
            var log = new ChainExecutionLog();
            var environment = new Dictionary<string, object>();
            environment.Log(log);

            var routeData = new RouteData();

            var arguments = new OwinServiceArguments(routeData, environment);

            arguments.Get<IChainExecutionLog>()
                .ShouldBeSameAs(log);
        }
        public Dictionary<string, object> get_request_Id(ChainExecutionLog query)
        {
            var log = _history.Find(query.Id);

            var dict = new Dictionary<string, object>();

            if (log != null)
            {
                dict.Add("log", log.ToDictionary());
                if (log.RootChain != null) dict.Add("type", log.RootChain.GetType().Name);
            }

            return dict;
        }
        public HttpRequestSummary(ChainExecutionLog log) : this()
        {
            var request = new OwinHttpRequest(log.Request);
            var response = new OwinHttpResponse(log.Request);

            id = log.Id.ToString();
            time = log.Time.ToHttpDateString();
            url = request.RawUrl();
            method = request.HttpMethod();
            status = response.StatusCode;
            description = response.StatusDescription;
            if (status == 302)
            {
                // TODO -- write a helper for location
                description = response.HeaderValueFor(HttpResponseHeaders.Location).SingleOrDefault();
            }

            contentType = response.ContentType();
            duration = log.ExecutionTime;
        }
        public void map_from_execution_log_happy_path()
        {
            var log = new ChainExecutionLog();
            log.Request.Add(OwinConstants.ResponseStatusCodeKey, 200);
            log.Request.ResponseHeaders().Add(HttpResponseHeaders.ContentType, new []{"text/plain"});

            var request = new OwinHttpRequest(log.Request);
            request.HttpMethod("POST");
            request.FullUrl("http://server/foo");

            log.MarkFinished();

            var summary = new HttpRequestSummary(log);

            summary.id.ShouldBe(log.Id.ToString());
            summary.time.ShouldBe(log.Time.ToHttpDateString());
            summary.url.ShouldBe("/foo");
            summary.method.ShouldBe("POST");
            summary.status.ShouldBe(200);
            summary.contentType.ShouldBe("text/plain");
            summary.duration.ShouldBe(log.ExecutionTime);
        }
 public void Enqueue(ChainExecutionLog log)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             log.RootChain?.Performance?.Read(log);
         }
         catch (Exception ex)
         {
             try
             {
                 _logger.Info("Failed while updating performance history: " + ex);
             }
             catch (Exception e)
             {
                 // Yeah, I know, but don't allow an exception here to *ever* bubble up
                 Console.WriteLine(e);
             }
         }
     });
 }
        public void Enqueue(ChainExecutionLog log)
        {
            Task.Factory.StartNew(() =>
            {
                try
                {
                    log.RootChain?.Performance?.Read(log);
                }
                catch (Exception ex)
                {
                    try
                    {
                        _logger.Info("Failed while updating performance history: " + ex);
                    }
                    catch (Exception e)
                    {
                        // Yeah, I know, but don't allow an exception here to *ever* bubble up
                        Console.WriteLine(e);
                    }
                }
            });

        }
 public void Enqueue(ChainExecutionLog log)
 {
     _collection.Add(log);
 }
        public void read_stores_the_last_execution()
        {
            var history = new PerformanceHistory();
            var log1 = new ChainExecutionLog();
            var log2 = new ChainExecutionLog();

            history.Read(log1);
            history.LastExecution.ShouldBeTheSameAs(log1);

            history.Read(log2);
            history.LastExecution.ShouldBeTheSameAs(log2);
        }
        public Func<IDictionary<string, object>, Task> WrapAppFunc(FubuRuntime runtime,
            Func<IDictionary<string, object>, Task> inner)
        {
            if (TraceLevel == TraceLevel.None) return inner;

            var logger = runtime.Get<IExecutionLogger>();

            return env =>
            {
                var log = new ChainExecutionLog();
                env.Log(log);

                return inner(env).ContinueWith(t =>
                {
                    if (t.IsFaulted)
                    {
                        t.Exception.Flatten().InnerExceptions.Each(log.LogException);
                    }

                    log.MarkFinished();

                    if (log.RootChain != null && ApplyTracing.ShouldApply(log.RootChain))
                    {
                        logger.Record(log, env);
                    }
                });
            };
        }
        public void record_headers_from_http_request()
        {
            var dict = new Dictionary<string, object>();
            dict.Add("owin.RequestHeaders", 1);
            dict.Add("owin.RequestMethod", 2);
            dict.Add("owin.RequestPath", 3);
            dict.Add("owin.RequestPathBase", 4);
            dict.Add("owin.RequestProtocol", 5);
            dict.Add("owin.RequestQueryString", 6);
            dict.Add("owin.RequestScheme", 7);
            dict.Add("owin.ResponseHeaders", 8);
            dict.Add("owin.ResponseStatusCode", 9);
            dict.Add("owin.ResponseReasonPhrase", 10);

            var log = new ChainExecutionLog();

            log.RecordHeaders(dict);

            log.Request["owin.RequestHeaders"].ShouldBe(1);
            log.Request["owin.RequestMethod"].ShouldBe(2);
            log.Request["owin.RequestPath"].ShouldBe(3);
            log.Request["owin.RequestPathBase"].ShouldBe(4);
            log.Request["owin.RequestProtocol"].ShouldBe(5);
            log.Request["owin.RequestQueryString"].ShouldBe(6);
            log.Request["owin.RequestScheme"].ShouldBe(7);
            log.Request["owin.ResponseHeaders"].ShouldBe(8);
            log.Request["owin.ResponseStatusCode"].ShouldBe(9);
            log.Request["owin.ResponseReasonPhrase"].ShouldBe(10);
        }
        public void record_envelope_headers()
        {
            var envelope = new Envelope();
            envelope.Headers["foo"] = "bar";

            var log = new ChainExecutionLog();
            log.RecordHeaders(envelope);

            log.Request["headers"].As<IDictionary<string, string>>()["foo"]
                .ShouldBe("bar");
        }
Beispiel #19
0
 public void Append(ChainExecutionLog[] requests)
 {
     _logs.AddRange(requests.Where(x => x.RootChain is RoutedChain));
 }