Skip to content
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

BatchSpanProcessor#force_flush: purge inherited spans even on shutdown #1537

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

casperisfine
Copy link
Contributor

Ref: #363
Ref: Shopify/pitchfork#74

At Shopify we're using the Pitchfork web server, and one thing it does is that it sometimes do a "double fork", similar to the classic daemonization dance.

Recently we noticed that sometimes the "middle process" of that daemonization dance would get "stuck". After adding some debug we figured it's because we have:

at_exit do
  # Triggers flushing of buffer on shutdown
  OpenTelemetry.tracer_provider.shutdown(timeout: 60)
end

So the child process inherits lots of spans from its parents, and normally OpenTelemetry deal gracefully with that by droping the inherited spans.

But here because we called shutdown, @keep_running is set to false hence reset_on_fork is not called.

I don't understand why we shouldn't call it during shutdown though, aside from avoiding to respawn the thread.

With this change we expect our "middle process" to drop all the inherited spans and to have nothing to flush.

@fbogsany @robertlaurin
cc @DazWorrall @bmansoob

Ref: open-telemetry#363
Ref: Shopify/pitchfork#74

At Shopify we're using the Pitchfork web server, and one thing it
does is that it sometimes do a "double fork", similar to the classic
daemonization dance.

Recently we noticed that sometimes the "middle process" of that
daemonization dance would get "stuck". After adding some debug
we figured it's because we have:

```ruby
at_exit do
  # Triggers flushing of buffer on shutdown
  OpenTelemetry.tracer_provider.shutdown(timeout: 60)
end
```

So the child process inherits lots of spans from its parents,
and normally OpenTelemetry deal gracefully with that by droping
the inherited spans.

But here because we called `shutdown`, `@keep_running` is set to `false`
hence `reset_on_fork` is not called.

I don't understand why we shouldn't call it during shutdown though, aside
from avoiding to respawn the thread.

With this change we expect our "middle process" to drop all the inherited
spans and to have nothing to flush.
@fbogsany fbogsany merged commit 6457553 into open-telemetry:main Oct 31, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants