Exemplo n.º 1
0
        public void IMetricsReporter_Test()
        {
            //IMetricsReporter _reporter =
            //    _reporterFactory.ForContext<ApiDesignTestsB>();
            IMetricsReporter _reporter =
                _reporterFactory.Build();
            IReadOnlyDictionary <string, string> tags = new Dictionary <string, string>
            {
                ["Active"]    = "true",
                ["Sentiment"] = "happy"
            };

            _reporter.Count();
            _reporter.Count(ImportanceLevel.High);
            _reporter.Count(ImportanceLevel.High, tags);

            using (_reporter.Duration())
            {
            }
        }
Exemplo n.º 2
0
        public override void OnActionExecuting(
            HttpActionContext actionContext)
        {
            //actionContext.RequestContext.Principal.Identity.Name
            var request = actionContext.Request;
            string actionName = request.GetActionDescriptor().ActionName;


            //InfluxManager.Default.TryAddTagRange(tags);
            _tagContext.PushToken("method", request.Method.Method);
            _tagContext.PushToken("uri", request.Method.Method);
            _telemetryPushContext.PushToken("request-version", request.Method.Method);
            _activationContext.PushFlow(CommonLayerOrService.WebApi, "Unknown", actionName);

            _reporter.Count(ImportanceLevel.Normal);
            var operation = _reporter.Duration(ImportanceLevel.Normal);
            actionContext.ActionArguments.Add("end-action", operation);
        }