Documentation
¶
Overview ¶
Package telemetry provides OpenTelemetry integration for PromptKit, including TracerProvider management and an event-to-span listener.
Index ¶
Constants ¶
const ( // InstrumentationName is the OTel instrumentation scope name. InstrumentationName = "github.com/AltairaLabs/PromptKit" // InstrumentationVersion is the OTel instrumentation scope version. InstrumentationVersion = "1.0.0" )
Variables ¶
This section is empty.
Functions ¶
func NewTracerProvider ¶ added in v1.3.2
func NewTracerProvider(ctx context.Context, endpoint, serviceName string) (*sdktrace.TracerProvider, error)
NewTracerProvider creates a TracerProvider that exports spans via OTLP/HTTP. The caller is responsible for calling Shutdown on the returned provider.
func SetupPropagation ¶ added in v1.3.2
func SetupPropagation()
SetupPropagation configures the global OTel text-map propagator to handle W3C TraceContext, W3C Baggage, and AWS X-Ray trace headers.
Types ¶
type OTelEventListener ¶ added in v1.3.2
type OTelEventListener struct {
// contains filtered or unexported fields
}
OTelEventListener converts runtime events into OTel spans in real time. It implements the events.Listener function signature via its OnEvent method. It is safe for concurrent use and tolerates out-of-order event delivery.
func NewOTelEventListener ¶ added in v1.3.2
func NewOTelEventListener(tracer trace.Tracer) *OTelEventListener
NewOTelEventListener creates a listener that creates OTel spans from runtime events.
func (*OTelEventListener) EndSession ¶ added in v1.3.2
func (l *OTelEventListener) EndSession(sessionID string)
EndSession ends the root span for the given session.
func (*OTelEventListener) OnEvent ¶ added in v1.3.2
func (l *OTelEventListener) OnEvent(evt *events.Event)
OnEvent handles a single runtime event and creates/completes OTel spans accordingly. It is safe for concurrent use and can be passed to EventBus.SubscribeAll.
func (*OTelEventListener) StartSession ¶ added in v1.3.2
func (l *OTelEventListener) StartSession(parentCtx context.Context, sessionID string)
StartSession creates a root span for the given session, optionally parented under the span context in parentCtx.