public void when_instrumenting_response_statsd_message_should_be_sent()
        {
            var port = int.Parse(ConfigurationManager.AppSettings["StatsD.Port"]);

            var actionContext = new HttpActionContext()
            {
                ActionDescriptor = new FakeActionDescriptor()
            };

            var httpActionExecutedContext = new HttpActionExecutedContext
            {
                ActionContext = actionContext,
                Response      = new HttpResponseMessage()
            };

            var task = Task.Factory.StartNew(() => ListenForUdpOnStatsDPort(port));

            httpActionExecutedContext.InstrumentResponse();

            task.Wait();

            var result = System.Text.Encoding.UTF8.GetString(task.Result);

            result.Should().Contain("ApplicationName.ActionName.200:1|c");
        }
Esempio n. 2
0
        public override void OnException(HttpActionExecutedContext context)
        {
            context.InstrumentResponse();

            base.OnException(context);
        }
        public override Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
        {
            actionExecutedContext.InstrumentResponse();

            return(base.OnActionExecutedAsync(actionExecutedContext, cancellationToken));
        }