`SpanProcessor.on_end` exceptions escape cleanup and replace application exceptions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- observability
Direzione di ricerca
Inizia in opentelemetry-sdk/src/opentelemetry/sdk/trace/init.py, in SynchronousMultiSpanProcessor.on_end, e segui la chiamata attraverso Span.end. Verifica che le eccezioni di SpanProcessor.on_end vengano gestite e registrate senza sostituire un’eccezione dell’applicazione né propagarsi quando non esiste alcuna eccezione dell’applicazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Steps to Reproduce
from opentelemetry.sdk.trace import SpanProcessor, TracerProvider
class RaisingProcessor(SpanProcessor):
def on_end(self, span):
raise RuntimeError("processor failed")
provider = TracerProvider()
provider.add_span_processor(RaisingProcessor())
tracer = provider.get_tracer("reproduction")
with tracer.start_as_current_span("operation"):
raise ValueError("application failed")
Expected Result
This method MUST be called synchronously within the
Span.End()API, therefore it should not block or throw an exception.
OpenTelemetry implementations MUST NOT throw unhandled exceptions at runtime.
API methods that accept external callbacks MUST handle all errors.
SynchronousMultiSpanProcessor.on_end invokes processors without an exception guard. The exception escapes through Span.end during context-manager cleanup.
Actual Result
The caller receives RuntimeError("processor failed"), with the application’s ValueError in __context__. Replacing the application’s raise with pass also propagates RuntimeError.
Would you like to implement a fix?
--- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
+++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
@@ -187,3 +187,6 @@
def on_end(self, span: "ReadableSpan") -> None:
for sp in self._span_processors:
- sp.on_end(span)
+ try:
+ sp.on_end(span)
+ except Exception:
+ logger.exception("Exception while calling SpanProcessor.on_end.")
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
- Lingua principale
- Python
- Stelle
- 2.6k
- Fork
- 1k
- Merge medio
- 5g 29m
- PR unite (30g)
- 17
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di open-telemetry/opentelemetry-python
-
Baggage is ignored by W3CBaggagePropagator and erronously causes warning 'Invalid baggage entry' Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
open-telemetry/opentelemetry-python#5678 · 1 reazione ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
open-telemetry/opentelemetry-python#5664 · 4 commenti ·
-
bug tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
Tutte le issue di open-telemetry/opentelemetry-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100