Exemple #1
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);
        }
        public void Implement_Via_Config_Expand_Test()
        {
            IReadOnlyDictionary <string, string> tags = new Dictionary <string, string>
            {
                ["operationName"]  = "X",
                ["operationGroup"] = "Y"
            };

            IMetricsReporterBuilder builder = new MetricsReporterBuilder(
                _activationFactory,
                _simpleConfig,
                _tagContext);

            _activationContext.PushFlow(CommonLayerOrService.WebApi, "Test-class", "test-method-a");
            _activationContext.PushToken("env", "qa");
            _tagContext.PushFlow(CommonLayerOrService.WebApi, "Test-class", "test-method-a");
            _tagContext.PushToken("env", "qa");
            _telemetryPushContext.PushToken("dry", "pushed-to-all");
            using (var reporter = builder.Build())
            {
                reporter.Count(ImportanceLevel.Low, tags);
            }
        }