Skip to content

Unexpected Asynchronous Spans  #1878

@astorm

Description

@astorm

I ran into a situation where the Elastic Node.js Agent is marking span payloads with the sync=false key/value pair even when the spans themselves contain no asynchronous work.

Consider the following program

const http = require('http');

const requestListener = function (req, res) {
  const span1 = apm.startSpan('This is span 1')
  span1.end()
  const span2 = apm.startSpan('This is span 2')
  span2.end()
  const span3 = apm.startSpan('This is span 3')
  span3.end()
  res.writeHead(200);
  res.end('Hello, World!');
}

const server = http.createServer(requestListener);
server.listen(8080);

This program handles an HTTP request, and then manually starts and stops three spans. Payloads are generated for each span, and those payload have the value sync=false. As a user, my first instinct would be that these spans would be considered synchronous work.

It's unclear whether this is a bug, or a deliberate tradeoff decision to treat all NodeJS spans as async.

Next Steps: Investigate where and why these spans have their default sync=true property set to false.

Metadata

Metadata

Assignees

Labels

agent-nodejsMake available for APM Agents project planning.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions