Example #1
0
 /// <summary>
 /// Push execution flow information.
 /// this information can be match by the activation rules.
 /// </summary>
 /// <typeparam name="T">Use to represent name of the layer or service class</typeparam>
 /// <param name="layerOrService">The layer or service.</param>
 /// <param name="entryMethodName">Name of the entry method.</param>
 /// <param name="alternativeLayerOrService">When layerOrService == Other you can specify alternative layerOrService name.</param>
 /// <example>
 /// flow,BL:LearningManager:GetLearningPath
 /// </example>
 public void PushFlow <T>(
     CommonLayerOrService layerOrService,
     [CallerMemberName] string entryMethodName = null,
     string alternativeLayerOrService          = null)
 {
     PushFlow(layerOrService, typeof(T).Name, entryMethodName, alternativeLayerOrService);
 }
Example #2
0
        /// <summary>
        /// Push execution flow information.
        /// this information can be match by the activation rules.
        /// </summary>
        /// <param name="layerOrService">The layer or service.</param>
        /// <param name="layerOrServiceClassName">
        /// Name of the layer or service class.
        /// You should use nameof(TheClassName).
        /// </param>
        /// <param name="entryMethodName">Name of the entry method.</param>
        /// <param name="alternativeLayerOrService">
        /// When layerOrService == Other you can specify alternative layerOrService name.
        /// </param>
        /// <example>
        /// flow:BL:LearningManager:GetLearningPath
        /// </example>
        public void PushFlow(
            CommonLayerOrService layerOrService,
            string layerOrServiceClassName,
            [CallerMemberName] string entryMethodName = null,
            string alternativeLayerOrService          = null)
        {
            #region Validation
            if (layerOrService != CommonLayerOrService.Other &&
                !string.IsNullOrEmpty(alternativeLayerOrService))
            {
                throw new ArgumentException($"{nameof(alternativeLayerOrService)} is not valid when {nameof(layerOrService)} != {nameof(CommonLayerOrService.Other)}");
            }
            #endregion // Validation

            #region string category = ...
            string category;
            if (layerOrService == CommonLayerOrService.Other)
            {
                category = alternativeLayerOrService;
            }
            else
            {
                category = layerOrService.ToString();
            }
            #endregion // string category = ...

            string candidate = $"flow:{category}:{layerOrServiceClassName}:{entryMethodName}";
            var    tags      = Tags;
            if (tags.ContainsKey(candidate))
            {
                return;
            }
            _context.Value = tags.Add(candidate, string.Empty);
        }
        public IMetricsReporterBuilder AddComponentInfo(
            CommonLayerOrService layerOrService = CommonLayerOrService.Other,
            string layerOrServiceClassName      = null,
            string alternativeLayerOrService    = null)
        {
            #region Validation

            if (layerOrService != CommonLayerOrService.Other &&
                !string.IsNullOrEmpty(alternativeLayerOrService))
            {
                throw new ArgumentException($"{nameof(alternativeLayerOrService)} is not valid when {nameof(layerOrService)} != {nameof(CommonLayerOrService.Other)}");
            }

            #endregion // Validation

            #region string layer = ...

            string layer;
            if (layerOrService == CommonLayerOrService.Other)
            {
                layer = alternativeLayerOrService;
            }
            else
            {
                layer = layerOrService.ToString();
            }

            #endregion // string layer = ...

            var tags = _tags.Add("layer", layer);
            tags = tags.Add("component", layerOrServiceClassName);
            return(new MetricsReporterBuilder(_activation, _tagContext, _measurementName, tags, _influxConfiguration));
        }
 /// <summary>
 /// Push execution flow information.
 /// this information can be match by the activation rules.
 /// </summary>
 /// <param name="layerOrService">The layer or service.</param>
 /// <param name="layerOrServiceClassName">
 /// Name of the layer or service class.
 /// You should use nameof(TheClassName).
 /// </param>
 /// <param name="entryMethodName">Name of the entry method.</param>
 /// <param name="alternativeLayerOrService">
 /// When layerOrService == Other you can specify alternative layerOrService name.
 /// </param>
 /// <example>
 /// flow:BL:LearningManager:GetLearningPath
 /// </example>
 public void PushFlow(
     CommonLayerOrService layerOrService,
     string layerOrServiceClassName,
     [CallerMemberName] string entryMethodName = null,
     string alternativeLayerOrService          = null)
 {
     foreach (var push in _pushs)
     {
         push.PushFlow(layerOrService, layerOrServiceClassName, entryMethodName, alternativeLayerOrService);
     }
 }
 public IMetricsReporterBuilder AddComponentInfo <T>(
     CommonLayerOrService layerOrService = CommonLayerOrService.Other,
     string alternativeLayerOrService    = null)
 {
     return(AddComponentInfo(layerOrService, typeof(T).Name, alternativeLayerOrService));
 }