Esempio n. 1
0
 private void RaiseInstrumentorRequired(InstrumentorRequiredEventArgs e)
 {
     if (InstrumentorRequired == null)
     {
         return;
     }
     InstrumentorRequired(this, e);
 }
Esempio n. 2
0
        private ITwoStageInstrumentor InitInstrumentor(MethodInfo methodInfo)
        {
            // ReSharper disable once RedundantAssignment
            var instrumentationContext = string.Empty;
            var instrumentationInfo    = GetInstrumentationInfo(methodInfo);

            if (instrumentationInfo == null)
            {
                return(null);
            }

            var instanceName = instrumentationInfo.InstanceName;

            PublishCounters = instrumentationInfo.PublishCounters;

            if (string.IsNullOrEmpty(instanceName) && _instanceNameProvider != null)
            {
                instanceName = _instanceNameProvider.GetInstanceName(methodInfo);
            }

            if (string.IsNullOrEmpty(instanceName))
            {
                throw new InvalidOperationException(
                          "Either InstanceName or InstanceNameProviderType must be supplied.");
            }

            if (_instrumentationContextProvider != null)
            {
                instrumentationContext = _instrumentationContextProvider.GetContext(methodInfo);
            }
            else
            {
                throw new InvalidOperationException(
                          "The Instrumentation Context Cannot be Null. Define a InstrumentationContextProvider implementation.");
            }

            SetEventPolicy();
            SetPublishCounterPolicy();
            SetErrorPolicy();

            var e = new InstrumentorRequiredEventArgs(CategoryName, instrumentationInfo);

            RaiseInstrumentorRequired(e);

            _instrumentors.AddOrUpdate(instrumentationContext, e.Instrumentor, (ictx, i) => e.Instrumentor);

            return(e.Instrumentor);
        }