1

我将 ElasticAPM 添加到我在 AspNetCore 3.1 上的启动中

app.UseAllElasticApm(Configuration);

在我的项目中,rest api services 记录为 kibana-apm 的事务选项卡。但是我的后台服务没有被 apm 代理记录,只有指标选项卡对我有用。

4

1 回答 1

1

目前后台服务不是开箱即用的。

您可以做的是使用公共代理 API,并使用一些额外的代码,您也可以将它们捕获为事务。

在后台服务中是这样的:

var transaction = Elastic.Apm.Agent
        .Tracer.StartTransaction("MyTransaction", ApiConstants.TypeRequest);
try
{
    //background service code that is captured as a transaction
}
catch (Exception e)
{
    transaction?.CaptureException(e);
    throw;
}
finally
{
    transaction?.End();
}
于 2020-04-06T18:03:11.230 回答