Migrating from Langfuse
cetra reads the spans that the Langfuse Python SDK produces, so you can keep your Langfuse instrumentation while you move.
Point the exporter at cetra
Section titled “Point the exporter at cetra”The Langfuse SDK builds on OpenTelemetry and installs its own tracer provider. By default it exports to Langfuse. To send its spans to cetra, add an OTLP exporter to that provider after you create the client.
from langfuse import Langfusefrom opentelemetry import tracefrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporterfrom opentelemetry.sdk.trace.export import BatchSpanProcessor
langfuse = Langfuse()
trace.get_tracer_provider().add_span_processor( BatchSpanProcessor( OTLPSpanExporter( endpoint="http://localhost:8080/v1/traces", headers={"Authorization": "Bearer <SK_CETRA_KEY>"}, ) ))Replace <SK_CETRA_KEY> with your sk-cetra- API key.
What carries over
Section titled “What carries over”The fixtures show the Langfuse SDK 5.1.0 producing these, and cetra reading them:
@observespans, withas_type="tool"becoming atoolspan and generations becomingllmspans.- The input and output of decorated functions, and the messages of the OpenAI drop-in.
- Session ID, user ID and tags, set at trace level, become the cetra session, user and tags. Trace metadata becomes metadata.
- The model, model parameters and
usage_details, including cached and reasoning tokens. - A reported cost (
cost_details) is kept as the reported cost, and cetra does not replace it with a computed one, except a total of exactly 0 on a span that has tokens, which is priced from the price table (see Cost and tokens). completion_start_timegives the time to first token.- An observation with level
ERRORhas the statuserror.
What changes
Section titled “What changes”- Scores and datasets are not spans, so they do not move with the exporter. Write scores with the cetra SDK or the API. See Scores.
- Spans arrive in cetra under cetra’s own names and fields. See Span attributes for the Langfuse attributes cetra reads.
Limits
Section titled “Limits”- The fixtures are Python only.
- The exporter wiring above is not covered by a test. The fixtures cover the spans, not their delivery.
- Traces: read the trace as a tree and a timeline.
- Cost and tokens: how cost is computed from the token counts.
- Online rules: score these traces automatically.