Skip to content

Exporter shutdown method does not flush spans when wrapped with SimpleSpanProcessor #5602

@chasestarr

Description

@chasestarr

What happened?

Steps to Reproduce

When I end a span, then next call shutdown, the ended span is not flushed. If I wait for the next event loop tick, the span is flushed as-expected. See this example in the repo that demonstrates the problem and an example work-around.

parentSpan.end();
// give some time before it is closed
setTimeout(() => {
  // flush and close the connection.
  exporter.shutdown();
}, 2000);

Providing 0 to setTimeout also resolved the issue for me.

parentSpan.end();
setTimeout(() => {
  exporter.shutdown();
}, 0);

Additional Details

See this other comment where the issue is shared.

Ideally, updating the example to below would work without the event loop wait.

parentSpan.end();
exporter.shutdown();

OpenTelemetry Setup Code

package.json

Relevant log output

Operating System and Version

No response

Runtime and Version

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpriority:p4Bugs and spec inconsistencies which do not fall into a higher prioritization

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions