private static void AddProperties(IDictionary <string, string> properties) { if (properties != null) { properties.AsParallel().ForAll(p => { NRClient.AddCustomParameter(p.Key, p.Value); }); } }
private static void AddMetric(IDictionary <string, double> metrics) { if (metrics != null) { metrics.AsParallel().ForAll(m => { NRClient.AddCustomParameter(m.Key, m.Value); }); } }
/// <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); }; }
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); } } }
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); }; }
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); } } }; }
public void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool success) { NRClient.RecordMetric(name, (float)duration.TotalMilliseconds); }
public void TrackMetric(string name, double value, IDictionary <string, string> properties = null) { AddProperties(properties); NRClient.RecordMetric(name, (float)value); }
public void TrackMetric(string name, TimeSpan value, IDictionary <string, string> properties = null) { AddProperties(properties); NRClient.RecordMetric(name, (float)value.TotalMilliseconds); }
public void TrackException(Exception exception, IDictionary <string, string> properties = null, IDictionary <string, double> metrics = null) { AddMetric(metrics); NRClient.NoticeError(exception, properties); }
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); }
public void TrackDependency(string dependencyName, string commandName, DateTimeOffset startTime, TimeSpan duration, bool success) { NRClient.RecordResponseTimeMetric(string.Format("{0}\\{1}", dependencyName, commandName), (long)duration.TotalMilliseconds); }
public void IncrementMetric(string name, double value) { NRClient.RecordMetric(name, (float)value); }
public void IncrementMetric(string name) { NRClient.RecordMetric(name, 1); NRClient.IncrementCounter(name); }
public void DecrementMetric(string name) { NRClient.RecordMetric(name, -1); }
public NRTelemetryConsumer() { NRClient.StartAgent(); }
public void DecrementMetric(string name) { NRClient.RecordMetric(FormatMetricName(name), -1); }
public void DecrementMetric(string name, double value) { NRClient.RecordMetric(FormatMetricName(name), (float)value * -1); }
public void TrackDependency(string dependencyName, string commandName, DateTimeOffset startTime, TimeSpan duration, bool success) { NRClient.RecordResponseTimeMetric(FormatMetricName($"{dependencyName}/{commandName}"), (long)duration.TotalMilliseconds); }