processor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package processor contains the Langfuse OpenTelemetry span processor.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldExport

func ShouldExport(span sdktrace.ReadOnlySpan) bool

ShouldExport applies the Langfuse v4 smart default filter.

Types

type AdmitFunc added in v0.4.0

type AdmitFunc func(context.Context)

AdmitFunc accepts the pending admission token in ctx, confirming to the starting SDK observation that this processor observed its start before any teardown. It runs synchronously inside Tracer.Start and must not block.

type Config

type Config struct {
	Next sdktrace.SpanProcessor

	PublicKey   string
	Environment string
	Release     string

	ContextAttributes ContextAttributesFunc
	HasTraceClaim     TraceClaimFunc
	Admit             AdmitFunc
}

Config configures a Processor.

type ContextAttributesFunc

type ContextAttributesFunc func(context.Context) []otelattr.KeyValue

ContextAttributesFunc returns already-normalized attributes belonging to this processor's client. The root package owns the context representation so multiple isolated clients can safely use the same context.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor adds Langfuse propagation and application-root attributes, then forwards only LLM-relevant sampled spans to the wrapped processor.

func New

func New(config Config) (*Processor, error)

New returns a Langfuse processor wrapping config.Next.

func (*Processor) ForceFlush

func (p *Processor) ForceFlush(ctx context.Context) error

ForceFlush forwards a flush only while the processor is active.

func (*Processor) OnEnd

func (p *Processor) OnEnd(span sdktrace.ReadOnlySpan)

OnEnd removes start-time state and applies the final smart filter. The end decision sees attributes added late by streaming/provider instrumentation.

func (*Processor) OnStart

func (p *Processor) OnStart(parent context.Context, span sdktrace.ReadWriteSpan)

OnStart fills missing Langfuse attributes and performs the start-time half of application-root detection. It intentionally tracks only direct parents, matching the current official Python processor.

func (*Processor) Shutdown

func (p *Processor) Shutdown(ctx context.Context) error

Shutdown stops accepting work, clears application-root state, and shuts down the wrapped processor exactly once. Later calls are harmless; a caller concurrent with the first shutdown may stop waiting when its own context is canceled.

type TraceClaimFunc

type TraceClaimFunc func(context.Context, oteltrace.TraceID) bool

TraceClaimFunc reports whether ctx contains this processor's client-scoped application-root claim for traceID.

Jump to

Keyboard shortcuts

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