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

Opaque per-request span; lifetime is unique_ptr. More...

#include <tracer.h>

Public Member Functions

virtual void add_event (std::string_view name, std::string_view payload={})=0
 Record a discrete time-stamped event on this span (mapped to OTel's Span::AddEvent).
 
virtual void end ()=0
 Close the span.
 
void set_attribute (std::string_view key, const char *value)
 Forwarding overload so string literals ("CHAIN") reach the string_view sink rather than slipping into a different overload.
 
virtual void set_attribute_bool (std::string_view key, bool value)=0
 Renamed off the set_attribute overload set on purpose: a const char* literal passed as the value would otherwise resolve to (string_view, bool) (pointer-to-bool standard conversion outranks the user-defined string_view conversion), silently dropping every string attribute.
 

Detailed Description

Opaque per-request span; lifetime is unique_ptr.

Adapters create a Span by wrapping their backend's span handle (e.g. opentelemetry::trace::Span). Calling end() is required before destruction for proper export — the destructor does NOT call end() on its own (an unended span signals "still in flight" to the OpenInference helpers and lets _close_all-style cleanup paths distinguish active vs. already-ended spans).

Thread safety: implementations MAY be called from multiple threads (engine event callback runs on whatever pool worker emitted the event). Adapter authors must serialize internally if their backend span isn't thread-safe.

Definition at line 45 of file tracer.h.

Member Function Documentation

◆ add_event()

virtual void neograph::observability::Span::add_event ( std::string_view  name,
std::string_view  payload = {} 
)
pure virtual

Record a discrete time-stamped event on this span (mapped to OTel's Span::AddEvent).

Used by the openinference layer for LLM_TOKEN events so each streamed chunk is visible in the trace timeline without inflating the parent span's attribute payload.

◆ end()

virtual void neograph::observability::Span::end ( )
pure virtual

Close the span.

After end() returns the span is finalized; further attribute / event writes are no-ops on most backends.

◆ set_attribute()

void neograph::observability::Span::set_attribute ( std::string_view  key,
const char *  value 
)
inline

Forwarding overload so string literals ("CHAIN") reach the string_view sink rather than slipping into a different overload.

Non-virtual; defined inline.

Definition at line 64 of file tracer.h.

◆ set_attribute_bool()

virtual void neograph::observability::Span::set_attribute_bool ( std::string_view  key,
bool  value 
)
pure virtual

Renamed off the set_attribute overload set on purpose: a const char* literal passed as the value would otherwise resolve to (string_view, bool) (pointer-to-bool standard conversion outranks the user-defined string_view conversion), silently dropping every string attribute.

Keep bool out of the overload set entirely.


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