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

Adapter facade for a tracing backend. More...

#include <tracer.h>

Public Member Functions

virtual std::unique_ptr< Spanstart_span (std::string_view name, Span *parent=nullptr)=0
 

Detailed Description

Adapter facade for a tracing backend.

The OpenInference helpers call start_span to open named spans (root + per-node + per-LLM-call). The parent argument carries the span hierarchy — a non-null parent means "open this as a child of the supplied span", null means "open as a root".

Adapter authors are free to ignore parent if their backend captures parents implicitly via an OTel context propagation hook; the OpenInference helpers DO supply the parent explicitly so a dep-free adapter can link spans without relying on contextvars- style implicit context.

Warning
Span lifetime contract. The OpenInference layer owns the unique_ptr<Span> your start_span returns and may release it (e.g. inside OpenInferenceTracerSession::close()). If your adapter stores raw pointers into the wrapper objects to allow post-close inspection (printing, test asserts, attribute audit), those pointers become dangling at close time — see issue #24.

The supported pattern is: own the recorded span DATA in your adapter (a RecordedSpan-style struct held in unique_ptr<RecordedSpan> inside the tracer), and have the Span wrapper your start_span returns merely point at that recorded struct. The wrapper's destruction is then harmless. See tests/test_openinference_cpp.cpp::InMemoryTracer and examples/49_openinference.cpp::PrintTracer for the reference shape.

Definition at line 114 of file tracer.h.

Member Function Documentation

◆ start_span()

virtual std::unique_ptr< Span > neograph::observability::Tracer::start_span ( std::string_view  name,
Span parent = nullptr 
)
pure virtual
Parameters
nameSpan name (e.g. "graph.run", "node.researcher", "llm.complete").
parentOptional parent span. May be a span this tracer itself returned from a previous start_span. Adapters should treat null as "root span".
Returns
Owned span; caller must call end() before drop.

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