private void Init(ActionExecutingContext actionContext) { SetEventPolicy(); SetPublishCounterPolicy(); SetErrorPolicy(); if (InstanceNameProviderType != null) { _instanceNameProvider = (IInstanceNameProvider)Activator.CreateInstance(InstanceNameProviderType); } if (InstrumentationContextProviderType != null) { _instrumentationContextProvider = (IInstrumentationContextProvider)Activator.CreateInstance(InstrumentationContextProviderType); } var instanceName = InstanceName; if (_instanceNameProvider != null) { instanceName = _instanceNameProvider.GetInstanceName(actionContext); } if (instanceName == null) { InstanceName = PerfItRuntime.GetCounterInstanceName( actionContext.ActionDescriptor.ControllerDescriptor.ControllerType, actionContext.ActionDescriptor.ActionName); } _instrumentor = new SimpleInstrumentor(Info); }
private ITwoStageInstrumentor InitInstrumentor(MethodInfo methodInfo) { string instrumentationContext = ""; var instrumentationInfo = GetInstrumentationInfo(methodInfo); if (instrumentationInfo != 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 instrumentor = new SimpleInstrumentor(new InstrumentationInfo() { Description = instrumentationInfo.Description, Counters = instrumentationInfo.Counters, InstanceName = instanceName, CategoryName = string.IsNullOrEmpty(this.CategoryName) ? instrumentationInfo.CategoryName : this.CategoryName, SamplingRate = SamplingRate, PublishCounters = PublishCounters, PublishEvent = PublishEvent, RaisePublishErrors = RaisePublishErrors }); _instrumentors.AddOrUpdate(instrumentationContext, instrumentor, (key, inst) => instrumentor); return(instrumentor); } else { return(null); } }
private void Init(ActionExecutingContext actionContext) { SetEventPolicy(); SetPublishCounterPolicy(); SetErrorPolicy(); SetSamplingRate(); if (SamplingRate == default(double)) { SamplingRate = Constants.DefaultSamplingRate; } if (InstanceNameProviderType != null) { _instanceNameProvider = (IInstanceNameProvider)Activator.CreateInstance(InstanceNameProviderType); } if (InstrumentationContextProviderType != null) { _instrumentationContextProvider = (IInstrumentationContextProvider)Activator.CreateInstance(InstrumentationContextProviderType); } if (Counters == null || Counters.Length == 0) { Counters = CounterTypes.StandardCounters; } var instanceName = InstanceName; if (_instanceNameProvider != null) { instanceName = _instanceNameProvider.GetInstanceName(actionContext); } if (instanceName == null) { instanceName = PerfItRuntime.GetCounterInstanceName(actionContext.ActionDescriptor.ControllerDescriptor.ControllerType, actionContext.ActionDescriptor.ActionName); } _instrumentor = new SimpleInstrumentor(new InstrumentationInfo() { Description = Description, Counters = Counters, InstanceName = instanceName, CategoryName = CategoryName, SamplingRate = SamplingRate, PublishCounters = PublishCounters, PublishEvent = PublishEvent, RaisePublishErrors = RaisePublishErrors, CorrelationIdKey = CorrelationIdKey }); }
private void Init(ActionExecutingContext actionContext) { SetErrorPolicy(); SetSamplingRate(); if (SamplingRate == default(double)) { SamplingRate = Constants.DefaultSamplingRate; } if (InstanceNameProviderType != null) { _instanceNameProvider = (IInstanceNameProvider)Activator.CreateInstance(InstanceNameProviderType); } _instanceNameProvider = _instanceNameProvider ?? (IInstanceNameProvider)actionContext.HttpContext.RequestServices.GetService(typeof(IInstanceNameProvider)); if (InstrumentationContextProviderType != null) { _instrumentationContextProvider = (IInstrumentationContextProvider)Activator.CreateInstance(InstrumentationContextProviderType); } _instrumentationContextProvider = _instrumentationContextProvider ?? (IInstrumentationContextProvider)actionContext.HttpContext.RequestServices.GetService(typeof(IInstrumentationContextProvider)); var instanceName = InstanceName; if (_instanceNameProvider != null) { instanceName = _instanceNameProvider.GetInstanceName(actionContext); } if (instanceName == null) { instanceName = PerfItRuntime.GetCounterInstanceName(actionContext.Controller.GetType(), actionContext.ActionDescriptor.DisplayName); } var inst = new SimpleInstrumentor(new InstrumentationInfo() { Description = Description, InstanceName = instanceName, CategoryName = CategoryName, SamplingRate = SamplingRate, RaisePublishErrors = RaisePublishErrors }); _instrumentor = inst; }
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); }
private void Init(HttpActionContext actionContext) { SetEventPolicy(); SetPublish(); SetErrorPolicy(); if (InstanceNameProviderType != null) { _instanceNameProvider = (IInstanceNameProvider)Activator.CreateInstance(InstanceNameProviderType); } if (InstrumentationContextProviderType != null) { _instrumentationContextProvider = (IInstrumentationContextProvider)Activator.CreateInstance(InstrumentationContextProviderType); } if (Counters == null || Counters.Length == 0) { Counters = CounterTypes.StandardCounters; } var instanceName = InstanceName; if (_instanceNameProvider != null) { instanceName = _instanceNameProvider.GetInstanceName(actionContext); } if (instanceName == null) { instanceName = PerfItRuntime.GetCounterInstanceName(actionContext.ControllerContext.ControllerDescriptor.ControllerType, actionContext.ActionDescriptor.ActionName); } _instrumentor = new SimpleInstrumentor(new InstrumentationInfo() { Description = Description, Counters = Counters, InstanceName = instanceName, CategoryName = CategoryName }, PublishCounters, PublishEvent, RaisePublishErrors); }
private void Init(ActionExecutingContext actionContext) { SetPublishCounterPolicy(); SetErrorPolicy(); SetSamplingRate(); if (SamplingRate == default(double)) { SamplingRate = Constants.DefaultSamplingRate; } if (InstanceNameProviderType != null) { _instanceNameProvider = (IInstanceNameProvider)Activator.CreateInstance(InstanceNameProviderType); } if (InstrumentationContextProviderType != null) { _instrumentationContextProvider = (IInstrumentationContextProvider)Activator.CreateInstance(InstrumentationContextProviderType); } if (Counters == null || Counters.Length == 0) { Counters = CounterTypes.StandardCounters; } var instanceName = InstanceName; if (_instanceNameProvider != null) { instanceName = _instanceNameProvider.GetInstanceName(actionContext); } if (instanceName == null) { instanceName = PerfItRuntime.GetCounterInstanceName(actionContext.ActionDescriptor.ControllerDescriptor.ControllerType, actionContext.ActionDescriptor.ActionName); } var inst = new SimpleInstrumentor(new InstrumentationInfo() { Description = Description, Counters = Counters, InstanceName = instanceName, CategoryName = CategoryName, SamplingRate = SamplingRate, PublishCounters = PublishCounters, RaisePublishErrors = RaisePublishErrors }); _instrumentor = inst; if (TracerTypes != null) { foreach (var tt in TracerTypes) { inst.Tracers.Add(tt.FullName, (ITwoStageTracer)Activator.CreateInstance(tt)); } } }