Skip to content

v0.4.0

Latest

Choose a tag to compare

@fgn fgn released this 21 Jul 22:45

Deterministic whole-trace sampling for isolated mode, with correlated application-level sampling and score coordination. All additions are backward compatible; the default configuration keeps exporting everything.

Added

  • Config.SampleRate (LANGFUSE_SAMPLE_RATE, [0, 1], nil keeps everything) selects the fraction of traces exported in isolated mode, decided once per trace by a deterministic threshold on the trace ID that matches OpenTelemetry's TraceIDRatioBased bit-for-bit.
  • Client.WithSampleRate overrides the fraction per context path, so one process can export different kinds of traces at different rates. The decision is inherited by every SDK observation in the trace, including across foreign middle spans and later rate changes.
  • TraceSampledAt exposes the same deterministic predicate for correlated application-level sampling: decisions at a smaller fraction are guaranteed subsets of those at a larger one, so work gated at a small fraction runs only on traces kept for export. Strict (bool, error) contract — out-of-range fractions and malformed trace IDs error instead of guessing.
  • Observation.Sampled reports the decision (a sampling decision, not a delivery guarantee).

Changed

  • Sampled-out observations keep their trace and span IDs and become cheap no-ops: Update and RecordError return before serialization, Mask, or Error() calls.
  • A score recorded directly on a sampled-out, SDK-originated context path targeting that trace is suppressed with a once-per-client diagnostic, so sampled-out traces do not accumulate orphaned scores. Session-only, out-of-context, foreign-origin, and all borrowed-mode scores are delivered unchanged.
  • Borrowed mode is unaffected: the application's sampler remains authoritative and the new controls are ignored there with a diagnostic.
  • A start that misses processor admission or observes the shutdown transition immediately after span start now returns the no-op observation instead of a live handle whose export path is already torn down.

This release also includes the 0.3.0 changelog entries (prompt management reads with client-side caching and fallbacks, Observation.EndAt, score backdating and score configs, and score delivery through the JSON ingestion endpoint), which were recorded earlier but never tagged.