File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -944,8 +944,15 @@ def _exit_open_spans(): # type: ignore[reportUnusedFunction] # pragma: no cove
944
944
# OTEL registers its own atexit callback in the tracer/meter providers to shut them down.
945
945
# Registering this callback here after the OTEL one means that this runs first.
946
946
# Otherwise OTEL would log an error "Already shutdown, dropping span."
947
+ # The reason that spans may be lingering open is that they're in suspended generator frames.
948
+ # Apart from here, they will be ended when the generator is garbage collected
949
+ # as the interpreter shuts down, but that's too late.
947
950
for span in list (OPEN_SPANS ):
951
+ # TODO maybe we should be recording something about what happened here?
948
952
span .end ()
953
+ # Interpreter shutdown may trigger another call to .end(),
954
+ # which would log a warning "Calling end() on an ended span."
955
+ span .end = lambda * _ , ** __ : None # type: ignore
949
956
950
957
self ._initialized = True
951
958
You can’t perform that action at this time.
0 commit comments