Package dev.braintrust.trace
Class BraintrustContext
java.lang.Object
dev.braintrust.trace.BraintrustContext
Used to identify the braintrust parent for spans and experiments. SDK users probably don't want
to use this and instead should use
BraintrustTracing or Eval-
Method Summary
Modifier and TypeMethodDescriptionstatic BraintrustContextfromContext(io.opentelemetry.context.Context context) Retrieves a BraintrustContext from the given Context.static io.opentelemetry.context.ContextofExperiment(String experimentId, io.opentelemetry.api.trace.Span span) Creates a context for an experiment parent.static io.opentelemetry.context.ContextsetParentInBaggage(io.opentelemetry.context.Context ctx, String parentType, String parentId) Sets the parent in baggage for distributed tracing.
-
Method Details
-
ofExperiment
public static io.opentelemetry.context.Context ofExperiment(@Nonnull String experimentId, @Nonnull io.opentelemetry.api.trace.Span span) Creates a context for an experiment parent. -
setParentInBaggage
public static io.opentelemetry.context.Context setParentInBaggage(@Nonnull io.opentelemetry.context.Context ctx, @Nonnull String parentType, @Nonnull String parentId) Sets the parent in baggage for distributed tracing.Baggage propagates automatically via W3C headers when propagators are configured, allowing parent context to flow across process boundaries.
- Parameters:
ctx- the context to updateparentType- the type of parent (e.g., "experiment_id", "project_name", "playground_id")parentId- the ID of the parent- Returns:
- updated context with baggage set
-
fromContext
Retrieves a BraintrustContext from the given Context. -
projectId
-
experimentId
-