-
Notifications
You must be signed in to change notification settings - Fork 655
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
sdk: shut down span processors automatically #280
Changes from 1 commit
25fa67e
5375741
981f2ba
e1bb798
eaac649
1fda442
7453436
41b6cb4
1827ed0
53e032c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,3 @@ def hello(): | |
|
||
if __name__ == "__main__": | ||
app.run(debug=True) | ||
span_processor.shutdown() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,3 @@ def hello(): | |
|
||
if __name__ == "__main__": | ||
app.run(debug=True) | ||
span_processor.shutdown() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
# limitations under the License. | ||
|
||
|
||
import atexit | ||
import logging | ||
import random | ||
import threading | ||
|
@@ -333,6 +334,13 @@ def __init__( | |
self._current_span_slot = Context.register_slot(slot_name) | ||
self._active_span_processor = MultiSpanProcessor() | ||
self.sampler = sampler | ||
self._atexit_hanlder = atexit.register( | ||
self._active_span_processor.shutdown | ||
) | ||
|
||
def __del__(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why put this on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that having it in |
||
atexit.unregister(self._atexit_hanlder) | ||
self._active_span_processor.shutdown() | ||
|
||
def get_current_span(self): | ||
"""See `opentelemetry.trace.Tracer.get_current_span`.""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference would be to not do this by default, but have it as something the user can plug himself, or at least make this optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlosalberto why not do this by default? Because it would be surprising that calling
del
results in (blocking!) network calls?I agree about making this configurable, but I think this is much better than the current default: call
shutdown
or lose unexported spans.