NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::observability::OpenInferenceTracerSession Class Reference

RAII session returned by openinference_tracer. More...

#include <openinference.h>

Public Member Functions

void close ()
 End the root span + any pending node spans.
 
Spancurrent_parent () const noexcept
 Internal — exposed so OpenInferenceProvider can open LLM child spans under the currently-active node 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.
 

Detailed Description

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:

auto session = openinference_tracer(my_tracer);
engine.run_stream(cfg, session.cb);
session.close(); // ends the root + any straggler node spans
friend 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_TOKE...

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.

Definition at line 67 of file openinference.h.

Member Function Documentation

◆ close()

void neograph::observability::OpenInferenceTracerSession::close ( )

End the root span + any pending node spans.

Idempotent.

Warning
Adapter authors: 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.

Friends And Related Symbol Documentation

◆ openinference_tracer

NEOGRAPH_API OpenInferenceTracerSession openinference_tracer ( Tracer ,
std::string  ,
std::string   
)
friend

Open a CHAIN-kind root span and return a session whose cb opens per-node CHAIN child spans + LLM_TOKEN events under it.

Parameters
tracerTracer adapter. Must outlive the session.
root_nameSpan name for the root (default "graph.run").
node_span_prefixPrefix for per-node spans (default "node.").

The documentation for this class was generated from the following file: