【问题标题】:Elastic APM RUM Missing nested spans弹性 APM RUM 缺少嵌套跨度
【发布时间】:2019-07-31 20:55:46
【问题描述】:

通过 Opentracing API 或 Elastic APM 的 API 在 Elsatic APM 中进行嵌套时。有些跨度从未被记录。

使用import * as apm from '@elastic/apm-rum';

const transaction = this.apm.startTransaction('transaction-scene-loaded', 'custom'); // recorded
const span = this.apm.startSpan('span-scene-loaded', 'custom'); // recorded
const span2 = this.apm.startSpan('span-loading-state-updated', 'custom'); // Not recorded

span2.end();
span.end();
transaction.end();

使用 Elastic 的 OpenTracing API:

const {
  init: initApm,
  createTracer
} = require('@elastic/apm-rum/dist/bundles/elastic-apm-opentracing.umd.js');

跨度的行为同样不一致。目前尚不清楚交易何时开始或结束。一些 span 被翻译成事务,嵌套 span 可能不会被记录。如果我声明一个页面范围的事务,Angular 的ngOnInit 可以被一个跨度记录,但其他事件挂钩永远不会被记录。

onLoaded() {
  const span = this.tracer.startSpan('span-scene-loaded'); // Not recorded
  // ...
  span.end();
}

我已经尝试过这种变化。在 span、childOf、应用级 span、span 的单个实例中包装 span。

【问题讨论】:

    标签: javascript angular opentracing elastic-apm


    【解决方案1】:

    要将跨度包含到事务中,您应该从事务对象开始跨度

    ...
    var span = transaction.startSpan('My custom span')
    ...

    结束父事务对象所有嵌套跨度也将级联结束

    https://www.elastic.co/guide/en/apm/agent/js-base/4.x/transaction-api.html#transaction-start-span

    【讨论】:

    • transaction.startSpan对此进行了测试。现在缺少整个事务。 const transaction = this.apm.startTransaction('transaction-scene-loaded', 'custom'); const span = transaction.startSpan('span-scene-loaded'); 嵌套跨度是一个单独的问题。好像我们不能用这个 Elastic 的 API 嵌套 span?
    • 您必须结束()事务才能让库准备好发送。您可以在同一个事务中创建多个跨度,但它们不能嵌套。它们将以这种方式显示:images.contentstack.io/v3/assets/bltefdd0b53724fa2ce/…
    • end() 已经被调用了,但是因为有间距我这里省略了。我也在这里尝试了一些变化。结束跨度然后事务,只是事务,超时,销毁,卸载前。记录了一些事务和一些跨度,但并不总是记录嵌套的跨度。一些事务和跨度永远不会被记录,即使是通过代码块运行。
    猜你喜欢
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 1970-01-01
    • 2021-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多