public void Start(IApmContext apmContext, ApmWebApiStartInformation apmWebApiStartInformation)
        {
            var key = string.Empty;

            object counterProperty;

            if (!apmContext.TryGetValue(AverageTimeTakenMsCounter, out counterProperty))
            {
                var categoryName = PerformanceCounterApmApiFilterAttribute.GetCategoryName(apmWebApiStartInformation.ApplicationName);
                var counterName  = GetCounterName(apmWebApiStartInformation.MethodIdentifier);

                var counter = Counters.GetOrAdd(key, s => GetCounter(categoryName, _instanceName, counterName));
                apmContext.Add(AverageTimeTakenMsCounter, counter);
            }

            object baseCounterProperty;

            if (!apmContext.TryGetValue(AverageTimeTakenMsBaseCounter, out baseCounterProperty))
            {
                var categoryName = PerformanceCounterApmApiFilterAttribute.GetCategoryName(apmWebApiStartInformation.ApplicationName);
                var counterName  = GetBaseCounterName(apmWebApiStartInformation.MethodIdentifier);
                var baseCounter  = BaseCounters.GetOrAdd(key, s => GetBaseCounter(categoryName, _instanceName, counterName));
                apmContext.Add(AverageTimeTakenMsBaseCounter, baseCounter);
            }
        }
        public void Start(IApmContext apmContext, ApmMethodHandlerStartInformation apmMethodHandlerStartInformation)
        {
            var key = string.Empty;

            object counterProperty;

            if (!apmContext.TryGetValue(TotalCountCounter, out counterProperty))
            {
                var categoryName = PerformanceCounterApmMethodHandler.GetCategoryName(apmMethodHandlerStartInformation.ApplicationName);
                var counterName  = GetCounterName(apmMethodHandlerStartInformation.MethodIdentifier);
                var counter      = Counters.GetOrAdd(key, s => GetCounter(categoryName, _instanceName, counterName));
                apmContext.Add(TotalCountCounter, counter);
            }
        }
        public void Start(IApmContext apmContext, ApmHttpClientStartInformation apmHttpClientStartInformation)
        {
            var key = string.Empty;

            object counterProperty;

            if (!apmContext.TryGetValue(LastOperationExecutionTimeMsCounter, out counterProperty))
            {
                var categoryName = PerformanceCounterApmHttpClientDelegatingHandler.GetCategoryName(apmHttpClientStartInformation.ApplicationName);
                var counterName  = GetCounterName(apmHttpClientStartInformation.MethodIdentifier);
                var counter      = Counters.GetOrAdd(key, s => GetCounter(categoryName, _instanceName, counterName));
                apmContext.Add(LastOperationExecutionTimeMsCounter, counter);
            }
        }
Beispiel #4
0
        public void WhenAddingTrackingInformationWithNoPreviousTracing()
        {
            _apmContext.Add(Constants.ClientNamePropertyKey, "TestClient");

            ApmContext.SetTracing(_apmContext);

            var traceId = (string)_apmContext[Constants.TraceIdHeaderKey];

            var regex = new Regex("TestClient=[^;]+");

            Assert.True(regex.IsMatch(traceId));
        }