Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chasestarr opened this issue Apr 9, 2025 · 1 comment · May be fixed by #5605
Open

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

chasestarr opened this issue Apr 9, 2025 · 1 comment · May be fixed by #5605
Assignees
Labels
bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization

Comments

@chasestarr
Copy link

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

@chasestarr chasestarr added bug Something isn't working triage labels Apr 9, 2025
@pichlermarc
Copy link
Member

Hi @chasestarr thanks for reaching out.

I see that the example there is misleading. Shutting down the exporter does not flush data from the SDK, it only shuts down the exporter itself. There is a NodeTracerProvider#shutdown() method that can be called that will also flush data, that's the one we want to show in the example.

I'll open a PR to update the example.

@pichlermarc pichlermarc added priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization and removed triage labels Apr 10, 2025
@pichlermarc pichlermarc self-assigned this Apr 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization
Projects
None yet
2 participants