|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
RAII session returned by openinference_tracer.
More...
#include <openinference.h>
Public Member Functions | |
| ChildSpanStarter | child_span_starter () const |
Return a copied operation that opens a child while leasing the current parent through Tracer::start_span. | |
| void | close () |
| End the root span + any pending node spans. | |
| Span * | current_parent () const noexcept |
| Snapshot of the current span. | |
Public Attributes | |
| graph::GraphStreamCallback | cb |
Engine event callback. Pass to engine.run_stream(). | |
Friends | |
| NEOGRAPH_API OpenInferenceTracerSession | openinference_tracer (Tracer &, std::string, std::string) |
Open a CHAIN-kind root span and return a session whose cb opens per-node CHAIN child spans + LLM_TOKEN events under it. | |
RAII session returned by openinference_tracer.
Holds the root span (kept alive for the duration of the engine run) and the GraphStreamCallback wired to record per-node / streaming events under that root.
Usage:
close() is also called by the destructor — explicit close is recommended only when the user wants to inspect the tracer's exported spans before the session goes out of scope (e.g. in tests). Double-close is a no-op. Copies of cb are safe to retain: they become no-ops after close/destruction, and close() waits for callbacks that already entered before finalizing their spans.
Definition at line 69 of file openinference.h.
| ChildSpanStarter neograph::observability::OpenInferenceTracerSession::child_span_starter | ( | ) | const |
Return a copied operation that opens a child while leasing the current parent through Tracer::start_span.
Safe across close/destruction.
| void neograph::observability::OpenInferenceTracerSession::close | ( | ) |
End the root span + any pending node spans.
Idempotent.
close() resets the internal unique_ptr<Span> over the root span (and the corresponding pending-node-span stacks). If your Tracer adapter handed out raw pointers into caller-owned span storage and stored them for post-close inspection, those pointers become dangling — any walk of "all spans I've recorded" after close() reads freed memory and may crash, hang, or print garbage (issue #24).The adapter must own the span DATA itself (not just the wrapper). Pattern: split a RecordedSpan (owned by the adapter in unique_ptrs) from the Span wrapper handed back to the OpenInference layer. The wrapper's destruction is then harmless — the recorded data lives in the adapter and survives close(). See tests/test_openinference_cpp.cpp (InMemoryTracer) and examples/49_openinference.cpp (PrintTracer) for the canonical shape.
|
noexcept |
Snapshot of the current span.
The pointer is only valid until another session operation or close(); use child_span_starter() when opening a child concurrently with session teardown.
|
friend |