telemetry

package
v1.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package telemetry provides OpenTelemetry integration for PromptKit, including TracerProvider management and an event-to-span listener.

Index

Constants

View Source
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.

func Tracer added in v1.3.2

func Tracer(tp trace.TracerProvider) trace.Tracer

Tracer returns a named tracer from the given TracerProvider. If tp is nil the global noop provider is used.

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. It is idempotent: if a session already exists for the given ID, the previous session span is ended before creating a new one. This allows callers to call StartSession on every Send/Stream with a fresh parent context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL