- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有一个每隔几秒运行一次的 Azure 函数。我们希望使用 New Relic 来让我们知道这段代码是否抛出异常或开始出现异常行为。我已在虚拟机上安装了 New Relic 代理,并通过 NuGet 引入了 NewRelic.Agent.Api DLL。我已将 NewRelic.AppName 设置为 AzureFunctionAppTest 并设置 NEWRELIC_LICENSEKEY 环境变量。日志文件表明我正在连接到 NewRelic。现在,我正在运行以下代码:
#r "Microsoft.windowsazure.storage"
using System;
using System.Threading.Tasks;
using Microsoft.WindowsAzure.Storage.Table;
public static void Run(TimerInfo myTimer, TraceWriter log, CloudTable syncTimesTable)
{
NewRelic.Api.Agent.NewRelic.SetTransactionName("SyncEvents", "GetRoutineData");
var rnd = new Random(DateTime.Now.Millisecond).Next(30);
log.Info($"Logging {rnd}");
var eventAttributes = new Dictionary<string, object>() {{"result", "Success!"}, {"Count", rnd.ToString()}};
NewRelic.Api.Agent.NewRelic.RecordCustomEvent("DevicesSynced", eventAttributes);
NewRelic.Api.Agent.NewRelic.NoticeError(new SyncException("This is another custom error"));
}
public class SyncException : Exception
{
public SyncException(string msg) : base(msg)
{
}
}
所以,基本上我尝试设置交易名称,然后生成一个随机数并将其记录为自定义事件,然后尝试记录自定义错误。
我让它运行一会儿,然后使用 New Relic 仪表板进行检查。这是我得到的:
我有一种感觉,我实际上并没有参与我的 Azure Function 代码中的事务,因此 New Relic 不允许我设置名称。我还有一种感觉,即使我使用 NOTICEError 记录错误,它也不会链接到任何事务,因此它不会显示在错误分析中。
我的问题:
谢谢!
更新:
我尝试在 Extensions
目录中添加一个名为 CustomInstrumentation.xml
的文件,按照 New Relic instructions包含以下内容:
<?xml version="1.0" encoding="utf-8"?>
<extension
xmlns="urn:newrelic-extension">
<instrumentation>
<!-- Define the method which triggers the creation of a transaction. -->
<tracerFactory name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory" metricName="Background/AzureDeviceSync">
<match assemblyName="Microsoft.Azure.WebJobs.Script" className="Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase">
<exactMethodMatcher methodName="Invoke" />
</match>
</tracerFactory>
</instrumentation>
</extension>
但是,我没有看到行为有任何差异。我尝试了几种不同的方法名称匹配(例如 InvokeCore
和 Invoke
),但似乎没有什么区别。
几个问题:
新遗物文档说:
To view the transaction: From the New Relic menu bar, select APM > Applications > (selected app) > Monitoring > Transactions > Type > (selected type). (The type is defined by Category/Name.) You can then view all custom transactions of the selected type.
它显示了带有自定义选项的下拉菜单的图片:
但是,我的 New Relic 界面没有任何类型的“类型”下拉列表:
此外,如果我检测代码以显示 Function 应用程序内的堆栈跟踪,这就是我得到的结果。也许会有帮助:
Stack:
at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at Submission#0.Run(TimerInfo myTimer, TraceWriter log, CloudTable syncTimesTable) in :line 9
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.<InvokeCore>d__23.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker.InvokeCore(Object[] parameters, FunctionInvocationContext context)
at Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.<Invoke>d__29.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
at Host.Functions.LogNewRelicAlert(TimerInfo myTimer, TraceWriter log, CloudTable syncTimesTable, ExecutionContext _context)
at lambda_method(Closure , Functions , Object[] )
at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker`1.InvokeAsync(TReflected instance, Object[] arguments)
at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`1.<InvokeAsync>d__8.MoveNext()
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.InvokeMoveNext(Object stateMachine)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run()
at System.Runtime.CompilerServices.YieldAwaitable.YieldAwaiter.RunAction(Object state)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
我想知道是否有任何类型的日志文件可以显示是否确实加载了自定义事务设置以及何时创建了新事务。现在我猜我的 XML 匹配了错误的内容。
还有一件事。如果我添加以下行:
NewRelic.Api.Agent.NewRelic.SetTransactionName("Custom", "Testing");
在我的 Function 应用中,我会在 New Relic 日志中看到以下警告:
2017-02-01 21:45:25,005 NewRelic WARN: Agent API Error: An error occurred invoking API method "SetTransactionName" - "System.InvalidOperationException: The API method called is only valid from within a transaction. This error can occur if you call the API method from a thread other than the one the transaction started on.
我认为这清楚地表明我们此时实际上并未处于事务中,除非它发生在另一个线程上(如果是这种情况我不会感到惊讶)。
还有其他想法吗?
最佳答案
终于成功了!好吧,至少我认为它会起作用。这是/Extensions 目录中我的 .XML 文件:
<?xml version="1.0" encoding="utf-8"?>
<extension
xmlns="urn:newrelic-extension">
<instrumentation>
<!-- Define the method which triggers the creation of a transaction. -->
<tracerFactory
name="NewRelic.Agent.Core.Tracer.Factories.BackgroundThreadTracerFactory"
metricName="Limeade/AzureDeviceSync">
<match assemblyName="Microsoft.Azure.WebJobs.Script" className="Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker">
<exactMethodMatcher methodName="InvokeCore" />
</match>
</tracerFactory>
</instrumentation>
</extension>
这个文件的名称并不重要,因为 New Relic 将加载 Extensions 目录中的每个 XML 文件。
以下是我学到的一些东西:
当您更改任何 New Relic 配置(包括扩展 XML 文件)时,您必须重置 IIS。然而,SCM 上的“重新启动站点”按钮实际上并没有杀死 IIS 进程。您必须进入 Kudu 中的 Process Explorer 并关闭 w3wp.exe 进程。如果您无法确定要终止哪个进程,可以添加 log.Info($"Currently running in PID: {System.Diagnostics.Process.GetCurrentProcess().Id}");
到您的函数应用程序以找出答案。
默认情况下,New Relic 将生成令人困惑的事务名称,例如 Microsoft.Azure.WebJobs.Script.Description.DotNetFunctionInvoker/InvokeCore。我找不到在 XML 文件中设置事务名称的方法。但是,您可以在 Azure Function 代码中设置新事务名称,如下所示:
NewRelic.Api.Agent.NewRelic.SetTransactionName("SyncEvents", "GetRoutineData");
如果从 Run
方法抛出异常并将该异常记录为 New Relic 中的错误,那就太好了,但经过相当多的尝试后我无法得到这个上类。我认为这些异常正在某个地方被吃掉,并且我无法找出跟踪器配置的正确组合来在它们丢失之前拦截它们。但是,您可以使用NoticeError()调用:NewRelic.Api.Agent.NewRelic.NoticeError(new SyncException("这是自定义错误"));
这看起来工作原理是一样的,这些错误将显示在 New Relic 的错误和错误分析中。缺点是您可能必须重构一堆 Azure Function 代码来捕获所有错误、注意到它们,然后在必要时重新抛出它们。
我花了两天时间才让它发挥作用,所以我希望这对某人有帮助!!
关于azure - 是否可以使用 New Relic 来监控 Azure Function 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41969537/
我正在 main.go 中创建新的 relic 事务,并且必须将它传递给处理程序,然后传递给 Controller 等等。有没有办法可以全局定义它,然后可以在任何处理程序、 Controller
在我的服务器上的 /var/log/newrelic/php_agent.log 中,我看到这样的行: 2013-08-30 16:05:01.444 (15615/child) warning: t
New Relic有一个Java代理,它可以作为依赖项添加到应用程序中。我相信,该代理作为正在运行的JVM的一部分进行检测。检测的数据每隔一分钟从Java代理发送到New Relic服务器。。如果JV
我想要实现的目标: 我想发送使我的页面完全交互所需的时间 描述: 我使用 requirejs 作为我的 javascript 的依赖管理器,所以基本上我想发送直到我的页面脚本完全执行所花费的时间 示例
Node.js 中的 New Relic 存在问题。它似乎干扰了我的 continuation-local-storage 实现,我的意思是它似乎正在杀死我的 cls 上下文。 现在,一切都完美运行,
New Relic 如何通过简单的安装进入我的应用程序?它如何知道所有方法、请求等? 它适用于 RoR、PHP 等。 谁能解释一下它背后的技术?我有兴趣利用我的 Rails 应用程序,但我想像 New
我在 New Relic 上有一个私有(private)帐户,该帐户用于监控我们公司的内部应用程序。我也是我们公司帐户的管理员,有两个订阅计划不同的子帐户。我需要将应用程序和服务器从我的私有(priv
我正在使用新的遗留标准来防止我的 heroku 应用程序闲置。似乎每分钟左右都会发出 ping 信号。这会以任何显着的方式减慢我的应用程序吗?有没有办法减少 ping 的发生频率?寻找像 heroku
我正在使用 New Relic 插件(memcached、mongodb 等)监控一些服务。他们向我显示该服务的统计数据,但当服务中断时,New Relic 不会发出任何警报。服务统计数据中只有零。如
我目前已经将 New Relic 服务绑定(bind)到在 Bluemix 中的 Liberty 下运行的 Java 应用程序。 我们使用蓝绿色部署方法来最大限度地减少推送新版本时的停机时间,因此应用
我们在生产环境中使用 newrelic_rpm。 我将日志级别更改为调试。 每当代理向服务器发送数据时,它会显示: [11/08/11 13:58:09 +0530 mubarocks.local (
我正在使用 Nancy 的自定义代理设置,如 here 所述对于 Azure 中托管的网站。通常情况下,一切正常,但我的服务返回一些我不希望在 New Relic 中报告的 4xx 错误。不幸的是,我
我正在使用 WSRequest 类向我的 Play 网络应用程序中的外部网络服务发出请求。 这是我用来进行 SOAP 调用的一小段代码: WSRequest req = WS.url("htt
我已经在两台服务器上安装了 New Relic,两台服务器都工作正常。 我已经安装了 MySQL 插件,两者的方式完全相同,但只有 1 个出现在 New Relic 中。 据我所知,两者的配置是相同的
我想在最重要的应用程序中使用新的遗留 APM。为了监控应用程序的性能,我在 api/post.go 文件中的 createpost api 请求处理程序上方添加了代码(如 new relic 中所述)
我正在使用 Go 的 newrelic SDK 端口在 NR 中创建自定义指标。我能够创建一个新的指标来衡量我的应用程序的吞吐量,我正在尝试创建一个平均响应时间的指标。 我已经添加了必要的代码来报告(
我可以从 New Relic 监控使用 Apache 提供的静态页面吗? 也许我应该包括一个模块? 最佳答案 New Relic 现在有插件。一位出版商已经为 Apache 发布了一个插件。 . 如果
我们已成功迁移所有 PHP 和 Ruby 应用程序,以使用 New Relic RPM 进行应用程序性能测量和服务器监控。我们对结果非常满意,这使我们能够提高平台数字时间的整体性能。我们仍然有很多 P
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 6年前关闭。 Improve thi
https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-ios/configuration/upload-dsyms-bit
我是一名优秀的程序员,十分优秀!