Skip to content
Judgment Labs
Esc
↑↓navigate↵open⌘Jpreview
On this page

JudgmentBaggageProcessor

Copies OTel baggage entries onto span attributes at span start.

PropType
BaggageKeyPredicateT?Any

Predicate that decides which baggage keys are propagated to span attributes.

TypeAny
DefaultCallable[[str], bool]
ALLOW_ALL_BAGGAGE_KEYS?BaggageKeyPredicateT

Default predicate that allows every baggage key.

TypeBaggageKeyPredicateT
Defaultlambda _: True

Copies OTel baggage entries onto span attributes at span start.

When a span starts, this processor reads all baggage from the parent context and sets matching entries as span attributes. Use baggage_key_predicate to control which keys are propagated.

Allow only Judgment-prefixed baggage keys:

from judgeval.trace.processors import JudgmentBaggageProcessor

processor = JudgmentBaggageProcessor(
    baggage_key_predicate=lambda k: k.startswith("judgment."),
)

__init__()

def __init__(baggage_key_predicate=ALLOW_ALL_BAGGAGE_KEYS) -> None:

Parameters

PropType
baggage_key_predicate?BaggageKeyPredicateT
TypeBaggageKeyPredicateT
DefaultALLOW_ALL_BAGGAGE_KEYS

Returns

None


on_start()

def on_start(span, parent_context=None) -> None:

Parameters

PropType
spanSpan
TypeSpan
parent_context?Optional[Context]
TypeOptional[Context]
DefaultNone

Returns

None


on_end()

def on_end(span) -> None:

Parameters

PropType
spanReadableSpan
TypeReadableSpan

Returns

None


shutdown()

def shutdown() -> None:

Returns

None


force_flush()

def force_flush(timeout_millis=30000) -> bool:

Parameters

PropType
timeout_millis?int
Typeint
Default30000

Returns

bool

Was this page helpful?