Repository navigation
fix(py): show error message and traceback on failed spans in the Dev UI - #113
Merged
Merged
Conversation
Base automatically changed from
fix/py-trace-failed-interrupted-spans
to
main
November 12, 2026 05:07
Since 0.13.0 the Dev UI poster sent spans as OTLP/JSON to /api/otlp with no events. The telemetry server's OTLP converter drops span events anyway, and the Traces tab reads a non-model span's heading and stack only from its exception event, so failed Python flow and tool spans showed "Error" and no traceback. Spans now POST TraceData to /api/traces, the shape JS and Go send and what Python sent before 0.13. A raised error records exception.type, .message (str(err)) and .stacktrace the way OTel's record_exception formats them, stored as strings so finished spans hold no frames. Interrupts record no event so the tool span still renders as Interrupted. Failures returned without raising keep status but get no event. Logs stay on /api/otlp.
huangjeff5
force-pushed
the
fix/py-devui-span-exception-events
branch
from
November 12, 2026 05:07
b1e49df to
997962f
Compare
apascal07
approved these changes
Nov 12, 2026
This was referenced Nov 15, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed flow or tool span in the Dev UI shows the error message as its heading and the Python traceback underneath again. Since 0.13.0 the heading read
Errorand the stack box was empty (or, with #63, a copy of the message).Stacked on #63 (
fix/py-trace-failed-interrupted-spans); will retarget tomainafter #63 merges.Checked in the Dev UI from
genkit start(CLI 1.40.1): on this branch thetake_orderspan details showallergen db unavailableas the heading and the full Python traceback below it. On the base branch the same trace showsErrorwith only the message in the box.Why it broke
#6132 replaced the OTel SDK +
TraceServerExporterwithDirectHttpInstrumentation, which posted spans as OTLP/JSON to${server}/api/otlpwithevents: []. Two problems stacked:span.record_exception(e)).telemetry-server/src/utils/otlp.tstoSpanData) drops spaneventsandlinksanyway, so nothing sent on/api/otlpcan reachtimeEvents.The Dev UI reads a non-model span's heading only from the first
timeEvents.timeEventwithdescription: 'exception'(exception.message), and the stack box fromexception.stacktrace, falling back tostatus.message.Changes
TraceDatato/api/traces, logs stay on/api/otlp:CollectorHttpSinknow encodes each export as the collector'sTraceData/SpanDataschema (ms timestamps, flat attribute map,instrumentationLibrary: genkit-tracer/v1,spanKind: INTERNAL,status: {code, message?},timeEvents.timeEvent[]), one payload per span. This is the endpoint and shape JS and Go post, and what Python sent before 0.13, so the server's span merge and live-view broadcast treat Python spans the same way. The background worker, queue, flush timeout, shutdown, and URL scheme check are unchanged._log_exporter.pyis untouched.exceptionevent:run_in_new_spanstoresexception.type,exception.messageandexception.stacktracein the format OTel'sSpan.record_exceptionwrites (ValueError,genkit._core._error.GenkitError,''.join(traceback.format_exception(...))), as plain strings onActiveSpan, so a finished span keeps no frames alive._StreamingCallbackErrorrecords the callback's own error. An emptystr(exc)leavesexception.messageout, so the heading falls back toErrorinstead of going blank.Decisions
exception.messageisstr(err), notGenkitError.message: For aGenkitErrorthat'sUNAVAILABLE: booking service down: after 5s, the same text asstatus.messageand the last line of the traceback..messagewould drop the status, which tells you whose fault it is, and the cause suffix, whichGenkitError.__init__builds specifically so the Dev UI shows the real reason.genkit:errorkeeps the bare.messageas before. JS and Go also put the status-prefixed string here.Interruptedonly whenexception.messageis missing, and Python'sInterruptstringifies its metadata ({'reason': 'manager approval'}), which would become the heading. The tool span keepsgenkit:state: error+genkit:metadata:interruptfrom fix(py): Dev UI traces show why generate failed, where it started, and interrupted tools #63, so it still renders as interrupted.generateandpromptbox failures into the response and callset_state('error', message=...). Nothing was raised on that span, so it getsstatus: {code: 2, message}and noexceptionevent; the stack box shows the message through itsstatus.messagefallback. JS and Go don't synthesize an event there either, and 0.12 showedErrorfor these spans too, so this isn't a regression.endTime: 0and no traceendTime, once on end./api/tracesalready ignores a stale start for a span it has as ended (file store merge +spanBroadcastEvents), which/api/otlpdidn't do for the live view. Only the root span sets the trace'sdisplayName/startTime, andendTimeonce the root ends.resource_attributesremoved from the private sink/poster:TraceDatahas no resource block, soDirectHttpInstrumentation(sink)andexport_spans(spans)drop the argument. Both are private (genkit._core._telemetry._http); only test sinks change.Cross-SDK
Python's Dev UI span wire format changes from OTLP/JSON on
/api/otlptoTraceDataon/api/traces, the format JS and Go already send and every shipped telemetry server accepts. Failed span, before vs after:JS, Go and Dart owners: nothing to do.
Breaking changes
None. No public API changes.
Testing
trace_data_encoder_test.py(new): success span shape and ms timestamps; start export (endTime: 0, no traceendTime) then end export; parent/child ids and root-only trace fields; attribute types (bool/int/float/str, JSON input, NaN); failed span with type/message/stacktrace; error escaping tool → flow;GenkitErrormessage; empty message; stream-callback unwrap; no frames held; interrupted tool rendersInterrupted; boxedgeneratefailure has status but no event. A small helper mirrors the Dev UI heading rule so the tests pin what the user sees.telemetry_test.py: against a local HTTP collector, spans POST to/api/traceswith the exception event and aget_loggerline still POSTs to/api/otlp. Existing OTLP span assertions moved toTraceData.genkit start(CLI 1.40.1) and a scratch app: rantake_order(tool raisesValueError('allergen db unavailable')) andcomp_dessert(tool raisesInterrupt) through the reflection server, thenGET /api/traces/<id>.take_orderandcheck_allergensboth storedtimeEventswithexception.type: ValueError,exception.message: allergen db unavailable, and a traceback ending in the tool'sraise;approve_compstoredgenkit:state: error,status: {code: 2}and no exception event;generatestayedsuccess.check_consistency,check_license,liccheck, pyright, pyrefly, ty, full pytest.Release note
Python: failed flow and tool spans in the Dev UI show the error message and Python traceback again (regressed in 0.13.0).