Exemplo n.º 1
0
 private static void AddProperties(IDictionary <string, string> properties)
 {
     if (properties != null)
     {
         properties.AsParallel().ForAll(p =>
         {
             NRClient.AddCustomParameter(p.Key, p.Value);
         });
     }
 }
Exemplo n.º 2
0
 private static void AddMetric(IDictionary <string, double> metrics)
 {
     if (metrics != null)
     {
         metrics.AsParallel().ForAll(m =>
         {
             NRClient.AddCustomParameter(m.Key, m.Value);
         });
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Para que seja possível acompanhar as requisições feitas de forma separada
        /// via new relic esse método deve ser chamado a cada requisição
        /// dessa forma todos os módulos devem herdar essa classe
        /// </summary>
        public void TrackNewRelic()
        {
            Before += ctx =>
            {
                var routeDescription = ctx.ResolvedRoute.Description;
                NewRelicAgent.SetTransactionName("Custom", $"Trilhas {routeDescription.Method} {routeDescription.Path}");

                return(null);
            };
        }
Exemplo n.º 4
0
 private static void AddMetric(IDictionary <string, double> metrics)
 {
     if (metrics != null)
     {
         var agent       = NRClient.GetAgent();
         var transaction = agent.CurrentTransaction;
         foreach (var metric in metrics)
         {
             transaction.AddCustomAttribute(metric.Key, metric.Value);
         }
     }
 }
Exemplo n.º 5
0
 private static void AddProperties(IDictionary <string, string> properties)
 {
     if (properties != null)
     {
         var agent       = NRClient.GetAgent();
         var transaction = agent.CurrentTransaction;
         foreach (var property in properties)
         {
             transaction.AddCustomAttribute(property.Key, property.Value);
         }
     }
 }
        protected BaseModule(string modulePath) : base(modulePath)
        {
            TraceID = Guid.NewGuid();

            OnError += new ErrorHandler(TraceID).OnError;

            Before += ctx =>
            {
                var routeDescription = ctx.ResolvedRoute.Description;
                NewRelicAgent.SetTransactionName("Custom/Endpoint", string.Format("{0} {1}", routeDescription.Method, routeDescription.Path));

                return(null);
            };
        }
Exemplo n.º 7
0
        public static async Task <dynamic> RunAsync(Func <Task <dynamic> > action)
        {
            try
            {
                return(await action());
            }
            catch (Exception ex)
            {
                NewRelicAgent.NoticeError(ex);
                ErrorSignal.FromContext(HttpContext.Current).Raise(ex);

                Response exceptionResponse = ex.Message;
                exceptionResponse.StatusCode = HttpStatusCode.NotAcceptable;

                return(exceptionResponse);
            }
        }
        static void app_PostMapRequestHandler(object sender, EventArgs e)
        {
            var ctx = ((HttpApplication)sender).Context;

            var handler = ctx.CurrentHandler as Page;

            if (handler == null)
            {
                return;
            }

            handler.Load += (o, args) =>
            {
                var c1Page = PageRenderer.CurrentPage;
                if (c1Page != null)
                {
                    var template = PageTemplateFacade.GetPageTemplate(c1Page.TemplateId);
                    var title    = template.Title;

                    NewRelicAgent.SetTransactionName("C1 Page", title);
                }
                else
                {
                    var adminPath   = UrlUtils.AdminRootPath;
                    var requestPath = ctx.Request.Url.LocalPath;

                    if (!requestPath.StartsWith(adminPath, StringComparison.OrdinalIgnoreCase))
                    {
                        return;
                    }

                    var newRelic = handler.Request.QueryString["newrelic"];
                    if (newRelic == null || !newRelic.Equals("true"))
                    {
                        NewRelicAgent.DisableBrowserMonitoring(true);
                    }
                }
            };
        }
Exemplo n.º 9
0
 public void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool success)
 {
     NRClient.RecordMetric(name, (float)duration.TotalMilliseconds);
 }
Exemplo n.º 10
0
 public void TrackMetric(string name, double value, IDictionary <string, string> properties = null)
 {
     AddProperties(properties);
     NRClient.RecordMetric(name, (float)value);
 }
Exemplo n.º 11
0
 public void TrackMetric(string name, TimeSpan value, IDictionary <string, string> properties = null)
 {
     AddProperties(properties);
     NRClient.RecordMetric(name, (float)value.TotalMilliseconds);
 }
Exemplo n.º 12
0
 public void TrackException(Exception exception, IDictionary <string, string> properties = null, IDictionary <string, double> metrics = null)
 {
     AddMetric(metrics);
     NRClient.NoticeError(exception, properties);
 }
Exemplo n.º 13
0
 public void TrackEvent(string eventName, IDictionary <string, string> properties = null, IDictionary <string, double> metrics = null)
 {
     NRClient.RecordCustomEvent(eventName, metrics != null ? metrics.ToDictionary(e => e.Key, e => (object)e.Value) : null);
     AddMetric(metrics);
     AddProperties(properties);
 }
Exemplo n.º 14
0
 public void TrackDependency(string dependencyName, string commandName, DateTimeOffset startTime, TimeSpan duration, bool success)
 {
     NRClient.RecordResponseTimeMetric(string.Format("{0}\\{1}", dependencyName, commandName), (long)duration.TotalMilliseconds);
 }
Exemplo n.º 15
0
 public void IncrementMetric(string name, double value)
 {
     NRClient.RecordMetric(name, (float)value);
 }
Exemplo n.º 16
0
 public void IncrementMetric(string name)
 {
     NRClient.RecordMetric(name, 1);
     NRClient.IncrementCounter(name);
 }
Exemplo n.º 17
0
 public void DecrementMetric(string name)
 {
     NRClient.RecordMetric(name, -1);
 }
Exemplo n.º 18
0
 public NRTelemetryConsumer()
 {
     NRClient.StartAgent();
 }
Exemplo n.º 19
0
 public void DecrementMetric(string name)
 {
     NRClient.RecordMetric(FormatMetricName(name), -1);
 }
Exemplo n.º 20
0
 public void DecrementMetric(string name, double value)
 {
     NRClient.RecordMetric(FormatMetricName(name), (float)value * -1);
 }
Exemplo n.º 21
0
 public void TrackDependency(string dependencyName, string commandName, DateTimeOffset startTime, TimeSpan duration, bool success)
 {
     NRClient.RecordResponseTimeMetric(FormatMetricName($"{dependencyName}/{commandName}"), (long)duration.TotalMilliseconds);
 }